ECS 30 Lecture Notes - Lecture 20: Static Variable, Memory Management, Null Pointer
Lecture 20
Static memory allocation
Life time issue
- Function cannot return a local variable
- When using local variable, all resources have to already exit before calling subfunction
- Global variable exist during the entire programs’ execution even when unused
Code lines examples:
Sizing issue
What if we need more ..
Requirement
- Lifetime independent from function
o Not in the stack
- Lifetime not necessarily for the entire
programs execution
o Not in data segment
Dynamic memory allocation
find more resources at oneclass.com
find more resources at oneclass.com