A memory optimization method and device based on state classification

By subdividing memory states and load types and combining them with predictive models, resource allocation strategies are dynamically adjusted, solving the problems of simple state representation and insufficient load awareness in memory management, thereby improving system response speed and resource utilization efficiency.

CN122261818APending Publication Date: 2026-06-23SHENZHEN HEJIUGUIYI CULTURAL DEVELOPMENT CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
SHENZHEN HEJIUGUIYI CULTURAL DEVELOPMENT CO LTD
Filing Date
2026-03-24
Publication Date
2026-06-23

AI Technical Summary

Technical Problem

Existing memory management technologies cannot accurately describe the gradual process of memory pressure, lack load awareness, have fixed scheduling strategies, and insufficient preloading capabilities, resulting in slow system response and unreasonable resource allocation, which affects user experience.

Method used

The memory status is divided into multiple levels, the load type is divided into multiple priorities, dynamic resource allocation is achieved through a scheduling policy mapping table, and resources are preloaded by combining a behavior prediction model.

Benefits of technology

It enables fine-grained management of memory resources, improves system adaptability and smoothness, reduces response latency, and enhances user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122261818A_ABST
    Figure CN122261818A_ABST
Patent Text Reader

Abstract

The application discloses a memory optimization method and device based on state classification. The method comprises: monitoring the available memory capacity of a computing device in real time, dividing the memory pressure state into N levels according to a plurality of preset pressure thresholds, wherein N >= 3; obtaining the load type identifier of the currently running application or process, and dividing the load type into at least two priority levels; according to the memory pressure state level and the load priority level, querying a preset scheduling strategy mapping table to obtain a corresponding resource allocation coefficient; and generating a resource scheduling instruction according to the resource allocation coefficient, wherein the instruction comprises: adjusting the resource allocation quota of the current process, adjusting the priority of the preload queue, and releasing the specified memory area. The application realizes dynamic optimization and scheduling of memory resources by combining and classifying the memory state and the load type, can be widely applied to various computing devices and application scenarios, and improves the system running fluency and memory utilization efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer technology, and specifically to a memory optimization method and apparatus based on state classification. Background Technology

[0002] With the rapid development of computer technology, the demand for memory resources from various applications is increasing day by day. Especially in scenarios such as games, video processing, and artificial intelligence inference, memory shortages have become a key bottleneck affecting user experience and system performance. Existing memory management technologies mainly suffer from the following problems: The state representation is too simple: Traditional memory management mainly relies on the binary judgment of "sufficient / stressful", which makes it difficult to accurately describe the gradual process of pressure change. This results in an overly coarse scheduling strategy that cannot adapt to the differentiated needs under different pressure levels. Lack of load awareness: It fails to distinguish the different memory resource requirements of different types of applications and different operating scenarios, resulting in unreasonable resource allocation. For example, real-time interactive applications (such as game front-ends) and background tasks (such as data synchronization) have completely different requirements for memory latency and bandwidth, which traditional methods cannot differentiate between. Fixed scheduling strategy: The memory reclamation and allocation strategy is preset and cannot be dynamically adjusted according to the system's running status. It lacks adaptive capability, resulting in a slow response of the system when memory pressure changes. Insufficient preloading capability: The lack of a mechanism to predict program behavior often results in resource loading lagging behind demand, leading to response delays and impacting user experience. Therefore, there is an urgent need for a method and device that can perform fine-grained and dynamic memory optimization scheduling based on memory status and load type. Summary of the Invention

[0003] Purpose of the invention This invention aims to provide a memory optimization method and apparatus based on state classification. By dividing memory states into multiple levels and load types into multiple priorities, and querying a scheduling policy mapping table based on the combination of the two, dynamic optimization scheduling of memory resources can be achieved, thereby improving system smoothness and memory utilization efficiency. Technical solution To achieve the above objectives, the present invention provides the following technical solution: A memory optimization method based on state classification includes the following steps: Step S1 (Memory Status Classification): Monitor the available memory capacity of the computing device in real time, and classify the memory pressure status into N levels according to multiple preset pressure thresholds, where N≥3. Preferably, N=4, and the memory pressure state is divided into a first state, a second state, a third state, and a fourth state. More preferably, when the memory usage rate is lower than a first threshold, it is determined to be in the first state; when it is between the first and second thresholds, it is determined to be in the second state; when it is between the second and third thresholds, it is determined to be in the third state; and when it is higher than the third threshold, it is determined to be in the fourth state. More preferably, the first threshold is 30%, the second threshold is 60%, and the third threshold is 80%. Step S2 (Load Type Classification): Obtain the load type identifier of the currently running application or process, and classify the load type into at least two priority levels. Preferably, the load type is divided into first priority, second priority, and third priority. More preferably, processes with real-time interaction requirements or high response requirements are classified as first priority, normally running processes are classified as second priority, and background tasks or processes with low response requirements are classified as third priority. Step S3 (Policy Query): Based on the memory pressure status level obtained in Step S1 and the load priority level obtained in Step S2, query the preset scheduling policy mapping table to obtain the corresponding resource allocation coefficient. The scheduling policy mapping table is stored in the form of a two-dimensional matrix, where rows correspond to memory pressure status levels, columns correspond to load priority levels, and matrix elements are resource allocation coefficient values. Preferably, the scheduling policy mapping table includes at least the following combinations of scheduling rules: When memory is in the first state and the load is the first priority, the first allocation factor is used and preloading is triggered. When the memory is in the third state and the load is the third priority, the third allocation factor is used and resource release is triggered. When memory is in the fourth state, regardless of the load type, the third allocation factor is used and a forced resource release is triggered. Step S4 (Instruction Generation): Based on the resource allocation coefficient obtained in Step S3, generate resource scheduling instructions, including: adjusting the resource allocation quota of the current process, adjusting the priority of the preload queue, and releasing a specified memory area. Preferably, the method further includes step S5 (behavior prediction): obtaining historical running data of the application or process, predicting its resource demand changes within a preset time window through a prediction model; and adding the required resources to the preloading queue in advance based on the prediction results. More preferably, the prediction model is a time-series neural network-based model, and its input features include: process type, running status, historical resource usage data, and time information. Preferably, the method further includes step S6 (dynamic adjustment): when the memory pressure state changes from the second state to the third state, the resource allocation of the non-core functions of the current process is automatically reduced; when the memory pressure state changes from the third state to the second state, the resource allocation of the non-core functions of the current process is automatically restored. A memory optimization device based on state classification, comprising: Monitoring module: Configured to monitor the available memory capacity of the computing device in real time and output the memory pressure status level; Classification module: Configured to obtain the load type identifier of the currently running application or process and output the load priority level; Scheduling module: Configured to query the scheduling policy mapping table based on memory pressure status level and load priority level, and output resource allocation coefficients; Execution module: Configured to generate and issue resource scheduling instructions based on resource allocation coefficients. Preferably, the device further includes: Prediction module: Configured to predict changes in resource requirements of an application or process based on its historical runtime data; Preloading module: Configured to add the resources required for prediction to the preloading queue based on the output of the prediction module. A computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the state-classification-based memory optimization method described above. Beneficial effects

[0004] Compared with the prior art, the present invention has the following beneficial effects: Fine-grained state representation: The memory pressure state is divided into N levels (preferably 4 levels), which can more accurately describe the pressure change trend than the traditional binary classification, providing a basis for fine-grained scheduling. Load awareness capability: By identifying load type priority, it can distinguish the different memory resource requirements of different types of applications and different running scenarios, realize on-demand allocation, and ensure the smooth operation of high-priority applications. Dynamic adaptive scheduling: By querying the combination of memory status and load type, the scheduling strategy can be dynamically adjusted instead of remaining fixed, thereby improving the system's adaptability. Predictive resource management: By combining behavioral prediction, the required resources are loaded in advance, reducing response latency and improving user experience. Wide applicability: This invention is not limited to specific application areas and can be applied to various scenarios that require memory optimization, such as games, cloud computing, AI inference, operating systems, and embedded systems. Attached Figure Description

[0005] Figure 1A flowchart of a memory optimization method based on state classification provided in an embodiment of the present invention; Figure 2 A block diagram of a memory optimization device based on state classification provided in an embodiment of the present invention; Figure 2 As an abstract illustration, a light-colored background is used to distinguish the module areas, clearly showing the device architecture. Figure 3 This is a schematic diagram illustrating the memory pressure state division provided in an embodiment of the present invention. Figure 3 Different colors are used to distinguish the four memory pressure states in order to more intuitively show the state division. Figure 4 This is an example of a scheduling strategy mapping representation provided in an embodiment of the present invention. Figure 5 A flowchart of the prediction preloading process provided in this embodiment of the invention; Figure 6 A flowchart for dynamic precision adjustment provided in an embodiment of the present invention. Detailed Implementation

[0006] The present invention will now be described in detail with reference to the accompanying drawings and specific embodiments. These embodiments are implemented based on the technical solution of the present invention, but the scope of protection of the present invention is not limited to the following embodiments. Example 1 Reference Figure 1 This embodiment provides a memory optimization method based on state classification, including the following steps: Step S101: Monitor memory status After the system starts up, the monitoring module collects memory usage data of the computing device in real time. Let the current memory usage rate be R, and the preset thresholds be T1=30%, T2=60%, and T3=80%. Output the memory stress status level based on the comparison results: If R < 30%, output the first state (state A); If 30% ≤ R < 60%, output the second state (state B); If 60% ≤ R < 80%, output the third state (state C); If R ≥ 80%, output the fourth state (state D). Step S102: Identify load type The classification module obtains process information of currently running applications and identifies the load type based on process characteristics: If a process has real-time interactive features (such as game front-end, video call), it is classified as the first priority (priority 1). If the process is a common application (such as document editing or web browsing), it is classified as the second priority (priority 2). If the process is a background task (such as data synchronization or log recording), it is classified as the third priority (priority 3). Step S103: Query scheduling policy The scheduling module queries the preset scheduling policy mapping table to obtain the resource allocation coefficient based on the memory status obtained in step S101 and the load priority obtained in step S102. like Figure 4 As shown, the scheduling strategy mapping table is a two-dimensional matrix with 4 rows and 3 columns, and the matrix elements are resource allocation coefficient values ​​(ranging from 0 to 100). The scheduling policy mapping table is as follows: When memory is in state A (utilization <30%) and the load is priority 1 (real-time interaction), the resource allocation coefficient is 95. When the memory is in the first state (A) and the load is the second priority (normal operation), the allocation coefficient is 80; When the memory is in the first state (A) and the load is the third priority (background task), the allocation coefficient is 60; When the memory is in the second state (B, 30%-60%) and the load is the first priority, the allocation coefficient is 85; Step S104: Generate scheduling instructions The execution module generates scheduling instructions based on resource allocation coefficients: If the allocation coefficient is ≥80, maintain high resource allocation, which can trigger preloading; If the allocation coefficient is between 50 and 80, maintain a moderate resource allocation; If the allocation coefficient is less than 50, reduce resource allocation and trigger resource release. Example 2 Reference Figure 2 This embodiment provides a memory optimization device based on state classification, including: Monitoring module (100): Connects to the operating system API of the computing device, configured to collect memory usage data in real time and output memory pressure status level; Classification module (200): Connected to the process management module, configured to obtain the load type identifier of the currently running process and output the load priority level; Scheduling module (300): Connected to monitoring module (100) and classification module (200) respectively, configured to query scheduling policy mapping table and output resource allocation coefficients based on memory pressure status level and load priority level; Execution module (400): Connected to scheduling module (300), configured to generate and issue resource scheduling instructions based on resource allocation coefficients; Prediction module (500) (optional): connected to execution module (400), configured to predict changes in resource demand based on historical operating data; Preload module (600) (optional): Connected to the prediction module (500) and the execution module (400), configured to preload resources based on the prediction results. Example 3 This embodiment provides an example of the application of the method in a game scenario. When players are playing the game: The monitoring module detected a memory usage rate of 35% (second state); The classification module identifies game progress as the highest priority (real-time interaction); The scheduling module queries the mapping table and obtains an allocation coefficient of 85; The execution module maintains high-precision rendering and preloads resources for the next scene. When memory usage rises to 75% (third state): The monitoring module outputs a third status; The scheduling module queries the mapping table and obtains an allocation coefficient of 70; The execution module appropriately reduces the rendering precision of non-focus objects to release cache resources; The game runs smoothly, and players are unaware of its operation. Example 4 This embodiment provides an example of the application of the method in a cloud computing server. The server runs multiple virtual machines simultaneously: The monitoring module detected that the physical memory usage rate was 82% (fourth state); The classification module identifies the load type of each virtual machine (real-time business, general computing, background tasks). The scheduling module outputs allocation coefficients based on the combined state: 55 for real-time business, 40 for normal calculation, and 20 for background tasks; The execution module migrates the background task virtual machine to a standby node, freeing up physical memory; The real-time business virtual machine continues to operate normally, and the service quality is unaffected. Example 5 Reference Figure 5 This embodiment provides a specific process for predictive preloading: Collect historical running data of the process, including process type, running status, resource usage, and timestamp; The feature sequence is input into a time-series neural network model, which outputs a prediction of future resource demand. Determine whether the prediction confidence level is higher than a preset threshold (e.g., 70%). If the value exceeds the threshold, the predicted resources will be added to the preloading queue and assigned a high priority. If the value is below the threshold, maintain the current state and wait for the next sampling. Example 6 Reference Figure 6 This embodiment provides a detailed process for dynamic precision adjustment: Continuously monitor memory status; Detect whether the memory status has changed; If the memory status changes from the second state (normal) to the third state (tight), perform a downgrade adjustment: reduce the allocation of non-core resources, reduce rendering precision, and release the cache; If the memory status changes from the third state (tight) to the second state (normal), perform recovery adjustments: restore non-core resource allocation, restore rendering precision, and restore cache; Execute the adjustment command to update the resource allocation status.

Claims

1. A memory optimization method based on state classification, characterized in that, Includes the following steps: Step S1: Monitor the available memory capacity of the computing device in real time, and divide the memory pressure status into N levels according to multiple preset pressure thresholds, where N≥3; Step S2: Obtain the load type identifier of the currently running application or process, and divide the load type into at least two priority levels; Step S3: Based on the memory pressure status level obtained in Step S1 and the load priority level obtained in Step S2, query the preset scheduling policy mapping table to obtain the corresponding resource allocation coefficient. Step S4: Based on the resource allocation coefficient obtained in step S3, generate resource scheduling instructions, including: adjusting the resource allocation quota of the current process, adjusting the priority of the preload queue, and releasing the specified memory area.

2. The method according to claim 1, characterized in that, The mapping relationship between the N levels and memory usage in step S1 is as follows: when the memory usage is lower than the first threshold, it is determined to be in the first state; when it is between the first threshold and the second threshold, it is determined to be in the second state; when it is between the second threshold and the third threshold, it is determined to be in the third state; and when it is higher than the third threshold, it is determined to be in the fourth state. The first threshold is 30%, the second threshold is 60%, and the third threshold is 80%.

3. The method according to claim 1, characterized in that, The load type classification in step S2 includes: processes with real-time interaction requirements or high response requirements are classified as first priority, normally running processes are classified as second priority, and background tasks or processes with low response requirements are classified as third priority.

4. The method according to claim 1, characterized in that, The scheduling policy mapping table described in step S3 is stored in the form of a two-dimensional matrix, where rows correspond to memory pressure status levels, columns correspond to load priority levels, and matrix elements are resource allocation coefficient values.

5. The method according to claim 1, characterized in that, The scheduling policy mapping table in step S3 includes at least the following combination of scheduling rules: when the memory is in the first state and the load is the first priority, the first allocation coefficient is used and preloading is triggered; When the memory is in the third state and the load is the third priority, the third allocation factor is used and resource release is triggered; when the memory is in the fourth state, regardless of the load type, the third allocation factor is used and forced resource release is triggered.

6. The method according to claim 1, characterized in that, It also includes step S5: obtaining historical running data of the application or process, predicting the changes in its resource demand within a preset time window through a prediction model; adding the required resources to the preloading queue in advance based on the prediction results; the prediction model is a model based on a temporal neural network, and its input features include: process type, running status, historical resource usage data, and time information.

7. The method according to claim 1, characterized in that, It also includes step S6: when the memory pressure state changes from the second state to the third state, automatically reduce the resource allocation of the non-core functions of the current process; when the memory pressure state changes from the third state to the second state, automatically restore the resource allocation of the non-core functions of the current process.

8. A memory optimization device based on state classification, characterized in that, include: The monitoring module is configured to monitor the available memory capacity of the computing device in real time and output the memory pressure status level. The classification module is configured to obtain the load type identifier of the currently running application or process and output the load priority level; The scheduling module is configured to query the scheduling policy mapping table based on the memory pressure status level and load priority level, and output the resource allocation coefficient; the execution module is configured to generate and issue resource scheduling instructions based on the resource allocation coefficient.

9. The apparatus according to claim 8, characterized in that, Also includes: The prediction module is configured to predict changes in the resource requirements of an application or process based on its historical running data; the preloading module is configured to add the predicted resources to the preloading queue based on the output of the prediction module.

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