/heap_arrays

/heap_arrays

Hi group,A question about option/heap_arrays:as I understand it, it will put automatic arrays on the heap instead of the stack.Will the automatic arrays therefore "exist" in the heap after the subroutine-exit?Ist itpreferable to declare the current automatic arrays as allocatable arrays ?Cheers-Ralf

5 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.
mecej4's picture

An option that would require that users change their source code (in order to deallocate at subroutine exit those local arrays that were allocated on the heap) would be quite unpopular. I believe that heap allocated arrays are managed separately by the Fortran runtime and are not accessible through the Fortran ALLOCATED() and DEALLOCATE() statements.

There is some overhead for garbage collection. That is why the compiler gives you the ability to specify a threshold for array sizes that has to be exceeded to become eligible for heap allocation.

Steve Lionel (Intel)'s picture

The temporaries allocated on the heap are automatically deallocated when they are no longer needed. This may be at routine exit, or earlier in some cases.

Steve

Ok, that's good to know - thanks!

Steve Lionel (Intel)'s picture

Quoting mecej4
There is some overhead for garbage collection. That is why the compiler gives you the ability to specify a threshold for array sizes that has to be exceeded to become eligible for heap allocation.

The option for the threshold is really not useful. At present it is effective only for automatic arrays whose size is known at compile time, which is very unlikely. There is no "garbage collection", but the compiler does keep a list, per routine, of heap-allocated temporaries and automatics and makes sure they are deleted on routine exit.

Steve

Login to leave a comment.