Organized from the video content of Teacher Hou Jie’s C++ memory management mechanism – from flat ground to tall building
C++ Memory Management – From Grands to Aoons PDF (from the web, thank you very much)
The test environment
- Ubuntu – 18.4.3
- Qt 5.13.1
- Dev 5.11
Free video from B station, self-searchable, C++ memory management mechanism – from flat ground to tall buildings
Is memory the “brain” of a computer? The CPU is the brain, the CPU is the three souls and six souls in the computer. But if there is no memory, everything only exists in the illusory, equivalent to non-existence.
Memory used to be one of the most precious and expensive peripheral resources, and modern programmers can’t imagine the DOS era when memory was more specific.
All have passed, but look at the present. We (seem to) have an endless supply of cheap memory. But beneath the surface, the operating system and the standard library do a lot of work. If you’re developing memory-hungry software or in a memory-constrained environment (such as an embedded system), it’s important to have a deep understanding of what the operating system and standard libraries do for you, or even to manage your own memory.
The course is divided into 6 lectures:
First lesson: Primitives
Constructs all the memory related underlying components in the C++ language, These include malloc/free, new/delete, operator new/operator delete, placement new/placement delete, and I’ll discuss what they mean, how they are used, and how they are overloaded. And develop a small memory pool.
Overview of each level of memory allocation: Expressions: New/Delete Expressions: New/Delete Expressions: New/Delete Expressions: New/Delete Expressions: New/Delete Expressions: New/Delete Expressions: New/Delete Expressions Per-class allocator Common static allocator(3rd Edition) is a Common static allocator for Macro Allocator (4th Edition) Allocator (5th Edition) Miscellaneous Discussion [The above chapters have been partially consolidated on the blog]
Lecture 2: STD ::allocator
The rise of standard libraries means that we can get rid of the repetitive trivialities of memory management and go straight to containers. But the allocator behind the container is responsible for the speed efficiency and space efficiency of the container. I’ll compare the allocator in the Visual C++, Borland C++, and Gun C++ libraries, and delve into the most elaborate design of the GNU C++ allocator.
BC5 allocator GNU allocator is an important part of the GNU allocator system. It is an important part of the GNU allocator system Porting GNU allocator to C [The above chapters are partially merged in this blog]
Lecture 3: malloc/free
Malloc /free is the last of all memory management methods; It’s the way you hook up with the operating system. You can also call the System API directly, but this is not recommended. It is therefore important to understand the internal management of malloc/free. Based on the malloc/free source code of Visual C++ CRT (C Runtime Library), I will explore the most basic and critical memory allocation function in depth.
VC6 and VC10 Malloc Comparison Small Block Heap(SBH) Initialization SBH Behavior Analysis -- Calculation of Block Size SBH Behavior Analysis -- Data Structure SBH Behavior Analysis -- Detailed Diagram of Allocation SBH Behavior Analysis -- Allocation + A review of the SBH for the release of sequential motion diagrams [the above chapters have been partially merged in the blog]
Lecture 4: Loki :: Allocator
Even well-known names such as the GNU C++ Pool allocator have their own glitches. Loki’s allocator is a compact, feature-free device worth exploring.
Loki::allocator behavior diagram class Chunk analysis class FixedAllocator analysis Loki::allocator review
Lecture 5: Other Topics
In addition to STD :: allocators, GNU C++ also brings allocators that are not part of the standard library and are considered extensions to the standard library. I’ll explore these extended allocators, especially bitmap_allocator.
We talk about not only the application, but also the design principles and implementation techniques. After understanding so many of the underlying layers (Windows Heap, CRT malloc/free, C++ new/delete, C++ allocator), you may finally realize that you don’t need to manage your own memory. Or maybe you finally have the ability to imagine where and how you need to strengthen memory management.
You will be provided with a complete set of lecture notes for the entire VIDEO course (that is, a written copy of each slide presented in VIDEO) and a complete program including code files.cpp and executable files.exe. You can stop at any time during the video — it takes a lot of time and brain power, but it gives you a lot of imagination.
VS2013 standard allocator with new_allocator G4.9 standard allocator with new_allocator G4.9 malloc_allocator G4.9 array_allocator G4.9 __pool_alloc G4.9 Bitmap_allocator G4.9 using the G4.9 allocator