MAT 21B Lecture Notes - Lecture 20: Null Pointer, Memory Leak, Static Variable
![](https://new-preview-html.oneclass.com/XgKv4J8wp0k5NlDY1G6ONrZDyz7LVMoP/bg1.png)
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
![MAT 21B Full Course Notes](https://new-docs-thumbs.oneclass.com/doc_thumbnails/list_view/2365737-class-notes-us-uc-davis-mat-21b-lecture13.jpg)
83
MAT 21B Full Course Notes
Verified Note
83 documents