summaryrefslogtreecommitdiff
path: root/documentation
diff options
context:
space:
mode:
authorwdfk-prog <[email protected]>2024-04-18 21:58:09 +0800
committerRbb666 <[email protected]>2024-04-19 15:36:02 +0800
commit4909b8788178e8432f0e00f6bec7571aa318b2aa (patch)
tree088375e693aa728cf713fba91e724e2b4827859e /documentation
parenta4a49492779f944dc29bc5f6e80f7bc7be389671 (diff)
[mem] Remove useless code And Update mem documentation
Diffstat (limited to 'documentation')
-rw-r--r--documentation/memory/figures/08smem_work4.pngbin0 -> 52729 bytes
-rw-r--r--documentation/memory/memory.md24
2 files changed, 23 insertions, 1 deletions
diff --git a/documentation/memory/figures/08smem_work4.png b/documentation/memory/figures/08smem_work4.png
new file mode 100644
index 0000000000..92544169d0
--- /dev/null
+++ b/documentation/memory/figures/08smem_work4.png
Binary files differ
diff --git a/documentation/memory/memory.md b/documentation/memory/memory.md
index 892107fd75..2ac9fe30ef 100644
--- a/documentation/memory/memory.md
+++ b/documentation/memory/memory.md
@@ -43,7 +43,13 @@ Any or none of these memory heap management algorithms can be chosen when the sy
### Small Memory Management Algorithm
-The small memory management algorithm is a simple memory allocation algorithm. Initially, it is a large piece of memory. When a memory block needs to be allocated, the matching memory block is segmented from the large memory block, and then this matching free memory block is returned to the heap management system. Each memory block contains data head for management use through which the used block and the free block are linked by a doubly linked list, as shown in the following figure:
+The small memory management algorithm is a simple memory allocation algorithm. Initially, it is a large piece of memory. When a memory block needs to be allocated, the matching memory block is segmented from the large memory block, and then this matching free memory block is returned to the heap management system. Each memory block contains data head for management use through which the used block and the free block are linked by a doubly linked list.
+
+
+
+**Use this implementation before 4.1.0**
+
+As shown in the following figure:
![Small Memory Management Working Mechanism Diagram](figures/08smem_work.png)
@@ -55,6 +61,22 @@ Each memory block (whether it is an allocated memory block or a free memory bloc
The performance of memory management is mainly reflected in the allocation and release of memory. The small memory management algorithm can be embodied by the following examples.
+
+
+**4.1.0 and later use this implementation**
+
+As shown in the following figure:
+
+![](figures/08smem_work4.png)
+
+**Heap Start**: The heap head address stores memory usage information, the heap head address pointer, the heap end address pointer, the minimum heap free address pointer, and the memory size.
+
+Each memory block (whether it is an allocated memory block or a free memory block) contains a data head, including:
+
+**pool_ptr**: Small memory object address. If the last bit of the memory block is 1, it is used. If the last bit of the memory block is 0, it is not used. When used, the structure members of the small memory algorithm can be quickly obtained by calc.
+
+
+
As shown in the following figure, the free list pointer lfree initially points to a 32-byte block of memory. When the user thread wants to allocate a 64-byte memory block, since the memory block pointed to by this lfree pointer is only 32 bytes and does not meet the requirements, the memory manager will continue to search for the next memory block. When the next memory block with 128 bytes is found, it meets the requirements of the allocation. Because this memory block is large, the allocator will split the memory block, and the remaining memory block (52 bytes) will remain in the lfree linked list, as shown in the following table which is after 64 bytes is allocated.
![Small Memory Management Algorithm Linked List Structure Diagram 1](figures/08smem_work2.png)