Re: heap allocation of arrays



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.

_If_ indeed one needs to increase the stack size explicitly (such
as with Winwoes), this is a convenience option, agreed. I do believe,
however, that the OS should be able to adapt the stack size appropriately.
Threaded code, with smallish stacks for each thread that cannot easily
be auto-expanded, would be another reason to at least have this option.

The detection does seem easier, because there is an explicit malloc() that
can fail, and it's fairly easy to attribute that failure to a particular
allocation request. If stack allocation is just a computation on the stack
pointer on routine entry and failure then is an access violation, there is
no way to attribute the failure to a particular array, and indeed its often
difficult to distinguish this failure from any other access violation.

Summary: I think it would be a good feature to have, but certainly not the
default. Do you already offer pragmas? If so, allow the programmer to set
this option on a per-array basis.

Jan
.



Relevant Pages

  • Re: dynamic array in MFC
    ... I can't find reason of failure my application... ... THe call stack is useless because it displays in such a tiny font that I can't even read ... list control, but don't keep a copy you think you are indexing into. ... You are still not showing the entire program, and you are not showing what line of your ...
    (microsoft.public.vc.mfc)
  • Re: Stack implementation of Linked List
    ... /* A Stack implementation of a singly linked list with 4 operations: ... struct my_stack* next; ... struct stack_list* stack_new(void) ... exit(EXIT FAILURE); /* There is no point in going beyond this ...
    (comp.lang.c)
  • Re: nolimit ruling
    ... There are three players: two with big stacks and one with a small ... One big stack says, "I'll put you all-in" as a bluff. ... The game slows down because you have to confirm the size of the bet ... problem caused by their failure to make sure they understand before they act. ...
    (rec.gambling.poker)
  • Re: ORDER in the 49G+ compared to the 48G; Question about executing keys
    ... That is not a failure by any means. ... it would be a failure for any command used in a program to leave any *unpredictable* number of results on the stack, because then the program would lose the ability to keep track of what was on the stack, which is often rather essential for proper function of programs. ... already suffer from this oversight, because if any program is written to leave a variable number of results on the stack during the execution of those commands, the fact that if the "variable number of results" goes down to zero, then *no* list (rather than an *empty* list) gets returned has always needed some special or defensive programming to compensate for that unthoughtful behavior. ...
    (comp.sys.hp48)
  • Re: Stack and Stack frame sizes in AIX
    ... "AIX Programmer" writes: ... Unless you manipulate the -bmaxdata ld argument, the stack and heap share ... You can allocate space on the stack using the C "alloca" function. ...
    (comp.unix.aix)