Re: heap allocation of arrays



robert.corbett@xxxxxxx wrote:
| I recently received a request to add an option to Sun Fortran
| to force all arrays to be allocated on the heap. Automatic
| arrays and other arrays that would normally be allocated on
| the stack would be replaced with pointers on the stack.
| Space for the arrays would be allocated and deallocated
| using malloc and free.
|
| The motivations given for requesting this option were that
| the default stack size for most programs is smaller than the
| default heap size and that failure to allocate space on the
| heap is easier to detect than failure to allocate space on the
| stack.
|
| What do you think about such an option?

FWIW, I deem Glen's proposal that the maximal *size* of stack
array is selectable the most reasonable compromise between
usability (c'mon, does one really want to heap-allocate bunch
of small variables just because one of them causes stack overflow)
and ease of implementation.

I recall a discussion on Intel Forum regarding a suggestion of
an "opposite" feature -- make ALLOCATABLE arrays to be allocated
on the stack if they fit, for efficiency reasons. As Steve explained
then, it's not easy to get the top of the stack on Windows, so it
wasn't quite feasible thing to do.

--
Jugoslav
___________
www.xeffort.com

Please reply to the newsgroup.
You can find my real e-mail on my home page above.
.



Relevant Pages

  • Re: run-time vs compile-time
    ... > offset related to some location (like stack base) somewhere. ... > offset from heap to pi. ... When you allocate an int on the heap, it is allocated at address 1. ... application has a given amount of memory it can use as it wishes. ...
    (alt.comp.lang.learn.c-cpp)
  • Re: run-time vs compile-time
    ... > offset related to some location (like stack base) somewhere. ... > offset from heap to pi. ... When you allocate an int on the heap, it is allocated at address 1. ... application has a given amount of memory it can use as it wishes. ...
    (comp.lang.cpp)
  • Re: "Heap" (was Re: static, global variable memory allocation)
    ... common to refer to the area used to allocate automatic objects ... Can a perverse but conforming implementation use the "heap" for ... used a linked list of save areas instead of a stack. ... CPU-specific region of memory that grows linearly in one direction, ...
    (comp.lang.c)
  • Re: heap allocation of arrays
    ... to force all arrays to be allocated on the heap. ... the stack would be replaced with pointers on the stack. ... heap is easier to detect than failure to allocate space on the ...
    (comp.lang.fortran)
  • Re: heap allocation of arrays
    ... to force all arrays to be allocated on the heap. ... the stack would be replaced with pointers on the stack. ... heap is easier to detect than failure to allocate space on the ...
    (comp.lang.fortran)