Method, device and equipment for optimizing memory management mechanism and storage medium

By constructing a dynamic programming state space and spatiotemporal prediction model, and combining it with a PID controller to optimize memory management, the problems of memory fragmentation and insufficient load adaptability are solved, memory allocation efficiency and response accuracy are improved, and lock contention overhead is reduced.

CN122332301APending Publication Date: 2026-07-03SHENZHEN GUOSHUOHONG ELECTRONICS CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
SHENZHEN GUOSHUOHONG ELECTRONICS CO LTD
Filing Date
2026-04-03
Publication Date
2026-07-03

AI Technical Summary

Technical Problem

In existing technologies, memory management mechanisms suffer from problems such as decreased allocation efficiency, insufficient prediction accuracy, and long-term performance degradation due to the accumulation of memory fragmentation, insufficient dynamic load adaptability, and lack of physical-virtual address space correlation modeling.

Method used

By constructing a dynamic programming state space, combining a spatiotemporal prediction model and a PID controller, the thread-local cache capacity threshold is dynamically adjusted, the fragmentation sensitivity level is fed back in real time, and memory blocks are pre-allocated to optimize memory management.

Benefits of technology

It significantly improves the long-term rationality and short-term response accuracy of memory allocation decisions, reduces lock contention overhead in high-concurrency scenarios, avoids latency and merging operations caused by fragmentation, and achieves a balance between memory utilization and allocation efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122332301A_ABST
    Figure CN122332301A_ABST
Patent Text Reader

Abstract

This invention relates to the field of memory management in computer systems, and discloses an optimization method, apparatus, device, and storage medium for memory management mechanisms. The method generates memory allocation strategies through dynamic programming, predicts demand using a spatiotemporal model, dynamically adjusts the local cache using PID control, provides real-time feedback on fragmentation sensitivity, and pre-allocates contiguous memory, achieving coordinated management of global optimization and real-time response. The apparatus includes a strategy pre-calculation module, a spatiotemporal prediction module, a closed-loop control module, a pre-allocation execution module, and a status feedback module. The device includes a memory, a processor, and a computer program stored in the memory and executable on the processor. The storage medium stores the computer program. This invention improves memory allocation efficiency, reduces high-concurrency latency, and suppresses fragmentation accumulation through coordinated optimization of dynamic programming and spatiotemporal prediction, combined with fragmentation-sensitive PID closed-loop control, multi-cycle pre-allocation, and physical-virtual address joint modeling.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of memory management in computer systems, and in particular to methods, apparatus, devices, and storage media for optimizing memory management mechanisms. Background Technology

[0002] In computer systems, especially in high-concurrency business scenarios, the performance of memory management mechanisms directly affects system throughput and response latency. Traditional memory management methods often employ static allocation strategies or local optimization algorithms based on immediate requests, which struggle to cope with dynamic load fluctuations and memory fragmentation issues arising from long-term operation. As business scales up, physical memory fragmentation leads to an increased failure rate in contiguous memory allocation, forcing the system to frequently perform memory merging or paging operations, significantly increasing lock contention overhead and unpredictable latency jitter.

[0003] In existing technologies, predictive models based on historical statistics often overlook the correlation between physical address space and virtual address access patterns, leading to discrepancies between pre-allocation strategies and actual business needs. Furthermore, fragmentation control mechanisms largely rely on post-event merging strategies, lacking quantitative assessment and proactive mitigation of fragmentation risks, resulting in continuous performance degradation after prolonged operation. Additionally, fixed settings for thread-local cache thresholds are difficult to adapt to varying load conditions, easily causing insufficient resource reservation or excessive resource consumption, further exacerbating the conflict between memory utilization and allocation efficiency.

[0004] Therefore, this invention proposes an optimized method, apparatus, device, and storage medium for memory management mechanisms to address the shortcomings of existing technologies. Summary of the Invention

[0005] The purpose of this invention is to provide an optimized method, apparatus, device, and storage medium for memory management mechanisms, which solves the problems of decreased allocation efficiency, insufficient prediction accuracy, and long-term performance degradation caused by memory fragmentation accumulation, insufficient dynamic load adaptability, and lack of physical-virtual address space correlation modeling.

[0006] To achieve the above objectives, the present invention provides the following technical solution: an optimization method for memory management mechanisms, the method comprising the following steps:

[0007] S1. Construct a dynamic programming state space based on memory block distribution, fragmentation sensitivity, and system load level, and pre-generate a dynamic programming strategy table by solving a multi-stage decision problem;

[0008] S2. Based on the state transition probabilities in the dynamic programming strategy table, memory demand is jointly predicted through a spatiotemporal prediction model. The spatiotemporal prediction model integrates time series analysis and physical-virtual address space topology to output the memory demand trend and hotspot area distribution in the future time window.

[0009] S3. Based on the memory demand trend and hot spot distribution output by the spatiotemporal prediction model, dynamically adjust the local cache capacity threshold of each thread through the PID controller, and feed back the adjusted threshold parameters to the dynamic programming state space in real time.

[0010] S4. When a memory release operation is detected, the fragmentation sensitivity level of the released region is calculated based on the physical address continuity and virtual address access frequency of the current memory block, and the fragmentation sensitivity level is synchronously updated to the dynamic programming strategy table and the feedback loop of the PID controller.

[0011] S5. Based on the hotspot region distribution and fragmentation sensitivity level output by the spatiotemporal prediction model, execute a pre-allocation strategy before the predicted high-concurrency time window, and allocate contiguous memory blocks from the global memory pool to the pre-allocation buffer in advance.

[0012] Preferably, step S1 includes:

[0013] When constructing the state space for dynamic programming, the system state is defined as a triple. ,in, A binary bitmap representing the distribution of free memory blocks, where each bit corresponds to the occupancy status of a physical memory page; This represents the fragmentation sensitivity level, obtained by quantifying the degree of fragmentation in memory regions. The system load level is discretized based on CPU utilization and memory request frequency according to a preset threshold.

[0014] When generating the dynamic programming strategy table, the optimal strategy for solving the multi-stage decision problem is determined based on the Bellman equation:

[0015] ;

[0016] in, A set of actions; Indicates the execution of an action The resulting expected increase in fragmentation; Indicates action The time cost of lock contention involved; The state transition probability; The weighting coefficients for fragmentation cost and lock contention cost.

[0017] Preferably, in step S2:

[0018] The spatiotemporal prediction model generates fused features of physical and virtual addresses through a dual-channel attention encoder, where the physical address... and virtual address Each vector is mapped to an embedding function. and The attention feature vector is calculated using the following formula. :

[0019] ;

[0020] in, , The weight parameters for the physical address lookup matrix; , These are the weight parameters of the virtual address key matrix; , These are the weight parameters of the mixture matrix; The dimension of the feature vector;

[0021] The fused feature vector Used to construct a memory block association graph, which serves as input for spatial topology analysis.

[0022] Preferably, in step S2:

[0023] The time series analysis module uses an autoregressive integral moving average model, and its prediction equation is:

[0024] ;

[0025] in: For time window Predicted memory requirements; and These are the coefficients of the autoregressive term and the moving average term, respectively; This is the white noise error term;

[0026] The spatial topology sensing module employs a graph convolutional network, and its node feature update formula is as follows:

[0027] ;

[0028] in, It is an adjacency matrix with self-connections. Indicates the physical proximity between memory blocks. The identity matrix is ​​used to introduce self-loop connections; for The degree matrix; For the first The node feature matrix of the layer; For the first The trainable weight matrix of the layer;

[0029] The time series prediction results Spatial topological features The inputs are fed into the demand fusion layer to generate joint prediction results.

[0030] Preferably, in step S3:

[0031] The proportional gain of the PID controller Integral gain and differential gain Based on fragment sensitivity level and system load level Dynamic adjustment, the adjustment formula is:

[0032] ;

[0033] in, , , These are the initial gain parameters; To match the load level Positively correlated scaling factor; This is a preset exponential constant;

[0034] The adjusted gain parameter is used to calculate the local cache capacity threshold. The updated threshold parameters are then written into the load level field of the dynamic programming state space in real time.

[0035] Preferably, in step S4:

[0036] The fragment sensitivity level For memory regions The calculation is performed using the following formula:

[0037] ;

[0038] in, Indicates the area The amount of external debris; Indicates the area Total physical memory capacity; Indicates the area The amount of internal fragmentation; Indicates the area Total allocated memory capacity; These are weighting coefficients that are dynamically adjusted based on the business type.

[0039] Calculated Simultaneously, the state update module of the dynamic programming strategy table and the feedback input interface of the PID controller are input.

[0040] Preferably, in step S5:

[0041] The triggering timing of the pre-allocation strategy is determined through a multi-cycle synchronization protocol, satisfying the pre-allocation time window. High-concurrency cycle of spatiotemporal prediction model output Satisfy integer multiple relationship:

[0042] ;

[0043] in, The multiplier is dynamically adjusted based on historical load fluctuations; pre-allocated amount. The calculation formula is:

[0044] ;

[0045] in, The memory requirement forecast value output by the time series forecasting module; This represents the hotspot region feature matrix output by the spatial topology prediction module. Take the first percentile; Based on fragment sensitivity level Dynamically adjusted preset values;

[0046] After pre-allocation is completed, update the free block distribution status in the dynamic programming strategy table. And the occupancy marker for the pre-allocated buffer.

[0047] The present invention also provides an optimization device for memory management mechanisms, the device comprising:

[0048] The strategy pre-computation module is used to construct a dynamic programming state space based on memory block distribution status, fragmentation sensitivity level and system load level, and generate a pre-computation strategy table by solving Bellman equations.

[0049] The spatiotemporal prediction module is used to perform joint feature encoding on physical and virtual addresses through a dual-channel attention encoder, and generate memory demand trends and hotspot region distribution predictions based on a time series analysis model and a graph convolutional network.

[0050] A closed-loop control module is used to dynamically adjust the thread local cache capacity threshold according to the output of the spatiotemporal prediction module. The adjustment is achieved through a PID controller, and the adjustment parameters are linked with the fragmentation sensitivity level in real time.

[0051] The pre-allocation execution module is used to trigger the pre-allocation operation of consecutive memory blocks before the predicted high-concurrency time window, and to determine the pre-allocation triggering timing according to the multi-cycle synchronization protocol.

[0052] The status feedback module is used to calculate the fragmentation sensitivity level of the current region when memory is released, and to synchronously update the calculation results to the policy pre-calculation module and the closed-loop control module.

[0053] The present invention also provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor.

[0054] The present invention also provides a storage medium having a computer program stored thereon.

[0055] In summary, the present invention has at least one of the following beneficial technical effects:

[0056] 1. This invention overcomes the limitations of local decision-making in traditional memory management methods by jointly optimizing dynamic programming strategy pre-computation and spatiotemporal prediction models. The dynamic programming state space integrates multi-dimensional parameters such as fragmentation sensitivity and load level to generate a globally optimal strategy, while the spatiotemporal prediction model captures the correlation between physical and virtual address spaces and the evolutionary patterns of time sequences, achieving dual prediction of demand trends and hotspot areas. This significantly improves the long-term rationality of allocation decisions and the accuracy of short-term response.

[0057] 2. This invention constructs a closed-loop link based on a PID controller, integrating fragmentation sensitivity levels into the control loop in real time. By dynamically adjusting the proportional, integral, and derivative gain parameters, the thread-local cache capacity threshold adapts to the degree of fragmentation and system load fluctuations, effectively balancing memory utilization and allocation efficiency, and reducing lock contention overhead in high-concurrency scenarios.

[0058] 3. This invention utilizes a pre-allocation execution module to precisely trigger memory reservation operations based on spatiotemporal prediction results and a multi-cycle synchronization protocol, completing the pre-allocation of contiguous memory blocks before the high-concurrency window. By combining physical address continuity detection and virtual address access pattern analysis, it ensures a high degree of matching between the pre-allocation buffer and hotspot areas, avoiding search and merging operations caused by fragmentation during real-time allocation, and significantly reducing critical path latency.

[0059] 4. The status feedback module of this invention calculates the fragmentation sensitivity level in real time during memory release, and synchronously updates the dynamic programming state space of the strategy pre-calculation module and the feedback parameters of the closed-loop control module. This mechanism achieves immediate assessment of fragmentation risk and cross-module collaborative suppression by quantifying the impact of the release operation on the physical layout and virtual access mode, preventing the accumulation of fragmentation effects during long-term operation.

[0060] 5. This invention employs a dual-channel attention encoder in its spatiotemporal prediction module to capture the spatial proximity of physical addresses and the access correlation of virtual addresses. It also combines this with graph convolutional networks to model memory block topology, overcoming the dependence of traditional prediction models on a single address space. This design enables hotspot region prediction to simultaneously reflect physical memory continuity and business access patterns, providing high-confidence spatial feature input for pre-allocation strategies. Attached Figure Description

[0061] Figure 1This is a schematic diagram of the method flow of the present invention;

[0062] Figure 2 This is a schematic diagram of the device structure of the present invention;

[0063] Figure 3 This is a schematic diagram of the computer device structure of the present invention;

[0064] Among them, 10 is the strategy pre-calculation module; 20 is the spatiotemporal prediction module; 30 is the closed-loop control module; 40 is the pre-allocation execution module; 50 is the status feedback module; 60 is the computer equipment; 61 is the processor; 62 is the memory; and 63 is the storage medium. Detailed Implementation

[0065] The following is in conjunction with the appendix Figure 1 -Appendix Figure 3 The present invention will be further described in detail below.

[0066] This invention provides an optimization method for memory management mechanisms, the method comprising the following steps:

[0067] S1. Construct a dynamic programming state space based on memory block distribution, fragmentation sensitivity, and system load level, and pre-generate a dynamic programming strategy table by solving a multi-stage decision problem;

[0068] In this embodiment, the optimization method of the memory management mechanism achieves globally optimal decision-making for memory allocation behavior by constructing a dynamic programming state space and pre-generating a policy table. The technical implementation is described in detail below:

[0069] The system state consists of three core dimensions, defined as triples. It is used to comprehensively describe the distribution of memory resources, the degree of fragmentation, and the system's operating load.

[0070] Free memory block distribution ( The bitmap records the occupancy status of physical memory pages in binary bitmap form. Each bit corresponds to a physical page; a bit value of "1" indicates that the page is free, while a bit value of "0" indicates that it has been allocated. The bitmap update rule is: allocation operations set the corresponding page bit to "0", and release operations set it to "1". By maintaining the bitmap status in real time, the distribution characteristics of consecutive free blocks in physical memory are accurately reflected.

[0071] Fragment Sensitivity Level ( The fragmentation rate is calculated by quantifying the internal and external fragmentation ratio of memory regions. This parameter is used to assess the fragmentation risk of the current memory layout, and its value ranges from 0, 10, to 1. The larger the value, the more severe the fragmentation problem.

[0072] System load level ( The load is generated by discretizing a comprehensive indicator of CPU utilization and memory request frequency. Specifically, the load is divided into multiple levels (such as low, medium, and high) by preset thresholds to characterize the intensity of real-time resource contention in the system. The discretization rules can be adjusted according to the actual scenario. For example, when the CPU utilization exceeds 70% and the memory request frequency exceeds 1000 times per second, it is judged as a high load level.

[0073] The policy table is generated by solving the Bellman equation for the optimal policy, and its mathematical form is:

[0074] ;

[0075] in, This is a set of actions, including three types of operations: memory splitting (Split), merging (Merge), and allocating new memory regions (Alloc_New). For example, the Split action is used to divide a large block of free memory into multiple smaller blocks of a specified size, and the Merge action is used to merge adjacent free blocks to reduce fragmentation;

[0076] Indicates the execution of an action The resulting expected fragmentation increment is dynamically calculated based on the action type. For the Split operation, the cost is the dispersion of the free blocks generated after the split, calculated as the difference between the number of split blocks and the ideal number of contiguous blocks; for the Merge operation, the cost is the negative difference in fragmentation sensitivity before and after the merge. The operation applies a fixed penalty value to discourage frequent requests for new regions; Indicates action The time cost of lock contention is modeled based on historical statistics of lock waiting times. For example, if an action requires a global memory lock to occupy a global memory lock for more than a preset time threshold, the lock contention cost increases exponentially. The state transition probability is calculated from the future memory demand distribution and hotspot region prediction results provided by the spatiotemporal prediction model. Specifically, the demand trend output by the spatiotemporal prediction model is used to deduce the state transition probability in action. After execution, the system state is transitioned to... The probability distribution; This is a weighting coefficient for fragmentation cost and lock contention cost; for example, it reduces the weighting coefficient in low fragmentation sensitivity scenarios. Values ​​are prioritized to ensure allocation efficiency and improve performance under high load scenarios. This value is used to reduce lock contention latency.

[0077] During the system initialization phase, the optimal action set for all possible system states is pre-calculated by iteratively solving the Bellman equation and stored as a policy table. The policy table uses a hash map as its data structure, with the key being a state triplet. The encoded value corresponds to the optimal action and expected cost. During system runtime, the optimal allocation strategy for the current state is obtained in real time by querying the strategy table, avoiding the performance overhead of online calculation.

[0078] S2. Based on the state transition probabilities in the dynamic programming strategy table, memory demand is jointly predicted through a spatiotemporal prediction model. The spatiotemporal prediction model integrates time series analysis and physical-virtual address space topology to output the memory demand trend and hotspot area distribution in the future time window.

[0079] In this embodiment, the spatiotemporal prediction model achieves joint prediction of future memory demand trends and hotspot region distribution by fusing time series analysis and spatial topological relationships. The technical implementation is detailed below:

[0080] The association features between physical addresses (PA) and virtual addresses (VA) are generated using a dual-channel attention encoder. Specifically:

[0081] Address embedding representation: Physical addresses and virtual addresses are each mapped to a fixed-dimensional vector through an embedding function, denoted as . and The embedding function is implemented using a fully connected neural network, which maps address values ​​to a high-dimensional semantic space to capture non-linear relationships.

[0082] Attention feature calculation: Generate the fused feature vector using the following formula. :

[0083] ;

[0084] Among them, the query matrix : Consists of physical address embedding vector and weight parameters Obtained by linear transformation, i.e. This is used to characterize the query intent for the physical address;

[0085] Key matrix : Consists of virtual address embedding vector and weight parameters Obtained by linear transformation, i.e. This is used to characterize the key-value matching features of virtual addresses;

[0086] Value matrix : A concatenated vector of physical and virtual addresses, weighted by parameters Linear transformation generation, i.e. It is used to fuse dual-channel semantic information;

[0087] Dimension scaling factor : Used to alleviate the gradient vanishing problem caused by the dot product of high-dimensional vectors, where is the dimension of the feature vector.

[0088] The Autoregressive Integral Moving Average (ARIMA) model is used to predict future memory demand.

[0089] ;

[0090] in, For time window Predicted memory requirements; and These are the coefficients of the autoregressive term and the moving average term, respectively; This is the white noise error term;

[0091] Autoregressive term Utilize historical memory usage Linear combinations capture time dependencies;

[0092] Moving average term Based on historical prediction errors Revise the current forecast value;

[0093] White noise item : Indicates random fluctuations not explained by the model, which conform to a Gaussian distribution with zero mean and fixed variance;

[0094] Parameter training: coefficients The non-stationarity of time series is eliminated by combining maximum likelihood estimation with difference operations for training.

[0095] A memory block association graph is constructed based on a graph convolutional network (GCN), and the topological relationship between physical proximity and access patterns is analyzed:

[0096] Adjacency Matrix Construction: Define an adjacency matrix with self-connections ,in It indicates the physical proximity relationship between memory blocks (such as contiguous addresses or adjacent page tables). The identity matrix is ​​used to introduce self-loop connections;

[0097] Feature propagation and update: Node features are iteratively updated through multi-layer graph convolution operations, the th... Feature matrix of layer The calculation is as follows:

[0098] ;

[0099] in, for The degree matrix; For the first The node feature matrix of the layer; For the first The trainable weight matrix of the layer;

[0100] Degree matrix :right The diagonal matrix obtained by summing the rows is used to normalize the adjacency matrix;

[0101] weight matrix : No. The trainable parameters of the layer are used for feature transformation;

[0102] Activation function : Prefer the ReLU function to introduce nonlinearity;

[0103] Final output layer The node characteristics represent the distribution of hotspot areas.

[0104] Time series forecast values Spatial topological features Input demand fusion layer to generate joint prediction results:

[0105] Quantile extraction: Quantile extraction from the spatial topological feature matrix Calculate by column percentile This is used to quantify the upper limit of memory requirements for hot spots;

[0106] Fusion rule: Joint predicted value Take the maximum value between the predicted time series value and the spatial quantile, that is:

[0107] ;

[0108] in The value is dynamically adjusted based on fragmentation sensitivity. For example, when fragmentation sensitivity is high, a higher quantile is selected to reserve redundant memory.

[0109] S3. Based on the memory demand trend and hot spot distribution output by the spatiotemporal prediction model, dynamically adjust the local cache capacity threshold of each thread through the PID controller, and feed back the adjusted threshold parameters to the dynamic programming state space in real time.

[0110] In this embodiment, the dynamic parameter tuning mechanism of the PID controller is used to adaptively adjust the thread-local cache capacity threshold, and the adjustment result is fed back to the dynamic programming state space in real time, forming a closed-loop control. The technical implementation is described in detail below:

[0111] The proportional gain of the PID controller ( ), integral gain ( ) and differential gain ( Based on fragment sensitivity level ( ) and system load level ( Dynamic adjustment, the adjustment formula is:

[0112] ;

[0113] in, , , These are the initial gain parameters; To match the load level Positively correlated scaling factor; This is a preset exponential constant;

[0114] Initial gain parameters ( , , ): This is preset during the system initialization phase, and the basic adjustment capability is determined through calibration testing. For example, It reflects the initial response strength of the system to deviations in memory demand.

[0115] Load scaling factor ( ): with system load level ( Positive correlation. Preferably, the load level is converted into a scaling factor through a preset mapping rule, such as 0.8 for low load, 1.0 for medium load, and 1.2 for high load, in order to enhance the adjustment response speed in high load scenarios.

[0116] Exponential constant ( ): Used to control the amplification effect of fragment sensitivity on the differential term. The preferred value is 2, which significantly improves the differential gain in high fragment sensitivity scenarios and suppresses the risk of overshoot.

[0117] Calculate the thread-local cache capacity threshold based on the adjusted gain parameter. ):

[0118] ;

[0119] Among them, the error term Defined as the memory requirement prediction value output by the spatiotemporal prediction model ( ) and current memory capacity ( ) deviation, that is:

[0120] ;

[0121] The threshold calculation process is executed periodically to ensure real-time tracking and prediction of changes in demand.

[0122] Adjusted threshold parameters Feedback is provided to the dynamic programming state space in the following ways:

[0123] Load level field update: Compared with the current load level ( Association, write state triples The load level field in the code. For example, when... When the load level exceeds the preset limit, a load level upgrade is triggered.

[0124] Strategy table regeneration trigger: When the load level changes beyond a set threshold, the strategy pre-calculation module is driven to resolve the Bellman equation and update the dynamic programming strategy table.

[0125] S4. When a memory release operation is detected, the fragmentation sensitivity level of the released region is calculated based on the physical address continuity and virtual address access frequency of the current memory block, and the fragmentation sensitivity level is synchronously updated to the dynamic programming strategy table and the feedback loop of the PID controller.

[0126] In this embodiment, the fragmentation sensitivity level calculation and feedback mechanism provides real-time status input for dynamic programming strategies and closed-loop control by quantifying the fragmentation degree of the memory release area. The technical implementation is described in detail below:

[0127] When a memory release operation is detected, the target memory region is targeted. Based on its physical address continuity and virtual address access pattern, the fragmentation sensitivity level is calculated using the following formula. :

[0128] ;

[0129] in, Indicates the area The amount of external debris; Indicates the area Total physical memory capacity; Indicates the area The amount of internal fragmentation; Indicates the area Total allocated memory capacity; These are weighting coefficients that are dynamically adjusted based on the business type.

[0130] External debris quantity ( This represents the unavailable memory capacity due to non-contiguous free memory blocks. Specifically, it counts the number of free blocks in the current region that cannot satisfy contiguous memory requests and multiplies this number by the average capacity of a single request. For example, if there are 3 discrete free blocks in the region and the average request capacity is 4 pages, then... Page.

[0131] Total physical memory capacity ( ): Target area The total number of physical memory pages can be obtained directly through the system memory mapping table.

[0132] Internal fragmentation ( This represents the unused capacity within an allocated memory block. It calculates the sum of the differences between the requested capacity and the actually used capacity by traversing all allocated blocks within the region. For example, if an allocated block requests 10 pages but only uses 6 pages, its internal fragmentation contribution is 4 pages.

[0133] Total allocated memory capacity ( ): The total number of pages in all allocated blocks within the region, obtained through bitmap statistics or memory allocator metadata.

[0134] Weighting coefficients ( ): Dynamically adjusted based on business type to balance the impact weight of internal / external fragmentation. For example, real-time computing tasks emphasize external fragmentation control. Batch processing tasks focus on internal fragmentation optimization. ).

[0135] Physical address continuity detection: By scanning the bitmap state of the regions adjacent to the freed memory block, the number of consecutive free blocks before and after it is counted. If both sides of the freed block are occupied, it is determined that it exacerbates external fragmentation.

[0136] Virtual address access frequency statistics: Based on the virtual addresses associated with memory release operations, query the access frequency and time distribution in historical access records. After the high-frequency access area is released, its internal fragmentation has a greater impact on performance.

[0137] Calculated Update system status using the following methods:

[0138] Dynamic programming strategy table update: Write state triple The fragmentation sensitivity field triggers the policy pre-computation module to re-solve the Bellman equation and generate an allocation policy adapted to the latest fragmentation state.

[0139] PID controller feedback input: The feedback interface of the input PID controller drives the dynamic adjustment of the proportional, integral, and derivative gains (as described in step S3). Specifically, when... When the threshold is exceeded, the proportional gain is increased to accelerate the adjustment response in fragment-sensitive scenarios.

[0140] S5. Based on the hotspot area distribution and fragment sensitivity level output by the spatiotemporal prediction model, a pre-allocation strategy is executed before the predicted high-concurrency time window to allocate continuous memory blocks from the global memory pool to the pre-allocation buffer in advance.

[0141] In this embodiment, the pre-allocation strategy, through a joint decision-making process combining a multi-cycle synchronous triggering mechanism and spatiotemporal prediction results, aims to reserve contiguous memory blocks before the high-concurrency time window, thereby reducing real-time allocation latency. The technical implementation is detailed below:

[0142] Based on a multi-cycle synchronization protocol, a pre-allocated time window is used. High-concurrency cycle of spatiotemporal prediction model output The relationship must satisfy an integer multiple:

[0143] ;

[0144] Among them, the multiplier coefficient : Dynamically adjusted based on historical load fluctuation variance. Specifically, calculate the most recent Variance of memory requests within a period And set through the following rules :

[0145] ;

[0146] in, This is the baseline variance value, set based on the initial system calibration results. The more drastic the load fluctuations (... The larger ( A higher value enhances the pre-allocated redundancy.

[0147] Pre-allocation Determined by fusing time series predicted values ​​with spatial topological feature quantiles:

[0148] ;

[0149] Among them, time series predicted values : The predicted memory demand for the future time window output by the ARIMA model.

[0150] Spatial quantiles Feature matrix of hotspot regions Take the first column Percentiles are used to quantify the upper limit of memory requirements for high-probability access areas.

[0151] Classification Based on the current fragment sensitivity level Dynamic adjustment. For example, when... When, set To reserve more redundant memory; when When, set To improve memory utilization.

[0152] Contiguous memory block extraction: Selecting contiguous memory blocks from the global memory pool that meet the requirements. A contiguous free area of ​​the specified size is selected; if no such area exists, an adjacent free block merging operation is triggered.

[0153] Pre-allocation buffer management: Extracted contiguous memory blocks are marked as pre-allocation buffers, and their starting physical addresses and capacities are recorded. Buffer marking information is written to the memory management metadata area for priority use by real-time allocation requests.

[0154] After pre-allocation is complete, perform the following status update operations:

[0155] Dynamic programming strategy table update: Update the free block distribution bitmap based on the physical address range of the pre-allocated buffer. Set the corresponding bit to "0" to indicate that it has been reserved.

[0156] Fragmentation Sensitivity Feedback: If the pre-allocation operation results in the generation of new external debris in adjacent areas, the fragmentation sensitivity level of the affected areas is recalculated. This triggers the regeneration of the strategy table.

[0157] The optimization device for the memory management mechanism described below and the optimization method for the memory management mechanism described above can be referred to in correspondence.

[0158] Please see the appendix Figure 2 The present invention also provides an optimization device for memory management mechanisms, the device comprising:

[0159] The strategy pre-computation module 10 is used to construct a dynamic programming state space based on the memory block distribution state, fragmentation sensitivity level and system load level, and generate a pre-computation strategy table by solving the Bellman equation.

[0160] This module pre-generates global memory allocation strategies by constructing a multi-dimensional state space. The system state is jointly defined by the memory block distribution state, fragmentation sensitivity level, and system load level.

[0161] Memory block distribution status: The free and occupied status of physical memory pages is recorded in real time using a binary bitmap, accurately reflecting the physical layout characteristics of consecutive free blocks.

[0162] Fragmentation sensitivity level: quantifies the ratio of internal and external fragmentation in a memory region, used to assess the impact of fragmentation on allocation efficiency.

[0163] System load level: generated by discretization based on CPU utilization and memory request frequency, characterizing the intensity of real-time resource contention in the system.

[0164] By solving the optimal decision problem of the Bellman equation, the optimal allocation action set (such as partitioning, merging, and requesting new regions) under different states is pre-calculated, and a strategy table is generated for real-time allocation decision-making. During system operation, when the state parameters change beyond a threshold, the strategy table is dynamically updated.

[0165] The spatiotemporal prediction module 20 is used to perform joint feature encoding on physical addresses and virtual addresses through a dual-channel attention encoder, and generate memory demand trends and hotspot region distribution predictions based on a time series analysis model and a graph convolutional network.

[0166] This module employs a dual-channel attention mechanism and a hybrid model architecture to achieve spatiotemporal joint prediction of memory requirements:

[0167] Physical-virtual address joint encoding: Physical addresses and virtual addresses are mapped to high-dimensional vectors through an embedding layer, and an attention mechanism is used to capture the non-linear correlation features between the two to generate an address association vector with fused semantics.

[0168] Time series analysis: Based on the historical evolution of memory usage over time, predict memory demand trends within future time windows and capture periodic and trend-related time series characteristics.

[0169] Spatial topology modeling: Construct an association graph with physical memory blocks as nodes, and analyze the proximity and access co-occurrence patterns of memory blocks through graph convolutional networks to identify hotspot areas with high probability of access.

[0170] The prediction results are output as a memory demand trend curve and a hotspot area distribution matrix, providing input for the pre-allocation strategy.

[0171] The closed-loop control module 30 is used to dynamically adjust the thread local cache capacity threshold according to the output of the spatiotemporal prediction module. The adjustment is achieved through a PID controller, and the adjustment parameters are linked with the fragment sensitivity level in real time.

[0172] This module uses an adaptive PID controller to dynamically adjust the thread-local cache threshold.

[0173] Proportional adjustment: Based on the deviation between the current memory demand forecast and the actual capacity, the threshold is adjusted in real time to quickly respond to demand fluctuations.

[0174] Integral term adjustment: Accumulated historical deviations eliminate steady-state errors and suppress threshold drift caused by long-term load fluctuations.

[0175] Differential adjustment: Predict demand change trends and adjust thresholds in advance to suppress overshoot risk.

[0176] The adjustment parameters are linked to the fragmentation sensitivity level in real time. When fragmentation sensitivity increases, the weight of the differential term is automatically increased to prioritize mitigating the impact of fragmentation. The adjusted threshold parameters are synchronously fed back to the policy pre-calculation module, driving the state space update.

[0177] The pre-allocation execution module 40 is used to trigger the pre-allocation operation of consecutive memory blocks before the predicted high-concurrency time window, and to determine the pre-allocation triggering timing according to the multi-cycle synchronization protocol.

[0178] This module triggers a pre-allocation operation based on spatiotemporal prediction results and multi-period synchronization rules:

[0179] Triggering timing decision: By analyzing historical load fluctuation patterns, the relationship between the pre-allocation time window and the integer multiple of the high-concurrency cycle is dynamically determined to ensure that the pre-allocation operation is strictly synchronized with the predicted peak.

[0180] Pre-allocation calculation: The time series forecast value and the spatial topological quantile are combined, and the larger value of the two is taken as the pre-allocation amount, taking into account both the global demand trend and the redundancy reservation of local hot spots.

[0181] Memory block reservation: Extract contiguous free blocks from the global memory pool to the pre-allocation buffer, update the memory distribution bitmap and mark the buffer status to ensure that real-time allocation requests can quickly obtain reserved resources.

[0182] The status feedback module 50 is used to calculate the fragmentation sensitivity level of the current area when memory is released, and to synchronously update the calculation result to the strategy pre-calculation module and the closed-loop control module.

[0183] This module performs fragmentation sensitivity assessment and multi-module state synchronization during memory release:

[0184] Fragmentation sensitivity calculation: Based on the physical address continuity (number of adjacent free blocks) of the released block and the historical access frequency of the virtual address, the impact of the release operation on local fragmentation is quantified.

[0185] Dynamic state synchronization: The calculation results are written to the state space field of the strategy pre-calculation module in real time, triggering the regeneration of the strategy table; at the same time, the feedback interface of the closed-loop control module is input to drive the adjustment of PID parameters.

[0186] Closed-loop linkage mechanism: When the fragmentation sensitivity exceeds the preset threshold, the pre-allocation module is forcibly triggered to perform a merging operation to reduce external fragmentation, forming a closed-loop control link of "evaluation-feedback-optimization".

[0187] The device in this embodiment can be used to execute the above method embodiments, and its principle and technical effects are similar, so they will not be described again here.

[0188] Please see the appendix Figure 3The present invention also provides a computer device 60, including a processor 61 and a memory 62, wherein the memory 62 stores a computer program executable by the processor, and the computer program performs the method described above when executed by the processor.

[0189] The present invention also provides a storage medium 63 on which a computer program is stored, the computer program being executed by a processor 61 to perform the method described above.

[0190] The storage medium 63 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable red-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk or optical disk.

[0191] Although embodiments of the invention have been shown and described, it will be understood by those skilled in the art that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the appended claims and their equivalents.

Claims

1. A method of optimizing a memory management mechanism, characterized in that, The method includes the following steps: S1. Construct a dynamic programming state space based on memory block distribution, fragmentation sensitivity, and system load level, and pre-generate a dynamic programming strategy table by solving a multi-stage decision problem; S2. Based on the state transition probabilities in the dynamic programming strategy table, memory demand is jointly predicted through a spatiotemporal prediction model. The spatiotemporal prediction model integrates time series analysis and physical-virtual address space topology to output the memory demand trend and hotspot area distribution in the future time window. S3. Based on the memory demand trend and hot spot distribution output by the spatiotemporal prediction model, dynamically adjust the local cache capacity threshold of each thread through the PID controller, and feed back the adjusted threshold parameters to the dynamic programming state space in real time. S4. When a memory release operation is detected, the fragmentation sensitivity level of the released region is calculated based on the physical address continuity and virtual address access frequency of the current memory block, and the fragmentation sensitivity level is synchronously updated to the dynamic programming strategy table and the feedback loop of the PID controller. S5. Based on the hotspot region distribution and fragment sensitivity level output by the spatiotemporal prediction model, execute the pre-allocation strategy before the predicted high-concurrency time window, and allocate continuous memory blocks from the global memory pool to the pre-allocation buffer in advance.

2. The method for optimizing the memory management mechanism according to claim 1, characterized in that, Step S1 includes: When constructing the state space for dynamic programming, the system state is defined as a triple. ,in, A binary bitmap representing the distribution of free memory blocks, where each bit corresponds to the occupancy status of a physical memory page; This represents the fragmentation sensitivity level, obtained by quantifying the degree of fragmentation in memory regions. The system load level is discretized based on CPU utilization and memory request frequency according to a preset threshold. When generating the dynamic programming strategy table, the optimal strategy for solving the multi-stage decision problem is determined based on the Bellman equation: ; in, A set of actions; Indicates the execution of an action The resulting expected increase in fragmentation; Indicates action The time cost of lock contention involved; The state transition probability; The weighting coefficients for fragmentation cost and lock contention cost.

3. The method for optimizing the memory management mechanism according to claim 1, characterized in that, In step S2: The spatiotemporal prediction model generates fused features of physical and virtual addresses through a dual-channel attention encoder, where the physical address... and virtual address Each vector is mapped to an embedding function. and The attention feature vector is calculated using the following formula. : ; in, , The weight parameters for the physical address lookup matrix; , These are the weight parameters of the virtual address key matrix; , These are the weight parameters of the mixture matrix; The dimension of the feature vector; The fused feature vector Used to construct a memory block association graph, which serves as input for spatial topology analysis.

4. The method for optimizing the memory management mechanism according to claim 3, characterized in that, In step S2: The time series analysis module uses an autoregressive integral moving average model, and its prediction equation is: ; in: For time window Predicted memory requirements; and These are the coefficients of the autoregressive term and the moving average term, respectively; This is the white noise error term; The spatial topology sensing module employs a graph convolutional network, and its node feature update formula is as follows: ; in, It is an adjacency matrix with self-connections. This indicates the physical proximity between memory blocks. The identity matrix is ​​used to introduce self-loop connections; for The degree matrix; For the first The node feature matrix of the layer; For the first The trainable weight matrix of the layer; The time series prediction results Spatial topological features The inputs are fed into the demand fusion layer to generate joint prediction results.

5. The method for optimizing the memory management mechanism according to claim 1, characterized in that, In step S3: The proportional gain of the PID controller Integral gain and differential gain Based on fragment sensitivity level and system load level Dynamic adjustment, the adjustment formula is: ; in, , , These are the initial gain parameters; To match the load level Positively correlated scaling factor; This is a preset exponential constant; The adjusted gain parameter is used to calculate the local cache capacity threshold. The updated threshold parameters are then written into the load level field of the dynamic programming state space in real time.

6. The method for optimizing the memory management mechanism according to claim 1, characterized in that, In step S4: The fragment sensitivity level For memory regions The calculation is performed using the following formula: ; in, Indicates the area The amount of external debris; Indicates the area Total physical memory capacity; Indicates the area The amount of internal fragmentation; Indicates the area Total allocated memory capacity; These are weighting coefficients that are dynamically adjusted based on the business type. Calculated Simultaneously, the state update module of the dynamic programming strategy table and the feedback input interface of the PID controller are input.

7. The method for optimizing the memory management mechanism according to claim 1, characterized in that, In step S5: The triggering timing of the pre-allocation strategy is determined through a multi-cycle synchronization protocol, satisfying the pre-allocation time window. High-concurrency cycle of spatiotemporal prediction model output Satisfy integer multiple relationship: ; in, The multiplier is dynamically adjusted based on historical load fluctuations; pre-allocated amount. The calculation formula is: ; in, The memory requirement forecast value output by the time series forecasting module; This represents the hotspot region feature matrix output by the spatial topology prediction module. Take the first percentile; Based on fragment sensitivity level Dynamically adjusted preset values; After pre-allocation is completed, update the free block distribution status in the dynamic programming strategy table. And the occupancy marker for the pre-allocated buffer.

8. An optimization device for memory management mechanisms, applied to the method described in any one of claims 1-7, characterized in that, The device includes: The strategy pre-computation module is used to construct a dynamic programming state space based on memory block distribution status, fragmentation sensitivity level and system load level, and generate a pre-computation strategy table by solving Bellman equations. The spatiotemporal prediction module is used to perform joint feature encoding on physical and virtual addresses through a dual-channel attention encoder, and generate memory demand trends and hotspot region distribution predictions based on a time series analysis model and a graph convolutional network. A closed-loop control module is used to dynamically adjust the thread local cache capacity threshold according to the output of the spatiotemporal prediction module. The adjustment is achieved through a PID controller, and the adjustment parameters are linked with the fragmentation sensitivity level in real time. The pre-allocation execution module is used to trigger the pre-allocation operation of consecutive memory blocks before the predicted high-concurrency time window, and to determine the pre-allocation triggering timing according to the multi-cycle synchronization protocol. The status feedback module is used to calculate the fragmentation sensitivity level of the current region when memory is released, and to synchronously update the calculation results to the policy pre-calculation module and the closed-loop control module.

9. A computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the method as described in any one of claims 1-7.

10. A storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the method as described in any one of claims 1-7.