Memory management mechanism optimization method and device, equipment and storage medium

By obtaining and analyzing memory data in the expansion of real application scenarios, and optimizing memory management in combination with the CPU load state, the accuracy and efficiency of the memory management mechanism in the existing technology are solved, and the stability and user experience of the background process are improved.

CN119357074APending Publication Date: 2025-01-24WEIFANG GOERTEK ELECTRONICS CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411387974.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-30
Publication Date
2025-01-24

AI Technical Summary

Technical Problem

The accuracy and efficiency of the existing technology in optimizing the memory management mechanism is low, especially in the expansion of real-life application scenarios, resulting in frequent termination of important background processes and XR application processes.

Method used

By obtaining the memory data of the target system in the extended real application scenario, calculate the number of real free pages and the number of recyclable file mapping pages, determine the current pressure status, and combine the current load state of the CPU to optimize the memory management mechanism.

Benefits of technology

It improves the accuracy and efficiency of the memory management mechanism, enhances the persistence ability of background processes, improves the user's interactive experience in the XR environment, and avoids the termination of important background processes and XR application processes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119357074A_ABST
    Figure CN119357074A_ABST
Patent Text Reader

Abstract

The invention discloses an optimization method and device of a memory management mechanism, equipment and a storage medium, and relates to the technical field of operating systems, and the optimization method comprises the steps that the number of real idle pages and the number of recoverable file mapping pages are determined according to memory data; determining the current pressure state of the target system according to the number of the real idle pages and the number of the recoverable file mapping pages; optimizing a memory management mechanism according to the current pressure state and the current load state of the CPU; through the above mode, the number of real idle pages and the number of recoverable file mapping pages are determined, the current pressure state is further determined, and then the memory management mechanism is optimized in combination with the current load state of the CPU, so that the accuracy and efficiency of optimizing the memory management mechanism can be effectively improved, the residence capability of a background process is enhanced, and the user experience is improved. The interaction experience of the user in the XR environment is improved, and on the basis of ensuring the stability of the target system, the termination of important background processes and XR application processes is avoided.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of operating system technology, and in particular to a method, device, equipment and storage medium for optimizing a memory management mechanism. Background Art

[0002] The memory management mechanism is crucial in the operating system, especially in a resource-constrained environment. At present, the commonly used memory management mechanism is to use the Low Memory Killer Daemon (LMKD) process to automatically terminate background processes according to the system's memory status to free up memory space. However, in the Extended Reality (XR) application scenario, due to the high memory requirements of applications and services, the default termination policy of the LMKD process will cause important background processes to be frequently terminated, and even terminate the XR application process. Therefore, it is particularly important to optimize the memory management mechanism. At present, the common way to optimize the memory management mechanism is to set a process identification policy, that is, the important background process or XR application process will not be terminated after it is identified. However, the above identification will take a lot of time, and the importance of the background process is constantly changing, resulting in low identification accuracy. Therefore, the accuracy and efficiency of optimizing the memory management mechanism in the above method are low.

[0003] The above contents are only used to assist in understanding the technical solution of the present application and do not constitute an admission that the above contents are prior art. Summary of the invention

[0004] The main purpose of this application is to provide a method, device, equipment and storage medium for optimizing a memory management mechanism, aiming to solve the technical problems of low accuracy and efficiency of optimizing a memory management mechanism in the prior art.

[0005] To achieve the above objectives, the present application proposes a method for optimizing a memory management mechanism, the method comprising:

[0006] Obtain memory data of the target system in the extended reality application scenario;

[0007] Determine the number of truly free pages and the number of reclaimable file mapping pages according to the memory data;

[0008] Determine the current pressure state of the target system according to the number of truly free pages and the number of reclaimable file mapping pages;

[0009] The memory management mechanism is optimized according to the current pressure state and the current load state of the CPU.

[0010] In one embodiment, the step of calculating the number of truly free pages and the number of reclaimable file mapping pages according to the memory data includes:

[0011] Obtaining the total number of free pages and the number of reserved pages according to the memory data;

[0012] Subtract the total number of free pages from the number of reserved pages to obtain the number of real free pages;

[0013] According to the memory data, the total number of file mapping pages, shared memory data, non-eviction memory data and swap cache data are obtained;

[0014] Calculate a target memory sum according to the shared memory data, the non-evictable memory data and the swap cache data;

[0015] When the total number of file mapping pages is greater than the target memory sum, the number of reclaimable file mapping pages is calculated according to the total number of file mapping pages and the target memory sum.

[0016] In one embodiment, the step of determining the current pressure state of the target system according to the number of truly free pages and the number of reclaimable file mapping pages includes:

[0017] Determine the preset memory watermark;

[0018] Compare the number of truly free pages with the preset memory watermark;

[0019] Compare the number of recyclable file mapping pages with the preset memory watermark;

[0020] Based on the target pressure state identification algorithm, the current pressure state of the target system is identified according to the free page comparison result and the file mapping page comparison result.

[0021] In one embodiment, the step of optimizing the memory management mechanism according to the current pressure state and the current load state of the CPU includes:

[0022] determining a current operating mode of the target system according to the current pressure state;

[0023] Get the current load status of the CPU;

[0024] The memory management mechanism is optimized according to the current operation mode and the current load state of the CPU.

[0025] In one embodiment, the step of optimizing the memory management mechanism according to the current operating mode and the current load state of the CPU includes:

[0026] When the current operating mode is an idle mode, setting a configuration parameter of memory recycling to a gentle recycling parameter;

[0027] When the current load state of the CPU is an idle state, generating a first event trigger signal;

[0028] The preset subsystem of the target system kernel triggers a memory recycling event according to the set mild recycling parameters and the first event trigger signal, thereby completing the optimization of the memory management mechanism.

[0029] In one embodiment, the step of optimizing the memory management mechanism according to the current operating mode and the current load state of the CPU includes:

[0030] When the current operation mode is the pressure mode, setting the configuration parameter of memory recycling to an aggressive recycling parameter;

[0031] When the current load state of the CPU is an idle state, generating a second event trigger signal;

[0032] The preset subsystem of the target system kernel triggers a memory recycling event according to the set mild recycling parameter and the second event trigger signal, thereby completing the optimization of the memory management mechanism.

[0033] In one embodiment, after the step of optimizing the memory management mechanism according to the current pressure state and the current load state of the CPU, the process further includes:

[0034] Determine the target pressure state of the target system according to the number of truly free pages and the number of reclaimable file mapping pages at the next moment;

[0035] determining a target operating mode of a target system according to the target pressure state;

[0036] When the target operating mode is inconsistent with the current operating mode and the configuration parameter of the memory recycling is an aggressive recycling parameter, the configuration parameter of the memory recycling is set to a mild recycling parameter, and the step of generating a first event trigger signal when the current load state of the CPU is an idle state is continued.

[0037] In addition, to achieve the above purpose, the present application also proposes an optimization device for a memory management mechanism, and the optimization device for the memory management mechanism includes:

[0038] An acquisition module is used to obtain the memory data of the target system in the extended reality application scenario;

[0039] A determination module, used to determine the number of truly free pages and the number of reclaimable file mapping pages according to the memory data;

[0040] The determination module is further used to determine the current pressure state of the target system according to the number of truly free pages and the number of reclaimable file mapping pages;

[0041] The optimization module is used to optimize the memory management mechanism according to the current pressure state and the current load state of the CPU.

[0042] In addition, to achieve the above-mentioned purpose, the present application also proposes a memory management mechanism optimization device, the device comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the memory management mechanism optimization method as described above.

[0043] In addition, to achieve the above-mentioned purpose, the present application also proposes a storage medium, which is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by the processor, the steps of the optimization method of the memory management mechanism as described above are implemented.

[0044] One or more technical solutions proposed in the present application have at least the following technical effects: by obtaining the memory data of the target system in the extended reality application scenario; determining the number of truly free pages and the number of recyclable file mapping pages according to the memory data; determining the current pressure state of the target system according to the number of truly free pages and the number of recyclable file mapping pages; optimizing the memory management mechanism according to the current pressure state and the current load state of the CPU; through the above methods, the number of truly free pages and the number of recyclable file mapping pages are determined respectively, and then the current pressure state of the target system is further determined, and then the memory management mechanism is optimized in combination with the current load state of the CPU, so as to effectively improve the accuracy and efficiency of the optimized memory management mechanism, thereby enhancing the resident capability of background processes, improving the user's interactive experience in the XR environment, and avoiding the termination of important background processes and XR application processes on the basis of ensuring the stability of the target system. BRIEF DESCRIPTION OF THE DRAWINGS

[0045] The accompanying drawings herein are incorporated in and constitute a part of the specification, illustrate embodiments consistent with the present application, and together with the description, are used to explain the principles of the present application.

[0046] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0047] Figure 1 A flowchart diagram of the first embodiment of the method for optimizing the memory management mechanism of the present application is provided;

[0048] Figure 2A flowchart diagram of the second embodiment of the method for optimizing the memory management mechanism of the present application is provided;

[0049] Figure 3 A brief flowchart of a method for optimizing a memory management mechanism provided in Embodiment 2 of the present application;

[0050] Figure 4 A schematic diagram of the module structure of the device for optimizing the memory management mechanism of an embodiment of the present application;

[0051] Figure 5 A schematic diagram of the device structure of the hardware operating environment involved in the method for optimizing the memory management mechanism in the embodiment of the present application.

[0052] The purpose, features and advantages of this application will be further described in conjunction with the embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION

[0053] It should be noted that the execution subject of this embodiment may be a computing service device with data processing, network communication and program running functions, such as a tablet computer, a personal computer, a mobile phone, etc., or an electronic device capable of realizing the above functions, a mechanism optimization device, etc. The following takes the mechanism optimization device as an example to illustrate this embodiment and the following embodiments.

[0054] Based on this, the embodiment of the present application provides a method for optimizing a memory management mechanism, referring to Figure 1 , Figure 1 This is a flow chart of the first embodiment of the method for optimizing the memory management mechanism of the present application.

[0055] In this embodiment, the method for optimizing the memory management mechanism includes steps S10 to S40:

[0056] Step S10, obtaining memory data of the target system in an extended reality application scenario.

[0057] It should be noted that the target system can be an Android system, and the memory data refers to the data that characterizes the memory of the target system in the extended reality application scenario. The memory data includes but is not limited to the total number of free pages, the number of reserved pages, the total number of file mapping pages, shared memory data, non-eviction memory data, and swap cache data, etc.

[0058] Step S20, determining the number of truly free pages and the number of reclaimable file mapping pages according to the memory data.

[0059] It can be understood that the number of truly free pages refers to the number of free pages that can be used for general purposes, and the number of file mapping pages refers to the number of pages mapped from files to the memory. This embodiment is aimed at the number of reclaimable file mapping pages. The number of truly free pages and the number of reclaimable file mapping pages can reflect the actual availability of the target system memory.

[0060] Further, step S20 includes: obtaining a total number of free pages and a number of reserved pages according to the memory data; performing subtraction calculation on the total number of free pages and the number of reserved pages to obtain a number of truly free pages; obtaining a total number of file mapping pages, shared memory data, non-evictable memory data, and swap cache data according to the memory data; calculating a target memory sum according to the shared memory data, the non-evictable memory data, and the swap cache data; and when the total number of file mapping pages is greater than the target memory sum, calculating a number of reclaimable file mapping pages according to the total number of file mapping pages and the target memory sum.

[0061] It should be understood that the total number of free pages refers to the total number of free pages, the number of reserved pages refers to the number of pages reserved by the target system, and the actual number of free pages other_free = the number of free pages mi->field.nr_free_pages-the number of reserved pages zi->totalreserve_pages.

[0062] It can be understood that the target memory sum refers to the sum of memory data in multiple dimensions, which includes shared memory data, non-eviction memory data and swap cache data. After calculating the target memory sum, determine whether the total number of file mapping pages is greater than the target memory sum. If so, calculate the number of reclaimable file mapping pages other_file based on the total number of file mapping pages and the target memory sum. If not, directly set the number of reclaimable file mapping pages to 0.

[0063] It should be noted that before calculating the number of truly free pages and the number of reclaimable file mapping pages, two variables are defined, namely other_free and other_file, which are used to store the calculated number of truly free pages and the number of reclaimable file mapping pages.

[0064] Step S30, determining the current pressure state of the target system according to the number of truly free pages and the number of reclaimable file mapping pages.

[0065] It can be understood that the current pressure state refers to the pressure state of the target system in the extended reality application scenario. The current pressure state can be comprehensively determined based on the number of truly free pages and the number of reclaimable file mapping pages. The current pressure state can ensure the pressure trend of the target system. For example, when the memory condition tends to deteriorate, memory recovery is performed in advance to improve the system memory condition.

[0066] Further, step S30 includes: determining a preset memory water level; comparing the number of truly free pages with the preset memory water level; comparing the number of reclaimable file mapping pages with the preset memory water level; and identifying the current pressure state of the target system based on the free page comparison results and the file mapping page comparison results based on the target pressure state identification algorithm.

[0067] It should be understood that the target pressure state identification algorithm refers to an algorithm used to identify the pressure state. In the present embodiment, it is used to identify the current pressure state of the target system. After obtaining the number of truly free pages and the number of reclaimable file mapping pages, it is necessary to compare the above quantity parameters with the preset memory water level respectively, and then use the target pressure state identification algorithm to identify the current pressure state of the target system. For example, when the free page comparison result is that the number of truly free pages is lower than the preset memory water level and the file mapping page comparison result is that the number of reclaimable file mapping pages is lower than the preset memory water level, it indicates that the memory pressure of the target system is relatively large.

[0068] Step S40: Optimizing the memory management mechanism according to the current pressure state and the current load state of the CPU.

[0069] It is understandable that after obtaining the current pressure state, the memory management mechanism is optimized in combination with the current load state of the CPU, so as to optimize the resource allocation strategy, improve the overall performance and stability of the target system, and enhance the residence capability of the background process.

[0070] Furthermore, after step S40, it also includes: determining a target pressure state of the target system according to the number of truly free pages and the number of reclaimable file mapping pages at the next moment; determining a target operating mode of the target system according to the target pressure state; when the target operating mode is inconsistent with the current operating mode and the configuration parameter of the memory recycling is an aggressive recycling parameter, setting the configuration parameter of the memory recycling to a mild recycling parameter, and continuing to execute the step of generating a first event trigger signal when the current load state of the CPU is an idle state.

[0071] It should be understood that after optimizing the memory management mechanism at the current moment, the number of truly free pages and the number of reclaimable file mapping pages at the next moment will also be obtained, that is, uninterrupted optimization is achieved, and then when the target operating mode is inconsistent with the current operating mode, it indicates that a mode switch has been performed. At this time, it is necessary to reset the configuration parameters of memory recovery. When the configuration parameters of memory recovery are aggressive recovery parameters, the configuration parameters of memory recovery are reset to moderate recovery parameters. Then, when the current load state of the CPU is idle, the first event trigger signal is used to trigger the memory recovery event to continue memory recovery.

[0072] This embodiment obtains memory data of the target system in an extended reality application scenario; determines the number of truly free pages and the number of reclaimable file mapping pages based on the memory data; determines the current pressure state of the target system based on the number of truly free pages and the number of reclaimable file mapping pages; optimizes the memory management mechanism based on the current pressure state and the current load state of the CPU; through the above methods, the number of truly free pages and the number of reclaimable file mapping pages are determined respectively, and then the current pressure state of the target system is further determined, and then the memory management mechanism is optimized in combination with the current load state of the CPU, so as to effectively improve the accuracy and efficiency of the optimized memory management mechanism, thereby enhancing the resident capability of background processes, improving the user's interactive experience in the XR environment, and avoiding the termination of important background processes and XR application processes on the basis of ensuring the stability of the target system.

[0073] Based on the first embodiment of the present application, in the second embodiment of the present application, the same or similar contents as those in the above-mentioned embodiment 1 can be referred to the above introduction, and will not be repeated in the following. Figure 2 , step S40 includes steps S401 to S403:

[0074] Step S401, determining a current operation mode of the target system according to the current pressure state.

[0075] It should be noted that the current operating mode refers to the operating mode of the target system under the current pressure state. When the current pressure state is an idle state, the current operating mode is determined to be an idle mode. When the current pressure state is a high pressure state, the current operating mode is determined to be a pressure mode.

[0076] Step S402, obtaining the current load status of the CPU.

[0077] It can be understood that the current load state refers to the load state of the CPU in the extended reality application scenario, and the parameters for determining the load state of the CPU include but are not limited to utilization, load balance, etc.

[0078] Step S403: Optimize the memory management mechanism according to the current operation mode and the current load state of the CPU.

[0079] It should be understood that after obtaining the current operating mode of the target system, the memory management mechanism is optimized in combination with the current load state of the CPU, so that the resource allocation strategy can be optimized.

[0080] Further, step S403 includes: when the current operating mode is an idle mode, setting the configuration parameters of memory recovery to mild recovery parameters; when the current load state of the CPU is an idle state, generating a first event trigger signal; triggering a memory recovery event through a preset subsystem of the target system kernel according to the set mild recovery parameters and the first event trigger signal, thereby completing the optimization of the memory management mechanism.

[0081] It is understandable that when the current operating mode is determined to be idle mode, a more relaxed recovery strategy is adopted, that is, the configuration parameters of memory recovery are set to mild recovery parameters to avoid unnecessary resource consumption. The mild recovery parameters represent a low threshold, and then when the current load state of the CPU is idle, it indicates that the CPU load is light. At this time, measures can be taken in advance to recycle memory, rather than waiting until the memory is tight. That is, the preset subsystem of the target system kernel triggers the memory recovery event according to the set mild recovery parameters and the first event trigger signal. The preset subsystem can be the mem_reclaim subsystem. After the memory recovery event is triggered, memory recovery is performed. At this time, the optimization of the memory management mechanism has been completed.

[0082] Further, step S403 includes: when the current operating mode is the stress mode, setting the configuration parameters of memory recycling to aggressive recycling parameters; when the current load state of the CPU is the idle state, generating a second event trigger signal; triggering a memory recycling event through a preset subsystem of the target system kernel according to the set mild recycling parameters and the second event trigger signal, thereby completing the optimization of the memory management mechanism.

[0083] It should be understood that when it is determined that the current operating mode is the stress mode, a strict recycling strategy is adopted, that is, the configuration parameters of memory recycling are set to aggressive recycling parameters to achieve the purpose of quickly releasing memory resources. The aggressive recycling parameters represent a high threshold, and then the preset subsystem of the target system kernel triggers the memory recycling event according to the set mild recycling parameters and the second event trigger signal to perform memory recycling. At this time, the optimization of the memory management mechanism has been completed, and predictive active memory recycling is realized, avoiding problems such as black screen and flash back of the XR application process due to insufficient memory, greatly improving the user experience.

[0084] This embodiment determines the current operating mode of the target system according to the current pressure state; obtains the current load state of the CPU; optimizes the memory management mechanism according to the current operating mode and the current load state of the CPU; through the above method, the corresponding current operating mode is determined according to the current pressure state of the target system, and then the memory management mechanism is comprehensively optimized in combination with the current load state of the CPU, thereby effectively improving the accuracy and efficiency of the optimized memory management mechanism, avoiding problems such as black screen and flash back of the XR application process due to insufficient memory, and greatly improving the user experience.

[0085] For example, to help understand the implementation process of the memory management mechanism optimization method obtained by combining this embodiment with the above-mentioned embodiment 1, please refer to Figure 3 , Figure 3 A brief flowchart of a method for optimizing a memory management mechanism is provided, specifically:

[0086] Two variables are defined to store the determined number of truly free pages and the number of reclaimable file mapping pages, and then the current pressure state of the target system is determined according to the number of truly free pages and the number of reclaimable file mapping pages, and the current operation mode of the target system is determined according to the current pressure state. When the current operation mode is the idle mode, the configuration parameters of memory recovery are set to mild recovery parameters, and then it is determined whether the current load state of the CPU is in the idle state. If so, a memory recovery event is triggered by a preset subsystem of the kernel of the target system according to the set mild recovery parameters and a first event trigger signal, thereby completing the optimization of the memory management mechanism. When the current operation mode is the pressure mode, the configuration parameters of memory recovery are set to aggressive recovery parameters, and a memory recovery event is also triggered by a preset subsystem of the kernel of the target system according to the set mild recovery parameters and a second event trigger signal, thereby completing the optimization of the memory management mechanism.

[0087] It should be noted that the above examples are only used to understand the present application and do not constitute a limitation on the optimization method of the memory management mechanism of the present application. More simple transformations based on this technical concept are all within the scope of protection of the present application.

[0088] This application also provides an optimization device for memory management mechanism, please refer to Figure 4 , the optimization device of the memory management mechanism includes:

[0089] The acquisition module 10 is used to acquire the memory data of the target system in the extended reality application scenario.

[0090] The determination module 20 is used to determine the number of truly free pages and the number of reclaimable file mapping pages according to the memory data.

[0091] The determination module 20 is further configured to determine the current pressure state of the target system according to the number of truly free pages and the number of reclaimable file mapping pages.

[0092] The optimization module 30 is used to optimize the memory management mechanism according to the current pressure state and the current load state of the CPU.

[0093] This embodiment obtains memory data of the target system in an extended reality application scenario; determines the number of truly free pages and the number of reclaimable file mapping pages based on the memory data; determines the current pressure state of the target system based on the number of truly free pages and the number of reclaimable file mapping pages; optimizes the memory management mechanism based on the current pressure state and the current load state of the CPU; through the above methods, the number of truly free pages and the number of reclaimable file mapping pages are determined respectively, and then the current pressure state of the target system is further determined, and then the memory management mechanism is optimized in combination with the current load state of the CPU, so as to effectively improve the accuracy and efficiency of the optimized memory management mechanism, thereby enhancing the resident capability of background processes, improving the user's interactive experience in the XR environment, and avoiding the termination of important background processes and XR application processes on the basis of ensuring the stability of the target system.

[0094] The memory management mechanism optimization device provided by the present application adopts the memory management mechanism optimization method in the above-mentioned embodiment, which can solve the technical problem of low accuracy and efficiency of the memory management mechanism optimization in the prior art. Compared with the prior art, the beneficial effects of the memory management mechanism optimization device provided by the present application are the same as the beneficial effects of the memory management mechanism optimization method provided by the above-mentioned embodiment, and the other technical features in the memory management mechanism optimization device are the same as the features disclosed in the above-mentioned embodiment method, which will not be repeated here.

[0095] In one embodiment, the determination module 20 is further used to obtain the total number of free pages and the number of reserved pages according to the memory data; perform subtraction calculation on the total number of free pages and the number of reserved pages to obtain the number of real free pages; obtain the total number of file mapping pages, shared memory data, non-evictable memory data and swap cache data according to the memory data; calculate the target memory sum according to the shared memory data, the non-evictable memory data and the swap cache data; when the total number of file mapping pages is greater than the target memory sum, calculate the number of reclaimable file mapping pages according to the total number of file mapping pages and the target memory sum.

[0096] In one embodiment, the determination module 20 is also used to determine a preset memory water level; compare the number of truly free pages with the preset memory water level; compare the number of reclaimable file mapping pages with the preset memory water level; and identify the current pressure state of the target system based on the free page comparison results and the file mapping page comparison results based on the target pressure state identification algorithm.

[0097] In one embodiment, the optimization module 30 is further used to determine the current operating mode of the target system according to the current pressure state; obtain the current load state of the CPU; and optimize the memory management mechanism according to the current operating mode and the current load state of the CPU.

[0098] In one embodiment, the optimization module 30 is also used to set the configuration parameters of memory recovery to mild recovery parameters when the current operating mode is idle mode; generate a first event trigger signal when the current load state of the CPU is idle state; trigger a memory recovery event through a preset subsystem of the target system kernel according to the set mild recovery parameters and the first event trigger signal, thereby completing the optimization of the memory management mechanism.

[0099] In one embodiment, the optimization module 30 is also used to set the configuration parameters of memory recovery to aggressive recovery parameters when the current operating mode is the stress mode; generate a second event trigger signal when the current load state of the CPU is the idle state; and trigger a memory recovery event through a preset subsystem of the target system kernel according to the set mild recovery parameters and the second event trigger signal to complete the optimization of the memory management mechanism.

[0100] In one embodiment, the optimization module 30 is further used to determine the target pressure state of the target system based on the number of truly free pages and the number of reclaimable file mapping pages at the next moment; determine the target operation mode of the target system based on the target pressure state; when the target operation mode is inconsistent with the current operation mode and the configuration parameter of the memory recovery is an aggressive recovery parameter, set the configuration parameter of the memory recovery to a mild recovery parameter, and continue to execute the step of generating a first event trigger signal when the current load state of the CPU is an idle state.

[0101] The present application provides an optimization device for a memory management mechanism, the optimization device for the memory management mechanism comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the optimization method for the memory management mechanism in the above-mentioned embodiment one.

[0102] Reference below Figure 5, which shows a schematic diagram of the structure of an optimization device suitable for implementing the memory management mechanism of the embodiment of the present application. The optimization device of the memory management mechanism in the embodiment of the present application may include but is not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Descriptions), PMPs (Portable Media Players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 5 The optimization device of the memory management mechanism shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.

[0103] like Figure 5 As shown, the memory management mechanism optimization device may include a processing device 1001 (such as a central processing unit, a graphics processor, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM: Read Only Memory) 1002 or a program loaded from a storage device 1003 to a random access memory (RAM: Random Access Memory) 1004. Various programs and data required for the operation of the memory management mechanism optimization device are also stored in the RAM 1004. The processing device 1001, the ROM 1002, and the RAM 1004 are connected to each other through a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Typically, the following systems may be connected to the I / O interface 1006: input devices 1007 including, for example, a touch screen, a touchpad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; output devices 1008 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; storage devices 1003 including, for example, a magnetic tape, a hard disk, etc.; and communication devices 1009. The communication device 1009 may allow the memory management mechanism optimization device to communicate with other devices wirelessly or by wire to exchange data. Although the figure shows the memory management mechanism optimization device with various systems, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems may be implemented or have instead.

[0104] In particular, according to the embodiments disclosed in the present application, the process described above with reference to the flowchart can be implemented as a computer software program. The computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through a communication device, or installed from the storage device 1003, or installed from the ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment disclosed in the present application are executed.

[0105] The memory management mechanism optimization device provided by the present application adopts the memory management mechanism optimization method in the above embodiment, which can solve the technical problems of low accuracy and efficiency of the memory management mechanism optimization in the prior art. Compared with the prior art, the beneficial effects of the memory management mechanism optimization device provided by the present application are the same as the beneficial effects of the memory management mechanism optimization method provided by the above embodiment, and the other technical features in the memory management mechanism optimization device are the same as the features disclosed in the method of the previous embodiment, which will not be repeated here.

[0106] It should be understood that the various parts disclosed in this application can be implemented by hardware, software, firmware or a combination thereof. In the description of the above embodiments, specific features, structures, materials or characteristics can be combined in any one or more embodiments or examples in a suitable manner.

[0107] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

[0108] The present application provides a computer-readable storage medium having computer-readable program instructions (ie, computer programs) stored thereon, wherein the computer-readable program instructions are used to execute the optimization method of the memory management mechanism in the above-mentioned embodiment.

[0109] The computer-readable storage medium provided in the present application may be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, systems or devices, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM: Erasable Programmable Read Only Memory or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM: CD-ReadOnly Memory), an optical storage device, a magnetic storage device, or any suitable combination thereof. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, system or device. The program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination thereof.

[0110] The computer-readable storage medium may be included in the optimization device of the memory management mechanism; or may exist independently without being assembled into the optimization device of the memory management mechanism.

[0111] Computer program code for performing the operations of the present application may be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, C++, and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0112] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system and method according to various embodiments of the present application. In this regard, each box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the box can also occur in a sequence different from that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flow chart, and the combination of the boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0113] The modules involved in the embodiments described in this application may be implemented by software or hardware, wherein the name of the module does not constitute a limitation on the unit itself in some cases.

[0114] The readable storage medium provided by the present application is a computer-readable storage medium, which stores computer-readable program instructions (i.e., computer programs) for executing the above-mentioned method for optimizing the memory management mechanism, and can solve the technical problems of low accuracy and efficiency of optimizing the memory management mechanism in the prior art. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided by the present application are the same as the beneficial effects of the method for optimizing the memory management mechanism provided by the above-mentioned embodiment, and will not be elaborated here.

[0115] The above descriptions are only some embodiments of the present application, and are not intended to limit the patent scope of the present application. All equivalent structural changes made using the contents of the present application specification and drawings under the technical concept of the present application, or direct / indirect applications in other related technical fields are included in the patent protection scope of the present application.

Claims

1. A method for optimizing a memory management mechanism, characterized in that: The method comprises: Obtain memory data of the target system in the extended reality application scenario; Determine the number of truly free pages and the number of reclaimable file mapping pages according to the memory data; Determine the current pressure state of the target system according to the number of truly free pages and the number of reclaimable file mapping pages; The memory management mechanism is optimized according to the current pressure state and the current load state of the CPU.

2. The method according to claim 1, characterized in that The step of calculating the number of truly free pages and the number of reclaimable file mapping pages according to the memory data comprises: Obtaining the total number of free pages and the number of reserved pages according to the memory data; Subtract the total number of free pages from the number of reserved pages to obtain the number of real free pages; According to the memory data, the total number of file mapping pages, shared memory data, non-eviction memory data and swap cache data are obtained; Calculate a target memory sum according to the shared memory data, the non-evictable memory data and the swap cache data; When the total number of file mapping pages is greater than the target memory sum, the number of reclaimable file mapping pages is calculated according to the total number of file mapping pages and the target memory sum.

3. The method according to claim 1, characterized in that The step of determining the current pressure state of the target system according to the number of truly free pages and the number of reclaimable file mapping pages comprises: Determine the preset memory watermark; Compare the number of truly free pages with the preset memory watermark; Compare the number of recyclable file mapping pages with the preset memory watermark; Based on the target pressure state identification algorithm, the current pressure state of the target system is identified according to the free page comparison result and the file mapping page comparison result.

4. The method according to claim 1, characterized in that The step of optimizing the memory management mechanism according to the current pressure state and the current load state of the CPU includes: determining a current operating mode of the target system according to the current pressure state; Get the current load status of the CPU; The memory management mechanism is optimized according to the current operation mode and the current load state of the CPU.

5. The method according to claim 4, characterized in that The step of optimizing the memory management mechanism according to the current operating mode and the current load state of the CPU comprises: When the current operating mode is an idle mode, setting a configuration parameter of memory recycling to a gentle recycling parameter; When the current load state of the CPU is an idle state, generating a first event trigger signal; The preset subsystem of the target system kernel triggers a memory recycling event according to the set mild recycling parameters and the first event trigger signal, thereby completing the optimization of the memory management mechanism.

6. The method according to claim 4, characterized in that The step of optimizing the memory management mechanism according to the current operating mode and the current load state of the CPU comprises: When the current operation mode is the pressure mode, setting the configuration parameter of memory recycling to an aggressive recycling parameter; When the current load state of the CPU is an idle state, generating a second event trigger signal; The preset subsystem of the target system kernel triggers a memory recycling event according to the set mild recycling parameter and the second event trigger signal, thereby completing the optimization of the memory management mechanism.

7. The method according to any one of claims 1 to 6, characterized in that After the step of optimizing the memory management mechanism according to the current pressure state and the current load state of the CPU, the method further includes: Determine the target pressure state of the target system according to the number of truly free pages and the number of reclaimable file mapping pages at the next moment; determining a target operating mode of a target system according to the target pressure state; When the target operating mode is inconsistent with the current operating mode and the configuration parameter of the memory recycling is an aggressive recycling parameter, the configuration parameter of the memory recycling is set to a mild recycling parameter, and the step of generating a first event trigger signal when the current load state of the CPU is an idle state is continued.

8. A device for optimizing a memory management mechanism, characterized in that: The device comprises: An acquisition module is used to obtain the memory data of the target system in the extended reality application scenario; A determination module, used to determine the number of truly free pages and the number of reclaimable file mapping pages according to the memory data; The determination module is further used to determine the current pressure state of the target system according to the number of truly free pages and the number of reclaimable file mapping pages; The optimization module is used to optimize the memory management mechanism according to the current pressure state and the current load state of the CPU.

9. A device for optimizing a memory management mechanism, characterized in that: The device comprises: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the method for optimizing the memory management mechanism according to any one of claims 1 to 7.

10. A storage medium, characterized in that: The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the method for optimizing the memory management mechanism according to any one of claims 1 to 7 are implemented.