- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ok, that's good to know - thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page