Difference between Stack and Heap

- Variables of value type are allocated in stack.
- Memory allocation of stack is speader than heap.
- If the object is small we should use value type (stack).
- Variables of reference type are allocated in heap.
- Memory allocation is slow.
- If the object is big one, using reference type is fine (heap).



datta said...
This comment has been removed by the author.
datta said...

if stack is speedier, so why not use only stack,why we need heap then.AFAIK, both use same underlying memory at hardware level. so why stack size should be limited?