Satck and Heap

Hi friends,

What is the difference between Stack and Heap?
When we should use Heap/Stack?
Which one is fast?
thank you mirage,its really help full.
stack -
is a LIFO data structure
is a part of RAM
fixed and limited
managed by CPU and memory will not become fragmented
for local variable only
fast as compare to Heap because reading from and writing to stack become very efficient

fast as compare to Heap because reading from and writing to stack become very efficient
The only inefficiency with regard to the heap is the allocation and deallocation of objects. Once an object has been allocated, access is nearly indisinguishable from any object on the stack.
yes I agree with you AbstrAnon.
After getting address of object from heap CPU treat it same n work with same speed as stack.
Topic archived. No new replies allowed.