here, its kind of hard to explain in words but my diagram is correct. i know this is an apple site but it has the best diagrams i could find.
http://developer.apple.com/techpubs/...oMemMgmt.4.htm
the definitions given above by DavidP are correct.
>Are variables allocated on the heap also pushed onto the stack?
no, objects dynamically allocated are stored in the heap. the pointer to the object is the local variable stored on the stack.
ill try one more ascii memory map...
Code:
[c++]
object* obj = new object("blah");
[/c++]
meanwhile, in memory....
------------------------------------------
Kernel space
------------------------------------------
Stack: variable 'obj' is stored here (the pointer)
HEAP: the actual object returned by new
and pointed to by 'obj' is stored here.
---------------------------------------------