tailieunhanh - Lecture Programming languages (2/e): Chapter 11 - Tucker, Noonan

Chapter 11 - Memory management. This chapter discusses the implementation of dynamic arrays and other objects using conventional techniques for managing heap memory. Especially important in this context is the notion of heap overflow, along with strategies for dealing with heap overflow when it occurs at run time. We discuss three key algorithms for heap memory management, which are affectionately known as garbage collection algorithms. | Programming Languages 2nd edition Tucker and Noonan Chapter 11 Memory Management C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do it blows your whole leg off. B. Stroustrup Contents The Heap Implementation of Dynamic Arrays Garbage Collection The Heap The major areas of memory: Static area: fixed size, fixed content allocated at compile time Run-time stack: variable size, variable content center of control for function call and return Heap: fixed size, variable content dynamically allocated objects and data structures The Structure of Run-Time Memory Fig Allocating Heap Blocks The function new allocates a block of heap space to the program. ., new(5) returns the address of the next block of 5 words available in the heap: Stack and Heap Overflow Stack overflow occurs when the top of stack, a, would exceed its (fixed) limit, h. Heap overflow occurs when a call to new occurs and the heap does not have a large enough block available to satisfy the call. Implementation of Dynamic Arrays Consider the declaration int A[n]; Its meaning (Meaning Rule ) is: 1. Compute addr(A[0]) = new(n). 2. Push addr(A[0]) onto the stack. 3. Push n onto the stack. 4. Push int onto the stack. Step 1 creates a heap block for A. Steps 2-4 create the dope vector for A in the stack. Stack and Heap Allocation for int A[10]; Fig Array References Meaning Rule The meaning of an ArrayRef ar for an array declaration ad is: 1. Compute addr(ad[]) = addr(ad[0])+ 2. If addr(ad[0]) addr(ad[])

TỪ KHÓA LIÊN QUAN
crossorigin="anonymous">
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.