[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Stack vs. heap?
"schmidtd" (schmidtd@my-deja.com) writes:
> Martin Doherty wrote:
>> I believe I thoroughly understand the operation of a stack, but the term
>> "heap" is a mystery.
>
> A heap isn't a classical data structure in the way a stack or queue is,
> so don't get confused by the similarity in naming.
>
>> I know it's used in UCSD/Apple Pascal for memory
>> management functions of some kind; can anyone explain to me what a heap
>> is in general concept, and what it's used for in Pascal?
>
> A heap is a chunk of memory that is used by a language to keep track of
> variables. Applesoft, for example, stores variables at HIMEM and works
> its way "down" in memory as variables get filled/used. That's
> conceptually a heap, though I don't think it ever gets refered to that
> way.
>
And isn't a heap something that comes and goes? Ie, you need some storage,
it gets allocated, and then the memory is returned to free memory after
it's not being used.
This is different from variables that remain forever, such as the system
variables that use up the zero-page.
And to reference your last bit about how heaps can make use of the stack,
that can be done because they aren't long term storage.
Michael