Stack:
- 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).
Heap:
- Variables of reference type are allocated in heap.
- Memory allocation is slow.
- If the object is big one, using reference type is fine (heap).
...S.VinothkumaR.
2 comments:
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?
Post a Comment