Upload
amanda-phillips
View
213
Download
1
Embed Size (px)
Citation preview
1
Programming Languages Storage Management
Cao Hoaøng Truï
Khoa Coâng Ngheä Thoâng TinÑaïi Hoïc Baùch Khoa TP. HCM
2
Storage Management
• Major run-time elements requiring storage
• Major operations requiring storage to be allocated/freed
• Storage management phases
• Storage management techniques
3
Run-time elements
• Code segments
• System run-time programs library routines storage management routines
• User-defined data structures
• Subprogram return points
4
Run-time elements
• Referencing environments
• Temporaries in expression evaluation
• Temporaries in parameter transmission
• Input-output buffers
• Miscellaneous system data
5
Run-time operations
• Subprogram call and return operations
• Data structure creation and destruction operations
• Component insertion and deletion operations
6
Storage Management Phases
1. Initial allocation: allocating free storage
2. Recovery: recovering unused storage garbage collection
3. Compaction and reuse: compaction: to construct large blocks reuse: as initial allocation
7
Storage Management Techniques
1. Static storage management
2. Stack-based storage management
3. Heap storage management fixed-size elements variable-size elements
8
Static Storage Management
Static allocation: allocation that remains fixed through out execution.
9
Stack-based Storage Management
• First Allocated - Last Freed.
• Simple storage recovery, compaction and reuse.
• Not applicable if storage needs to be allocated/freed at arbitrary points.
10
Heap Storage Management
Heap: a block of storage within which data are allocated/freed in an arbitrary manner.
11
heap
head
initial free-space list
heap
head
12
heap (storage allocated by NEW)
typical Pascal memory organization
subprogram code segmentsand system run-time routines (statically allocated) stack
bottomactivation records
free space
heap bottom