Re: where? heap or stack?

From: Jeff Schwab (jeffplus_at_comcast.net)
Date: 05/05/04


Date: Wed, 05 May 2004 10:13:03 -0400

Leor Zolman wrote:
> On Wed, 05 May 2004 06:25:18 -0400, Jeff Schwab <jeffplus@comcast.net>
> wrote:
>
>
>
>>Yes. Careful about calling it "heap," though; "stack" and "heap" in C++
>>refer to standard data structures, not to regions of memory.
>>
>
>
> Interesting this issue should just now come up, as I was wondering myself
> about it while reading through Eckel/Allison's _Thinking in C++ Volume II_.
> Throughout the book, they use the word "heap" synonymously with "free
> store". IOW, instead of saying "allocated dynamically" or even "allocated
> on/from the free store", they consistently say "from the heap", use the
> term "heap memory", and even name a utility class for monitoring use of
> new/delete "TraceHeap".
>
> Now I'm used to seeing this wording being picked on, but hasn't it in fact
> become effectively idiomatic to say "allocated on the heap" when you simply
> mean dynamically? Sort of like the word "momentarily" has now,
> unfortunately, become effectively synonymous with "in a moment"? In
> reality, how often is the use of the word "heap" /really/ going to be
> ambiguous when it pops up in discussions like this? I'm not happy about it,
> but I'd vote to bite the bullet and just let people say "heap" unmolested
> unless it really isn't clear what they're talking about...

You're absolutely right. The FAQ for this group even refers to the
stack & the heap in the idiomatic way. Unfortunately, when one uses
these terms in a news group posting, someone likely will get very huffy
and say something pedantic unless you beat them to the punch. I try to
do nip such complaints in the bud in a more humane way than some folks
might.

Of course, in "real world" conversations, development is usually being
done for well-known platforms, so I can point to documentation that
explains the free store really is a heap, and that function-scoped
variables really are on a stack. :)



Relevant Pages

  • Re: redefining operator new and STL classes
    ... >> stack or the heap? ... > is used to refer to forms of the new operator ... > which is to say, first memory is allocated using an operator new, ...
    (alt.comp.lang.learn.c-cpp)
  • [OT] Re: Which scope for variables being used in a loop?
    ... Escape Analysis in JSE6 might rule it out, i.e. allocate them on ... stack, for small objects. ... which they refer are allocated on the heap as always. ...
    (comp.lang.java.programmer)
  • Re: Sorting Data that feeds into other formulas....
    ... So GL$12 will always refer to row 12, whatever you do with your data. ... Then, when you sort, the reference will "follow" the data to the new cell. ... > Ranking'!GL$14+'Rep Stack Ranking'!GL$40 ...
    (microsoft.public.excel.misc)
  • Re: "Heap" (was Re: static, global variable memory allocation)
    ... common to refer to the area used to allocate automatic objects ... as the "stack", but I think most of us agree that this is misleading ... I'd say that "the heap" could refer to the region ...
    (comp.lang.c)
  • Re: collect data using threads
    ... I believe there is a method pop() already supplied for you. ... Normally though, I think one would refer to these as the head and tail (not top and bottom), and probably call the whole thing a queue, rather than a stack. ...
    (comp.lang.python)