Re: heap allocation of arrays



Jugoslav Dujic wrote:

(snip regarding heap vs. stack allocation)

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.

There is a non-standard C library function alloca() for stack
allocation of dynamic arrays in C. The main advantage is not
having to remember to free() them. I never use it because it
is not be available on all systems.

-- glen

.



Relevant Pages

  • Re: Optimizing stack access for a stack based VM
    ... Local variables should occur as natural operands of instructions (on ... from the middle of the stack. ... Global stack allocation has the potential for significant savings by ... register allocator with very few global registers does. ...
    (comp.compilers)
  • Re: A solution for the allocation failures problem
    ... struct nested *ptr1; ... which would jump to label if the allocation failed. ... implemented for the stack under windows. ... So in the malloc instance I would say you make use of the pre-allocated reserve rather than freeing it so you can do further mallocs whilst recovering. ...
    (comp.lang.c)
  • Re: Fortran memory allocation (stack/heap) issues
    ... > rather than Fortran, ... dynamic allocation, and relatively little stack allocation. ... value return and arrays by reference. ...
    (comp.lang.fortran)
  • Re: Are static array pointers thread safe?
    ... 'static' that it is NOT allocated on the stack! ... how allocation works; I've even had one correspondent assure me that he would not use ... globals, static data members of classes, and local statics. ... observe all sorts of strange things in the absence of synchronization, ...
    (microsoft.public.vc.mfc)
  • Re: allocatable array *not* equivalent to dynamic allocation?
    ... Allocatable arrays in fact *ARE* a form of dynamic allocation, ... I infer from the citation. ...
    (comp.lang.fortran)