[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Stack vs. heap?
- Subject: Re: Stack vs. heap?
- From: Don Bruder <dakidd@sonic.net>
- Date: Wed, 21 Jun 2006 15:48:46 -0700
- Newsgroups: comp.sys.apple2
- Organization: Chaotic Creations Unlimited
- References: <W9cmg.37$oA2.73@news.oracle.com>
- User-agent: MT-NewsWatcher/3.1 (PPC)
- Xref: g2news2.google.com comp.sys.apple2:9574
In article <W9cmg.37$oA2.73@news.oracle.com>,
Martin Doherty <martin.doherty@undisclosed.com> wrote:
> I believe I thoroughly understand the operation of a stack, but the term
> "heap" is a mystery. 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?
>
> Thanks
> Martin
Stack:
A segment of memory where fixed-size values (typically one logical
"word" in size, regardless of whether the word is 1 byte, 2 bytes, 4
bytes, or some other number of bytes) get "pushed" and "popped" for
temporary storage - The first value pushed is the last to be popped. See
also "last in, first out" (AKA "LIFO") queue. Although the operation of
a stack and a LIFO is generally handled differently at the "Step 1 do
this, step 2 do that, step 3 do something else..." level, they perform
in exactly the same way at the "overall picture" level.
Heap:
A segment of memory where chunks of arbitrary sizes get allocated, used
for storage, then released for re-use. See also "memory pool".
"Heap" can have variou meanings depending on the machine architecture
and programming model and/or language being used. In the case of Apple
Pascal, "Heap" generally refers to "all of the memory allocated to the
program that isn't executable code, static strings, constant values, or
declared variables". Arrays are generally in the heap. Likewise, the
values of string variables (which are, of course, little more than a
special case of arrays in Pascal)
--
Don Bruder - dakidd@sonic.net - If your "From:" address isn't on my whitelist,
or the subject of the message doesn't contain the exact text "PopperAndShadow"
somewhere, any message sent to this address will go in the garbage without my
ever knowing it arrived. Sorry... <http://www.sonic.net/~dakidd> for more info