This is a created article in which the information may have evolved or changed.
11. Toad Notes Go language--memory splitter
Memory allocator, also known as Memoryallocator.
Core: Autonomous management, Cache reuse, no lock allocation.
Memory management takes the page as the basic unit, and multiple address contiguous pages form a block of memory.
Pages are page, and continuous pages are span.
Press 8 times times to divide small objects into various size specifications. Size class.
Three-tier management organization
The three-tier management bodies are shown in Figure 1:
The algorithm relies on successive addresses to reserve a larger address space. Figure 2below:
Saves the span pointer by page.
Checks to see if the object belongs to span.
Checks whether adjacent spans can be merged.
Quickly allocate and expand as needed.
Figure 3below:
Garbage collection
The garbage collector raises the recycle operation. Figure 4below:
Allocate memory for Management objects without occupying reserved addresses
Figure 5: