Storage Allocation Strat
The compilers code generation and optimization phases must work in correct orer with the runtime env to ...
Static Storage Allocation
- Used when size and type of stuff is known at compile time
- its fast and simple as mem locations are already decided
- not very flexible
Dynamic Storage Allocation
Stack Based Storage Allocation
- when a function is called a new block of mem called stack frame is pushed onto a stack to hold the functions local vars and other info
- Efficient memory management for function calls and mem is auto allocated and deallocated which prevent mem leaks
- can only access the memory the order it was allocated (LIFO),
Heap Based Storage Allocation
- Heap is a region of the memory that's available for dynamic memory allocation during program execution
- need to know the size of objects in runtime
- very flexible and u can allocated mem whnever u want and need it
- management of heap becomes complex and goes out of hand as it may cause mem leaks