|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ä |
Three
ways memory is allocated
|
|
|
|
ä |
Static
|
|
|
|
ä |
Allocated
as soon as execution begins
|
|
|
|
ä |
Lasts
until termination
|
|
|
|
ä |
Usually
reside in fixed data segments
|
|
|
|
ä |
Note:
a variable can be static yet have a local scope
|
|
|
|
ä |
Local
|
|
|
|
ä |
Created
on the stack or in a register when an
|
|
|
enclosing
block or function is entered
|
|
|
|
ä |
Disappear
when the block or function is exited
|
|
|
|
ä |
Dynamic
|
|
|
|
ä |
Created
and destroyed by specific function calls
|
|
|
during
a program
|
|
|
|
ä |
Can
be called by application source or the runtime
|
|
|
|
ä |
Operations:
malloc or new, and free or delete
|
|
|
ä |
How
does dynamic memory allocation work?
|
|
|
ä |
Use a
datatype we call a heap
|
|