MAT 21B Lecture Notes - Lecture 20: Null Pointer, Memory Leak, Static Variable
Lecture 20
Static memory allocation
Life time issue (see below for example correlation)
- 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
See powerpoint →
find more resources at oneclass.com
find more resources at oneclass.com
beigecamel74 and 41 others unlocked
83
MAT 21B Full Course Notes
Verified Note
83 documents