Thread Memory Allocation Policy for Faster Heap Management
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Existing memory management methods suffer from low memory allocation speed and inefficient memory recollection due to frequent requests to the operating system or memory management system, leading to increased CPU usage and reduced efficiency.
Innovation Solution
A memory management method that determines a memory allocation policy for each target object based on its reference to another object, allowing for memory allocation in a target allocation buffer or heap memory, reducing the need for multiple requests and optimizing the allocation process.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Productivity
If memory is allocated by requesting from the operating system or memory management system for each object, then memory allocation can be performed, but the allocation speed is slow and CPU usage increases
Solution Approach 1:
The system pre-allocates a pool of memory blocks from the operating system in advance, storing them in a memory pool data structure. When memory allocation is needed, blocks are taken from this pre-allocated pool without requiring additional requests to the operating system, thereby improving allocation speed and reducing CPU overhead.
Solution Approach 2:
A memory pool acts as an intermediary layer between the operating system and the application's memory allocation requests. The memory pool manages a collection of pre-allocated memory blocks, providing fast allocation to applications while the operating system is contacted only when the pool needs to be replenished.
2Quantity of substance
If memory is allocated frequently from the operating system, then memory can be provided to objects, but the number of requests increases and efficiency decreases
Solution Approach 1:
The system pre-allocates a pool of memory blocks from the operating system in advance, storing them in a memory pool data structure. When memory allocation is needed, blocks are taken from this pre-allocated pool without requiring additional requests to the operating system, thereby improving allocation speed and reducing CPU overhead.
Solution Approach 2:
Multiple individual memory allocation requests are merged into a single bulk allocation request to the operating system. The memory pool consolidates many small allocation needs into one large allocation, reducing the total number of system calls and improving overall memory management efficiency.
3Ease of operation
If memory allocation requests are made frequently, then objects can be allocated memory, but CPU usage of memory management code increases
Solution Approach 1:
The system pre-allocates a pool of memory blocks from the operating system in advance, storing them in a memory pool data structure. When memory allocation is needed, blocks are taken from this pre-allocated pool without requiring additional requests to the operating system, thereby improving allocation speed and reducing CPU overhead.
Solution Approach 2:
The memory pool manages its own internal allocation and deallocation operations without requiring intervention from the operating system or complex memory management code. Once the pool is initialized with memory blocks, it autonomously serves allocation requests from its internal buffer, reducing CPU usage of memory management code.
Data Source
AI summary
A memory management method, comprising: obtaining a target object to which memory is to be allocated in a target thread; determining, based on reference of the target object to another object, a memory allocation policy corresponding to the target object, the memory allocation policy comprising a first policy and a second policy, the first policy indicating to allocate, in an allocation buffer of heap memory, memory of a corresponding size to the target object, and the second policy indicating to allocate, in the heap memory, memory of a corresponding size to the target object; and allocating, based on the memory allocation policy corresponding to the target object, memory to the target object in a target allocation buffer corresponding to the target thread or in the heap memory, the target allocation buffer being configured to allocate memory to a plurality of objects in the target thread corresponding to the first policy.


