Download presentation
Presentation is loading. Please wait.
1
PZ10A Programming Language design and Implementation -4th Edition Copyright©Prentice Hall, 2000 1 PZ10A - Heap storage Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section 10.1-10.3, 10.4.2
2
PZ10A Programming Language design and Implementation -4th Edition Copyright©Prentice Hall, 2000 2 Heap storage Dynamic allocation and stacks are generally incompatible.
3
PZ10A Programming Language design and Implementation -4th Edition Copyright©Prentice Hall, 2000 3 Stack and heap location Pointer X points to stack storage in procedure Q's activation record that no longer is live (exists) when procedure Q terminates. Such a reference is called a dangling reference. Dynamic storage is usually a separate structure in C, Ada, Pascal...
4
PZ10A Programming Language design and Implementation -4th Edition Copyright©Prentice Hall, 2000 4 Heap storage problems Major storage for ML, LISP and Prolog is a heap. Get storage - allocate(x) free storage - free(x) Problems: Dangling reference: allocate(x);y = x; free(x); y still points to allocated Inaccessible storage: allocate(x); first allocation to x now lost. Memory fragmentation …(next slide)
5
PZ10A Programming Language design and Implementation -4th Edition Copyright©Prentice Hall, 2000 5 Memory fragmentation Memory fragmentation: allocate(a); allocate(x); allocate(y); free(a); allocate(z); free(y); allocate(b); No contiguous space for b
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.