c++内存算法
Chapter 1 Memory Management Mechanisms11.1 Overview11.2 Mechanism Versus Policy11.3 Memory Hierarchy31.4 Address Lines and Buses61.5 Intel Pentium Architecture81.5.1 Real Mode Operation111.5.2 Protected Mode Operation151.5.2.1 Protected Mode Paging211.5.2.2 Paging as Protection251.5.2.3 Addresses: Logical, Linear, and Physical261.5.2.4 Page Frames and Pages271.6 Closing Thoughts331.7 References34Chapter 2: Memory Management Policies352.1 Overview352.2 Case Study: MS-DOS352.2.1 DOS Segmentation and Paging362.2.2 DOS Memory Map362.2.3 Memory Usage382.2.4 Example: A Simple Video Driver392.2.5 Example: Usurping DOS412.2.6 Jumping the 640KB Hurdle452.3 Case Study: MMURTL482.3.1 Background and Design Goals482.3.2 MMURTL and Segmentation492.3.3 Paging Variations512.3.4 MMURTL and Paging512.3.5 Memory Allocation532.4 Case Study: Linux552.4.1 History and MINIX552.4.2 Design Goals and Features552.4.3 Linux and Segmentation562.4.4 Linux and Paging582.4.5 Page Fault Handling622.4.6 Memory Allocation622.4.7 Memory Usage662.4.8 Example: Siege Warfare672.4.9 Example: Siege Warfare, More Treachery712.5 Case Study: Windows762.5.1 Historical Forces762.5.2 Memory Map Overview792.5.3 Windows and Segmentation812.5.3.1 Special Weapons and Tactics822.5.3.2 Crashing Windows with a Keystroke832.5.3.3 Reverse Engineering the GDT842.5.4 Windows and Paging862.5.4.1 Linear Address Space Taxonomy862.5.4.2 Musical Chairs for Pages882.5.4.3 Memory Protection892.5.4.4 Demand Paging902.5.5 Memory Allocation912.5.6 Memory Usage942.5.7 Turning Off Paging972.5.8 Example: Things That Go Thunk in the Night982.6 Closing Thoughts1012.7 References1022.7.1 Books and Articles1022.7.2 Web Sites103Chapter 3: High-Level Services1053.1 View from 10,000 Feet1053.2 Compiler-Based Allocation1063.2.1 Data Section1093.2.2 Code Section1123.2.3 Stack1133.2.3.1 Activation Records1153.2.3.2 Scope1213.2.3.3 Static or Dynamic?1273.3 Heap Allocation1273.3.1 System Call Interface1283.3.2 The Heap1313.3.2.1 Manual Memory Management1323.3.2.2 Example: C Standard Library Calls1333.3.2.3 Automatic Memory Management1353.3.2.4 Example: The BDW Conservative Garbage Collector1363.3.2.5 Manual Versus Automatic?1383.4 The Evolution of Languages1423.4.1 Language Features1633.4.2 Virtual Machine Architecture1653.4.3 Java Memory Management1663.5 Memory Management: The Three-layer Cake1723.6 References173Chapter 4: Manual Memory Management1754.0 Replacements for malloc() and free()1754.1 System Call Interface and Porting Issues1764.2 Keep It Simple.Stupid!1784.3 Measuring Performance1784.3.1 The Ultimate Measure: Time1794.3.2 ANSI and Native Time Routines1804.3.3 Testing Methodology1854.4 Indexing: The General Approach1894.5 malloc() Version 1: Bitmapped Allocation1904.5.1 Theory1904.5.2 Implementation1914.5.2.1 tree.cpp1924.5.2.2 bitmap.cpp1984.5.2.3 memmgr.cpp2024.5.2.4 mallocV1.cpp2064.5.2.5 perform.cpp2084.5.2.6 driver.cpp2084.5.2.7 Tests2094.5.3 Trade-Offs2154.6 malloc() Version 2: Sequential Fit2154.6.1 Theory2164.6.2 Implementation2184.6.2.1 memmgr.cpp2184.6.2.2 mallocV2.cpp2284.6.2.3 driver.cpp2294.6.3 Tests2304.6.4 Trade-Offs2324.7 malloc() Version 3: Segregated Lists2334.7.1 Theory2334.7.2 Implementation2344.7.2.2 memmgr.cpp2344.7.2.3 mallocV3.cpp2434.7.3 Tests2444.7.4 Trade-Offs2484.8 Performance Comparison248Chapter 5: Automatic Memory Management2505.1 Garbage Collection Taxonomy2505.2 malloc() Version 4: Reference Counting2515.2.1 Theory2515.2.2 Implementation2535.2.2.1 driver.cpp2535.2.2.2 mallocV4.cpp2555.2.2.3 perform.cpp2565.2.2.4 memmgr.cpp2585.2.3 Tests2695.2.4 Trade-Offs2725.3 malloc() Version 5: Mark-Sweep2745.3.1 Theory2745.3.2 Implementation2775.3.2.1 driver.cpp2775.3.2.2 mallocV5.cpp2795.3.2.3 perform.cpp2805.3.2.4 memmgr.cpp2825.3.3 Tests2975.4 Performance Comparison3035.5 Potential Additions3035.5.1 Object Format Assumptions3045.5.2 Variable Heap Size3055.5.3 Indirect Addressing3065.5.4 Real-Time Behavior3075.5.5 Life Span Characteristics3085.5.6 Multithreaded Support309Chapter 6: Miscellaneous Topics3116.1 Suballocators3116.2 Monolithic Versus Microkernel Architectures3156.3 Closing Thoughts318Index321Organization334Chapter 1 - Memory Management Mechanisms334Chapter 2 - Memory Management Policies334Chapter 3 - High-Level Services334Chapter 4 - Manual Memory Management335Chapter 5 - Automatic Memory Management335Chapter 6 - Miscellaneous Topics335330Chapter 1Memory Management Mechanisms1.1Overview"Everyone has a photographic memory. Some people just don't have film." -Mel BrooksNote: In the text of this book, italics are used to define or emphasize a term. The Courier font is used to denote code, memory addresses, input/output, and f