Stack and Heap Flashcards
Heap Memory is used by ____.
all the parts of the application
Stack memory is used by _____.
only one thread of exectution
Whenever an object is created, ____
its always stored in the Heap Space and the stack memory contains the reference to it.
Stack Memory only contains ___
local primitive values and reference variables to objects in Heap Space
Objects stored in the _______ are globally accessible
Heap
______ can’t be accessed by other threads
Stack Memory
Memory management in Stack is done in ______
LIFO
Heap memory management:
more complex due to global accessibility
Memory divided into young gen, old gen, etc.
_____ memory is short-lived
Stack
_____ memory lives from start until end of application exectution
Heap
When stack is full, java runtime throws:
java.lang.StackOverFlowError
When Heap is full, java runtime throws:
java.lang.OutOfMemoryError
_____ memory size is smaller compared to ____ memory
Stack, Heap
_____ memory speed is faster compared to ____ memory
Stack, Heap