william007
asked on
Heap and Stack
What is heap and stack? and what is their relationship?
I am new to this, and hope someone can recommend some introductory URLs that clearly introduce this, thanks:-)
I am new to this, and hope someone can recommend some introductory URLs that clearly introduce this, thanks:-)
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Correct.
Another description from: http://blogs.wwwcoder.com/govinda/archive/2004/08/16/688.aspx
Stack and Heap:
Both of 'em are sources from which memory is allocated. Stack is automatic, which is created when memory is in scope, and destroyed when it is out of scope. Heap is manual and created and destroyed when requested. On stack, the local variables (unless they are static or register data members), function parameters are stored on stack. On heap normally global variables, static local variables, any data allocated by using calls like new, malloc, calloc etc. memory allocation calls.
Another description from: http://blogs.wwwcoder.com/govinda/archive/2004/08/16/688.aspx
Stack and Heap:
Both of 'em are sources from which memory is allocated. Stack is automatic, which is created when memory is in scope, and destroyed when it is out of scope. Heap is manual and created and destroyed when requested. On stack, the local variables (unless they are static or register data members), function parameters are stored on stack. On heap normally global variables, static local variables, any data allocated by using calls like new, malloc, calloc etc. memory allocation calls.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
William, if you're after an abstract definition of a stack & heap, then please ignore this post.. But if you have a particular context, then perhaps we can provide a simpler and more suitable definition ...
(e.g., the "Java Heap").
(e.g., the "Java Heap").
ASKER
Thanks for all the reply:-)
InteractiveMind, I would like to hear about the definition in Java context.
InteractiveMind, I would like to hear about the definition in Java context.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
So, how about Java Stack? Is it only use for recursive call?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi, InteractiveMind,
Thanks, this gave me a more "concrete" view of heap and stack.
My last question is,
1)Is this practise apply to C++ and VB also?
2)How the Non Object Oriented language(like C etc) make use of heap?
Thanks, this gave me a more "concrete" view of heap and stack.
My last question is,
1)Is this practise apply to C++ and VB also?
2)How the Non Object Oriented language(like C etc) make use of heap?
I'm afraid that my understanding of lower-level programming is limited, so I could not give you a definite answer.
[Stack's as data types are certainly used in C, C++, and VB though]
Sorry
[Stack's as data types are certainly used in C, C++, and VB though]
Sorry
ASKER
Thanks:-)
--> 1)Is this practise apply to C++ and VB also?
Assuming you are talking about stack processing, yes, all languages that make use of stacks are processed LIFO.
--> 2)How the Non Object Oriented language(like C etc) make use of heap?
These are used to store your variables or varaible that may be needed by the system.
See:
http://www.cprogramming.com/tutorial.html
for more information.
Assuming you are talking about stack processing, yes, all languages that make use of stacks are processed LIFO.
--> 2)How the Non Object Oriented language(like C etc) make use of heap?
These are used to store your variables or varaible that may be needed by the system.
See:
http://www.cprogramming.com/tutorial.html
for more information.
ASKER
--> 1)Is this practise apply to C++ and VB also?
Are they using heap to store object, and static variable those kind of things also?
Are they using heap to store object, and static variable those kind of things also?
ASKER