Qus:    Give the differences between the stack and heap?
Dec 14, 2020 12:41 2 Answers Views: 90 PADMAKEECHU

 1. Stack is used for static memory allocation while Heap is used for dynamic memory allocation.

2. Variables allocated on the stack are stored directly to the memory and access to this memory is very fast, and it's allocation is dealt with when the program is compiled whereas variables allocated on the heap have their memory allocated at run time and accessing this memory is a bit slower, but the heap size is only limited by the size of virtual memory.

Prev Next
Answers (2)
PARTH Dec 15, 2020 07:59
Answer:   1. Stack is used for static memory allocation while Heap is used for dynamic memory allocation.
2. Variables allocated on the stack are stored directly to the memory and access to this memory is very fast, and it's allocation is dealt with when the program is compiled whereas variables allocated on the heap have their memory allocated at run time and accessing this memory is a bit slower, but the heap size is only limited by the size of virtual memory.

FRAUSKY Dec 15, 2020 08:13
Answer:   Stack is allocation in the memory where value types are stored. Heap is a memory allocation where the reference types are stored.

Post Your Answer
Guest User

Not sure what course is right for you?

Choose the right course for you.
Get the help of our experts and find a course that best suits your needs.


Let`s Connect