Storage management routines

The routines described in this section provide a virtual storage heap. The virtual memory heap is located in memory above the stack, and has an initial size of 100 Megabytes. Since these routines work with addresses, the storage acquired by these routines must be manipulated by the 'core' intrinsics. As with any storage heap, it is important to avoid excessive fragmentation. This can be achieved by a variety of strategies, such as allocating blocks of fixed size, or de-allocating all allocated storage at once, so that no 'holes' are created. The first fit algorithm is used by the routines. Block sizes are rounded up to multiples of 4 bytes in size and carry a maximum of a 16-byte overhead. This overhead is reduced when many blocks are allocated and can be reduced to as little as 4 bytes. It is not necessary to return allocated storage before a program terminates - this is done automatically.

Under Win32 there are two 100MB heaps:

a) A Fortran heap used by GET_STORAGE@, RETURN_STORAGE@ and SHRINK_STORAGE@. This is fully virtual. Pages are provided by the run-time system in order to fill program page demands. The program may fail if it uses too much of the address space allocated or if the physical resources of the system are not sufficient to satisfy the program's demands.

b) A C/C++ heap used by malloc, new etc. in order to provide physical (committed) pages.

Memory allocated from this heap is guaranteed to be available. Memory allocated by GET_STORAGE@ should not be returned using free or delete. Similarly, memory allocated using malloc or new should not be returned using RETURN_STORAGE@.

 

GET_STORAGE@

Gets a block of storage of size N bytes from the storage heap.

RETURN_STORAGE@

Returns a block of storage.

SHRINK_STORAGE@

Shrinks a block of storage.

GET_GSTORAGE@

Gets a block of storage of size N bytes directly from the operating system.

RETURN_GSTORAGE@

Returns a block of storage storage allocated by GET_GSTORAGE@.

 

See also: Standard Fortran 95 storage allocation

 

 

Basket
Empty
 
Copyright © 1999-2024 Silverfrost Limited