Memory management method and device, electronic equipment and storage medium
By dividing the memory pages of system services into memory groups and managing them according to the memory swap strategy of each system service, the problem of lack of targeted memory swap management in the existing technology is solved, and higher management accuracy is achieved.
Patent Information
- Application Number
- CN202311109637.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-30
- Publication Date
- 2025-02-28
AI Technical Summary
When performing memory swap management, the prior art lacks targetedness and cannot accurately manage the memory pages of system services, resulting in poor management flexibility.
By dividing the memory pages corresponding to each system service currently running into the corresponding memory groups, the memory group corresponding to each system service is obtained, and based on the memory swap strategy corresponding to the memory group of each system service, the memory pages in the memory group of each system service are managed.
It realizes targeted memory exchange management of memory pages of each system service, improving the accuracy of memory exchange management.
Smart Images

Figure CN119536968A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of electronic devices, and more specifically, to a memory management method, device, electronic device and storage medium. Background Art
[0002] With the rapid advancement of science and technology and living standards, electronic devices (such as smart phones, tablet computers, etc.) have become one of the commonly used electronic products in people's lives. In electronic devices, memory is one of the important components. It is a bridge for communication with the central processing unit (CPU). Since the capacity of memory is limited, it is usually necessary to manage the memory. In related technologies, memory swapping mechanisms are usually used to manage memory to increase available memory. However, the flexibility of memory swapping management in related technologies is poor, and it is impossible to accurately perform memory swapping management on the memory pages of system services. Summary of the invention
[0003] The present application proposes a memory management method, device, electronic device and storage medium, which can realize targeted memory swap management of memory pages of system services and improve the accuracy of memory swap management.
[0004] In a first aspect, an embodiment of the present application provides a memory management method, the method comprising: dividing the memory pages corresponding to each currently running system service into corresponding memory groups to obtain the memory groups corresponding to each system service; and performing memory swap management on the memory pages in the memory group of each system service based on the memory swap policy corresponding to the memory group of each system service.
[0005] In a second aspect, an embodiment of the present application provides a memory management device, comprising: the memory grouping module is used to divide the memory pages corresponding to each currently running system service into corresponding memory groups to obtain the memory groups corresponding to each system service; the memory swap module is used to perform memory swap management on the memory pages in the memory group of each system service based on the memory swap policy corresponding to the memory group of each system service.
[0006] In a third aspect, an embodiment of the present application provides an electronic device, comprising: one or more processors; a memory; one or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the one or more processors, and the one or more applications are configured to execute the memory management method provided in the first aspect above.
[0007] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, in which a program code is stored. The program code can be called by a processor to execute the memory management method provided in the first aspect above.
[0008] The solution provided by the present application obtains a memory group corresponding to each system service by dividing the memory pages corresponding to each currently running system service into a corresponding memory group, and performs memory swap management on the memory pages in the memory group of each system service based on the memory swap policy corresponding to the memory group of each system service, thereby achieving targeted memory swap management of the memory pages of each system service and improving the accuracy of memory swap management. BRIEF DESCRIPTION OF THE DRAWINGS
[0009] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.
[0010] Figure 1 A schematic flow chart of a memory management method according to an embodiment of the present application is shown.
[0011] Figure 2 A schematic flow chart of a memory management method according to another embodiment of the present application is shown.
[0012] Figure 3 A schematic flow chart of a memory management method according to another embodiment of the present application is shown.
[0013] Figure 4 A flowchart of a memory management method according to another embodiment of the present application is shown.
[0014] Figure 5 A schematic flow chart of a memory management method according to yet another embodiment of the present application is shown.
[0015] Figure 6 A block diagram of a memory management device according to an embodiment of the present application is shown.
[0016] Figure 7 It is a block diagram of an electronic device according to an embodiment of the present application for executing the memory management method according to an embodiment of the present application.
[0017] Figure 8 It is a storage unit of an embodiment of the present application for storing or carrying program codes for implementing the memory management method according to an embodiment of the present application. DETAILED DESCRIPTION
[0018] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application.
[0019] Memory (also known as random access memory, RAM) refers to the memory used when running a program (i.e., running memory). It can only store data temporarily and is used to exchange cache data with the processor, but the memory itself cannot be used to store data for a long time. When an electronic device is running, the CPU will transfer the data that needs to be calculated to the memory for calculation. When the calculation is completed, the CPU will transmit the result. The operation of the memory also determines the stable operation of the electronic device. Since the physical memory of an electronic device is limited, and the use of memory by a process is uncertain, there is always a possibility that the physical memory will run out. In response to the situation where memory resources are tight, electronic devices usually manage memory through memory swapping.
[0020] Among them, in Android or other Linux-based systems, memory swap is a traditional memory management strategy that allows the operating system to "swap out" the data in the memory to the hard disk, compress it to other memory areas, flash memory and other storage media to free up memory space for other processes. When the "swapped out" data is needed again, the operating system will "swap it back" from the above storage media to the memory, but if the above storage medium is a physical disk, due to the access rate limit of the physical disk (the current mainstream disk read and write rate is usually at the level of hundreds of megabytes / second), the whole process is very time-consuming. During this process, users may feel that the system is abnormally slow.
[0021] The following is an introduction to the technical terms involved in memory swapping in related technologies.
[0022] Swap Space: It is a special hard disk partition, which is used by the system as Swap storage space. The size of Swap Space is usually set by the system administrator when the system is installed or configured, and is usually determined based on the system's RAM size and application requirements.
[0023] Swapiness: is a system parameter that controls the system's reliance on Swap. The Swapiness value ranges from 0 to 100. A higher value indicates that the system is more inclined to swap out data to Swap Space, while a lower value indicates that the system is more inclined to keep data in memory as much as possible.
[0024] Page Replacement Algorithm: Swap management in Linux systems is mainly based on a page replacement algorithm called "Least Recently Used" (LRU). Simply put, the LRU algorithm records the last time each memory page was accessed. When a swap is needed, the system will choose to swap out the page that has not been accessed for the longest time, because such a page is least likely to be needed again in the near future.
[0025] Swap In and Swap Out: When the system memory is insufficient, the operating system will trigger Swap Out to swap out the selected memory page to Swap Space. When a swapped-out page is needed again, the system will trigger Swap In to swap the page from Swap Space back to the memory.
[0026] In the related art, when performing memory swap management, all memory pages are usually managed according to a fixed memory swap strategy. In this way, all memory pages of system services will be determined according to the same strategy to determine the pages to be swapped out, which will cause some important system service memory pages to be swapped out, affecting the running speed. For example, when using the LRU algorithm to determine the memory pages to be swapped out, if a process of an important system service (such as Bluetooth communication service, mobile network communication service) has not been accessed for the longest time, then swapping out the process will affect the operation of the system service, and further affect the user's use of the electronic device.
[0027] In view of the above problems, the inventors have proposed a memory management method, device, electronic device and storage medium provided in the embodiments of the present application, which can realize targeted memory swap management of memory pages of each system service, thereby improving the accuracy of memory swap management. The specific memory management method will be described in detail in the subsequent embodiments.
[0028] The memory management method provided in the embodiment of the present application is described in detail below with reference to the accompanying drawings.
[0029] See also Figure 1 , Figure 1 FIG. 1 is a flow chart of a memory management method provided by an embodiment of the present application. In a specific embodiment, the memory management method is applied to Figure 6 The memory management device 600 and the electronic device 100 ( Figure 7). The following will take an electronic device as an example to illustrate the specific process of this embodiment. Of course, it can be understood that the electronic device used in this embodiment can be a smart phone, a tablet computer, a smart watch, an e-book, etc., which is not limited here. Figure 1 The process shown is described in detail, and the memory management method may specifically include the following steps:
[0030] Step S110: Divide the memory pages corresponding to each currently running system service into corresponding memory groups to obtain the memory groups corresponding to each system service.
[0031] In an embodiment of the present application, when the electronic device manages the memory, for each currently running system service, the memory page corresponding to each system service can be divided into a corresponding memory group, and the memory group corresponding to each system service can be obtained, so as to perform corresponding memory exchange management for the memory pages in each memory group, thereby realizing targeted memory exchange management for the memory pages of each system service. Among them, system services refer to programs, routines or processes that perform specified system functions in order to support other programs, especially underlying programs. For example, system services include camera services, multimedia services, Bluetooth communication services, mobile network communication services, application lifecycle management services, etc.; there is a fundamental difference between system services and ordinary applications. System services can run without user login and when the user has logged out, while the application will be terminated when the user has not logged out. It is understandable that system services need to occupy memory to store data during operation when they are running. The size of memory space occupied by different system services in different running states is not necessarily the same; memory page is the unit of memory management by the operating system. The unit memory size occupied by a memory page may not be limited. The unit memory size occupied by memory pages set by different electronic devices may be different. System services running in electronic devices can occupy multiple memory pages in memory, and the size of the memory space they occupy corresponds to the size occupied by all corresponding memory pages. Among them, memory pages can include anonymous pages, file pages, etc., which are not limited here; anonymous pages refer to pages without file background, such as heaps, stacks, data segments, etc.; file pages refer to pages with file backgrounds, which are caches generated in memory after the program reads files. File pages are also called file caches.
[0032] In some implementations, the electronic device divides the memory pages corresponding to each currently running system service into the corresponding memory group, which may be to create a memory group corresponding to each running system service, and then divide the memory pages corresponding to each system service into the created memory group. Optionally, the memcg grouping mechanism in the Linux system may be used as the implementation carrier of the memory group.
[0033] In some implementations, the electronic device may, when a system service is running, divide the memory pages corresponding to each currently running system service into corresponding memory groups to obtain a memory group corresponding to each system service. That is, as long as there is a running system service, the memory pages corresponding to the system service will be grouped to obtain a memory group corresponding to each system service.
[0034] In a possible implementation, when system services are running, after the memory pages corresponding to each running system service are grouped, if there is a new running system service, the corresponding memory pages of the new running system service can be divided into corresponding memory groups.
[0035] In some embodiments, considering that when an electronic device performs memory exchange management on memory, it is mainly when there is insufficient memory (for example, the remaining memory is less than the set memory threshold, the memory requirements of the current process cannot be met, and memory space cannot be allocated for the new process, etc.), the memory pages that need to be swapped out will be selected and swapped out to other storage areas. Therefore, it is possible to predict whether the electronic device will perform memory exchange management after the target duration. According to the prediction result, if the prediction result indicates that memory exchange management will be performed after the target duration, the memory pages corresponding to each currently running system service can be divided into corresponding memory groups at the current moment. Among them, the specific value of the target duration may not be limited, for example, it may be 3 minutes, 5 minutes, 10 minutes, etc. In this way, it is possible to group the memory pages corresponding to each running system service before the predicted electronic device performs memory exchange management, so that before performing memory exchange management, the memory pages in the memory group can be performed according to the memory exchange strategy of each memory group. Memory exchange management is then performed on the memory pages corresponding to each system service in a targeted manner. The electronic device may predict whether the electronic device will perform memory swap management after a target time period at every first interval time period, and the first interval time period may be 30 seconds, 1 minute, 3 minutes, etc.
[0036] In one possible implementation, a pre-trained memory swap prediction model is stored in the electronic device. The memory swap prediction model may be pre-trained based on historical device information collected at different times. The historical device information is device information collected by the electronic device during historical operation, and the historical device information is marked with a corresponding memory swap tag. The historical device information may include: historical moment, total memory size, remaining memory size at the historical moment, running applications at the historical moment, and other information related to the current state of the electronic device at the historical moment. The memory swap tag is used to characterize whether the electronic device performs memory swap management after the target duration at the historical moment. Among them, the memory swap prediction model may be a support vector machine (SVM), a neural network, a naive Bayes classifier, etc., and the specific model type of the memory swap prediction model may not be limited.
[0037] In the above implementation, when the electronic device needs to predict whether memory swap management will be performed after a target duration, it can obtain current device information, i.e., the current time, total memory size, remaining memory size of the electronic device at the current time, applications running at the current time, and other information, and then input the current device information into the above memory swap prediction model to obtain a prediction result. Based on the prediction result, it can be determined whether the electronic device will perform memory swap management after the target duration.
[0038] Optionally, the prediction result may be a classification result of whether the electronic device will perform memory exchange management after a target duration, and the classification result includes two categories: performing memory exchange management and not performing memory exchange management. Therefore, the classification result may directly indicate whether the electronic device will perform memory exchange management after the target duration. The prediction result may also be a probability value representing whether the electronic device will perform memory exchange management after the target duration. The probability value is positively correlated with the possibility that the electronic device will perform memory exchange management after the target duration. That is, the larger the probability value, the greater the possibility that the electronic device will perform memory exchange management after the target duration. The smaller the collision probability value, the smaller the possibility that the electronic device will perform memory exchange management after the target duration. Therefore, based on the prediction result, it may also be determined whether the electronic device will perform memory exchange management after the target duration.
[0039] Optionally, the above memory exchange prediction model can be trained in the following way: obtain the historical device information of the electronic device at different historical moments in the historical operation process, and obtain the record of whether the memory exchange management is performed after the target time of each historical moment. According to the obtained record, the above memory exchange label can be marked for the historical device information at each historical moment, thereby obtaining a sample data set; when the memory exchange prediction model is obtained by training based on the sample data set, the historical device information can be input into the initial prediction model to obtain the prediction result output by the initial prediction model for the input historical device information, and the target loss value of the initial prediction model can be determined according to the prediction result and the memory exchange label marked by the historical device information; after determining the target loss value corresponding to the initial detection model, the initial prediction model can be iteratively trained according to the target loss value to obtain the final memory exchange prediction model. Among them, the initial prediction model can be a neural network, a Softmax logistic regression model, a support vector machine, etc., and the specific initial prediction model can be not limited; when determining the target loss value, the loss value can be determined according to the difference between the prediction result and the memory exchange label marked by the historical device information.
[0040] When the initial prediction model is iteratively trained according to the target loss value, the model parameters of the initial prediction model can be adjusted according to the calculated target loss value; the historical device information is repeatedly input into the initial prediction model to obtain the prediction result output by the memory swap prediction model for the input historical device information, and based on the prediction result and the memory swap label marked by the historical device information, the target loss value corresponding to the initial prediction model can be determined, and the model parameters of the initial prediction model can be adjusted according to the target loss value until the training end condition is met to obtain the trained memory swap prediction model. The training end condition of iterative training can include: the number of iterative training reaches the target number; or the total loss value of the initial prediction model meets the set condition.
[0041] In the above implementation, if it is determined that the electronic device does not perform memory swap management after the target duration at the current moment, the memory pages of the running applications may not be grouped, that is, the memory pages of each application are not divided into corresponding memory groups, thereby reducing the consumption of processing resources of the electronic device.
[0042] Step S120: performing memory swap management on memory pages in the memory group of each system service based on the memory swap policy corresponding to the memory group of each system service.
[0043] In an embodiment of the present application, after the memory pages corresponding to each running system service are divided into corresponding memory groups and the memory groups corresponding to each system service are obtained, the memory pages in the memory groups of each system service can be managed by memory swapping based on the memory swapping policy corresponding to the memory groups of each system service. The memory swapping policy corresponding to the memory groups of each system service can be determined based on the memory usage requirements of each system service during operation and the importance of the system service, wherein the memory usage requirements may include memory access speed, memory access frequency, etc. The importance of the system service can be predetermined (for example, determined based on user operations) or determined based on the number of times the application is run and the running frequency. For example, if the system service requires a high memory access speed and frequent memory access during runtime, its memory swap policy can be determined as a policy that does not perform memory swapping, that is, when the electronic device performs memory swapping management, it will not determine the memory pages that need to be swapped out from the memory group of the system service; for another example, if the system service requires a low memory access speed and low memory access frequency during runtime, its memory swap policy can be determined as a swapping policy corresponding to a First Input First Output (FIFO) algorithm, that is, when the electronic device performs memory swapping management, it determines the memory page that first enters the cache from the memory group of the system service as the memory page that needs to be swapped out.
[0044] In some embodiments, when the electronic device performs memory swap management on the memory pages in the memory group of each system service based on the memory swap policy corresponding to the memory group of each system service, it may be performed when the triggering conditions for performing memory swap management are met (for example, the remaining memory is less than the set memory threshold, the memory requirements of the current process cannot be met, or memory space cannot be allocated for the new process, etc.). In other words, when the electronic device needs to perform memory swap management on the memory, it can determine whether the memory pages in the memory group need to be swapped out, and the memory pages to be swapped out if the memory pages need to be swapped out, based on the memory swap policy corresponding to the memory group of each system service. For example, the memory swap policy corresponding to the memory group of system service A is the swap policy corresponding to LRU. Then, according to the LRU algorithm, the memory page that has not been accessed for the longest time can be determined from the memory group of system service A, and the memory page can be used as the memory page to be swapped out, and the data in the memory page to be swapped out can be swapped out to the corresponding swap area. For another example, the memory swap policy corresponding to the memory group of system service B is the swap policy corresponding to the FIFO algorithm. Then, according to the FIFO algorithm, the memory page that first enters the cache can be determined from the memory group of system service A, and the memory page can be used as the memory page to be swapped out, and the data in the memory page to be swapped out can be swapped out to the corresponding swap area.
[0045] In some embodiments, the memory exchange strategy corresponding to each of the above memory groups can also be determined by the electronic device according to a pre-trained strategy recognition model. Among them, the strategy recognition model can be pre-trained according to the service information of different system services, and the service information can be the memory access frequency of the system service at runtime, the type of process created by the system service at runtime, the number of processes created by the system service at runtime, the memory size occupied by the system service at runtime, and the service information is marked with a strategy label corresponding to the memory exchange strategy. Among them, the strategy recognition model can be a neural network, a naive Bayes classifier, etc., and of course, the specific model type of the strategy recognition model can be unlimited. When determining the memory exchange strategy corresponding to the memory group of the system service, the electronic device can obtain the service information of the system service, and then input the service information into the above strategy recognition model, and obtain the recognition result output by the strategy recognition model. According to the recognition result, the memory exchange strategy can be determined and used as the memory exchange strategy corresponding to the memory group of the system service. It can be understood that the above service information usually affects the memory usage requirements of the system service, and when the memory usage requirements are different, the memory exchange strategy to be used may also be different, so the memory exchange strategy can be identified according to the service information of the above system service.
[0046] In a possible implementation, the mapping relationship between multiple sample system services and memory exchange strategies can be obtained in advance. The mapping relationship can be set by the developer for each sample system service according to the memory usage requirements of the multiple sample system services; then the service information of each sample system service is obtained, and the corresponding strategy label is marked for the service information of each sample system service according to the above mapping relationship; when the strategy recognition model is trained, the service information of the sample system service can be input into the initial recognition model to obtain the recognition result output by the initial recognition model for the input service information, and the loss value of the initial recognition model can be determined according to the recognition result and the strategy label marked by the service information; after the loss value corresponding to the initial recognition model is determined, the initial recognition model can be iteratively trained according to the loss value to obtain the final strategy recognition model. Wherein, when determining the above loss value, the loss value can be determined according to the difference between the recognition result and the strategy label marked by the above service information.
[0047] The memory management method provided in the embodiment of the present application obtains the memory group corresponding to each system service by dividing the memory pages corresponding to each currently running system service into the corresponding memory group, and performs memory swap management on the memory pages in the memory group of each system service based on the memory swap policy corresponding to the memory group of each system service, thereby realizing targeted memory swap management on the memory pages of each system service and improving the accuracy of memory swap management.
[0048] See also Figure 2 , Figure 2 A flow chart of a memory management method provided by another embodiment of the present application is shown. The memory management method is applied to the above electronic device. Figure 2 The process shown is described in detail, and the memory management method may specifically include the following steps:
[0049] Step S210: Based on the process of each currently running system service, determine the memory page corresponding to each system service.
[0050] In an embodiment of the present application, when the electronic device divides the memory pages corresponding to each running system service into corresponding memory groups, it can determine the memory pages corresponding to each system service based on the process of each system service.
[0051] In some implementations, the process created by each of the above system services at runtime can be queried to obtain the process of each system service, and then the memory page corresponding to the process of each system service is determined as the memory page corresponding to each system service.
[0052] In some embodiments, it is considered that some processes may belong to multiple system services, that is, some system services may share some processes during operation. For example, system service A and system service B share process 1, and process 1 belongs to both system service A and system service B. Then, when dividing the memory pages of these system services, it is impossible to determine the memory group to which the memory pages corresponding to the shared processes belong. Therefore, after determining the process of each system service, the first process belonging to multiple system services can be determined based on the process of each system service, and then the first process can be filtered out from the process of each system service to obtain the second process of each system service (that is, the process remaining after filtering out the first process from the process of each system service), and then the memory page corresponding to the second process of each system service is determined as the memory page corresponding to each system service.
[0053] Step S220: Divide the memory pages corresponding to each system service into corresponding memory groups to obtain the memory groups corresponding to each system service.
[0054] In an embodiment of the present application, after determining the memory page corresponding to each system service, the memory page corresponding to each system service can be divided into the corresponding memory group to obtain the memory group corresponding to each system service. Among them, for each system service running, a memory group corresponding to each system service can be created, and then the memory page corresponding to each system service can be divided into the created memory group. Optionally, the memcg grouping mechanism in the Linux system can be used as the implementation carrier of the memory group.
[0055] In some embodiments, if the above first process (i.e., a process belonging to multiple system services) is filtered out from the memory page corresponding to each system service determined above, then for the above first process, the multiple system services to which each first process belongs can be determined; for each first process, the target system service is determined from the multiple system services to which it belongs, and then the first process is divided into the memory group of the target system service.
[0056] Among them, the target system service can be the system service with the highest priority among the multiple system services to which the first process belongs. The priority of the system service can be divided according to the importance of the system service and the demand for memory use, and the priority of the system service can be positively correlated with the importance of the system service and the demand for memory use, that is, the higher the priority of the system service, the higher the importance of the system service and the higher the demand for memory use; the memory exchange policy corresponding to the memory group of each system service can be determined based on the priority of the system service (for example, the memory exchange policy is determined based on the priority of the system service in subsequent embodiments). For example, the higher the priority of the system service, the higher the accuracy of the memory exchange policy corresponding to its memory group in determining the memory page to be swapped out. Therefore, based on the above implementation, it can be achieved that for the memory pages corresponding to the processes that belong to multiple system services at the same time, memory exchange management can be performed more accurately.
[0057] In some embodiments, if the above determined memory pages corresponding to each system service filter out the above first process (i.e., the process belonging to multiple system services), then for the above first process, a memory group corresponding to the first process may be created for all first processes separately, and the memory pages corresponding to these first processes may be divided into the memory group, and then the memory pages in the memory group may be managed by memory exchange through the memory exchange policy corresponding to the memory group. Among them, considering that the first process belongs to multiple system services at the same time, the memory pages corresponding to these processes are of high importance, and if they are swapped out of memory, it is likely to affect the operation of these system services, so the memory exchange policy corresponding to the memory group corresponding to the first process may be determined as a policy of not performing memory exchange, that is, when the electronic device performs memory exchange management, the memory pages in the memory group will not be swapped out from the memory.
[0058] Step S230: Based on the memory swap policy corresponding to the memory group of each system service, memory swap management is performed on the memory pages in the memory group of each system service.
[0059] In the embodiment of the present application, step S230 can refer to the contents of other embodiments and will not be repeated here.
[0060] The memory management method provided in the embodiment of the present application determines the memory pages corresponding to each system service based on the process of each running system service, and then divides the memory pages corresponding to each currently running system service into corresponding memory groups to obtain the memory groups corresponding to each system service, and performs memory swap management on the memory pages in the memory group of each system service based on the memory swap policy corresponding to the memory group of each system service, thereby realizing targeted memory swap management of the memory pages of each system service and improving the accuracy of memory swap management.
[0061] See also Figure 3 , Figure 3 A flowchart of a memory management method provided by another embodiment of the present application is shown. The memory management method is applied to the above electronic device. Figure 3 The process shown is described in detail, and the memory management method may specifically include the following steps:
[0062] Step S310: Divide the memory pages corresponding to each currently running system service into corresponding memory groups to obtain the memory groups corresponding to each system service.
[0063] In the embodiment of the present application, step S310 may refer to the contents of other embodiments and will not be described in detail here.
[0064] Step S320: determining a memory swap policy corresponding to the memory group of each system service based on the target priority corresponding to each system service, wherein the memory swap policies corresponding to the memory groups of system services with different priorities are different.
[0065] In an embodiment of the present application, different priorities can be divided for different system services, and the priorities corresponding to different system services can be obtained. The priorities corresponding to system services can be divided according to at least one of the system service's memory usage requirements and the importance of the system service, wherein, if the priorities of system services are divided according to the system service's memory usage requirements, the memory usage requirements of system services of the same priority are matched, and the level of the system service's memory usage requirements is positively correlated with the priority of the system service, that is, the higher the system service's memory usage requirements, the higher the priority of the system service; if the priorities of system services are divided according to the importance of the system services, the importance of system services of the same priority are matched, and the importance of the system services is positively correlated with the priority of the system services, that is, the higher the importance of the system services, the higher the priority of the system services; if the priorities of system services are divided according to the system service's memory usage requirements and the importance of the system services, the memory usage requirements of system services of the same priority and the importance of the system services are matched, and the level of the system service's memory usage requirements is positively correlated with the priority of the system services, that is, the higher the system service's memory usage requirements and the importance of the system services, the higher the priority of the system services. Since the priority level corresponding to the system service is divided according to at least one of the system service's memory usage requirements and the system service's importance, when determining the memory swap strategy corresponding to the memory group of each system service, the memory swap strategy corresponding to the memory group of each system service can be determined based on the target priority level corresponding to each system service, and the memory swap strategies corresponding to the memory groups of system services with different priorities are different.
[0066] In some embodiments, a mapping relationship between different priorities and memory exchange strategies may be pre-stored in the electronic device, and the mapping relationship is determined based on the memory usage requirements of system services of different priorities and the importance of the system services. If the priorities are divided based on the memory usage requirements, the mapping relationship is determined based on the memory usage requirements of the system services; if the priorities are divided based on the importance of the system services, the mapping relationship is determined based on the importance of the system services; if the priorities are divided based on the memory usage requirements and the importance of the system services, the mapping relationship is determined based on the memory usage requirements and the importance of the system services. For example, the priorities corresponding to system services include priority 1, priority 2, and priority 3 in descending order, and the priorities are determined according to the importance of the system services. The higher the priority, the higher the importance of the system services. For priority 1, a policy of not performing memory swapping can be set, that is, when the memory pages in the memory group of the system service corresponding to priority 1 are managed by memory swapping using this policy, the memory pages in the memory group will not be swapped out. For priority 2, a policy corresponding to the LRU algorithm can be set to keep the most recently used data in the memory. For priority 3, a swapping policy corresponding to the FIFO algorithm can be set to reduce the processing resources occupied by memory swapping management. In the above implementation, when determining the memory swapping policy corresponding to the memory group of each system service based on the target priority corresponding to each system service, the memory swapping policy corresponding to the target priority can be determined based on the above mapping relationship, and used as the memory swapping policy corresponding to the memory group of the system service.
[0067] In some embodiments, the above priorities are positively correlated with the memory usage requirements of the system service and the importance of the system service. When determining the memory swap strategy corresponding to the memory group of each system service based on the target priority corresponding to each system service, it is possible to determine for each system service whether the target priority is the first priority (i.e., the highest priority). If the target priority corresponding to the system service is the first priority, then the memory swap strategy corresponding to the memory group of the system service is determined to be the first strategy of not swapping out memory; if the target priority corresponding to the system service is not the first priority, then the target swap algorithm corresponding to the target priority is determined from a plurality of page swap algorithms, and the memory swap strategy corresponding to the target swap algorithm is used as the memory swap strategy corresponding to the memory group of the system service. That is to say, for the system service corresponding to the highest priority, the system service has the highest memory usage demand and the highest importance. Therefore, the memory pages in the memory group of the system service corresponding to this priority may not be swapped out to avoid affecting the operation of the system service. For system services corresponding to other priorities other than the highest priority, the corresponding page swapping algorithm may be used for memory swapping management, wherein the various page swapping algorithms may be an LRU algorithm, a FIFO algorithm, a clock page replacement algorithm, a least frequently used replacement (LFU) algorithm, etc. For system services of other priorities other than the highest priority, the accuracy of swapping out pages may be determined according to various page algorithms, and corresponding page swapping algorithms may be set for system services of each other priority, wherein, for other priorities except the first priority, the higher the priority, the higher the accuracy of the corresponding page swapping algorithm in determining the swapped out pages.
[0068] In a possible implementation, the priorities corresponding to system services can be divided into first priority, second priority and third priority, where the first priority is the highest priority, the second priority is lower than the first priority, and the third priority is lower than the second priority; multiple page interaction algorithms may include LRU algorithm and FIFO algorithm. It can be understood that the priority level corresponding to the system service is divided according to at least one of the system service's memory usage requirements and the system service's importance. Therefore, the system service corresponding to the first priority level has the highest memory usage requirements and the highest importance of the system service. The system service corresponding to the second priority level has the second highest memory usage requirements and the highest importance of the system service. The system service corresponding to the third priority level has the lowest memory usage requirements and the lowest importance of the system service. Therefore, when determining the memory swap strategy for the memory group of each system service, if the target priority level corresponding to the system service is the second priority level, since the LRU algorithm has a high accuracy in determining the memory pages that need to be swapped out, the LRU algorithm can be determined from a variety of page swap algorithms, and the second strategy corresponding to the LRU algorithm is used as the memory swap strategy corresponding to the memory group of the system service; if the target priority level corresponding to the system service is the third priority level, since the FIFO algorithm consumes less processing resources when determining the memory pages to be swapped out, the FIFO algorithm can be determined from a variety of page swap algorithms, and the third strategy corresponding to the FIFO algorithm is used as the memory swap strategy corresponding to the memory group of the system service.
[0069] Step S330: Based on the memory swap policy corresponding to the memory group of each system service, memory swap management is performed on the memory pages in the memory group of each system service.
[0070] In the embodiment of the present application, step S330 can refer to the contents of other embodiments and will not be repeated here.
[0071] The memory management method provided in the embodiment of the present application obtains the memory group corresponding to each system service by dividing the memory pages corresponding to each currently running system service into the corresponding memory group, and then determines the memory swap strategy corresponding to the memory group of each system service according to the priority corresponding to each system service, and then performs memory swap management on the memory pages in the memory group of each system service according to the determined memory swap strategy, thereby realizing targeted memory swap management of the memory pages of each system service and improving the accuracy of memory swap management.
[0072] See also Figure 4 , Figure 4 A schematic diagram of a memory management method provided by another embodiment of the present application is shown. The memory management method is applied to the above electronic device. Figure 4The process shown is described in detail, and the memory management method may specifically include the following steps:
[0073] Step S410: Divide the memory pages corresponding to each currently running system service into corresponding memory groups to obtain the memory groups corresponding to each system service.
[0074] In the embodiment of the present application, step S410 can refer to the contents of other embodiments and will not be repeated here.
[0075] Step S420: If it is determined that a target memory page in the target memory group needs to be swapped out based on the memory swap policy corresponding to the target memory group served by the target system, the target memory page is swapped out to a target storage area corresponding to the target memory group.
[0076] In an embodiment of the present application, when memory exchange management is performed on the memory pages in the memory group of each system service based on the memory exchange policy corresponding to the memory group of each system service, for the target memory group of the target system service, based on the memory exchange policy corresponding to the target memory group, it is determined that the target memory page in the target memory group needs to be swapped out, and the target memory page can be swapped out to the target storage area corresponding to the target memory group. Wherein, the target system service is any running system service. For example, the memory exchange policy corresponding to the target memory group of the target system service is the policy corresponding to the LRU algorithm. If it is determined that the page that has not been accessed for the longest time in the target memory group is the target memory page, then the target memory page is the memory page that needs to be swapped out; for another example, the memory exchange policy corresponding to the target memory group is the policy corresponding to the FIFO algorithm. If it is determined that the memory page that first enters the cache in the target memory group is the target memory page, then the target memory page is the memory page that needs to be swapped out. Wherein, the target memory area can be a compressed memory area, a flash memory, or an area in a disk. It can be understood that corresponding to different memory groups, the memory pages therein can be set with corresponding swap areas, so that the memory pages in the memory group can be swapped out to the corresponding destination (ie, the target storage area).
[0077] In some embodiments, when it is determined that the target memory page in the target memory group needs to be swapped out, the priority corresponding to the target system service can be determined, and then based on the priority corresponding to the target system service, the corresponding swap area is determined as the target storage area, and the data read and write speeds of the swap areas corresponding to different priorities are different; the target memory page is swapped out to the target storage area. Among them, the division method of the priorities corresponding to different system services can refer to the content of the aforementioned embodiment, which will not be repeated here. Since system services of different priorities have different memory usage requirements and importance, the speeds of swapping out the memory pages they need and swapping the data of the memory pages back to the memory are different, and the swapped out destination will affect the speed of swapping out and swapping back the memory pages, so the correspondence between different priorities and swap areas can be predetermined. For example, the priorities include the first priority, the second priority, and the third priority from high to low, then the swap area corresponding to the first priority can be a compressed memory area, the swap area corresponding to the second priority can be a storage area in the flash memory, and the swap area corresponding to the third priority can be a storage area in the disk.
[0078] The memory management method provided in the embodiment of the present application obtains the memory group corresponding to each system service by dividing the memory pages corresponding to each currently running system service into the corresponding memory group, and performs memory swap management on the memory pages in the memory group of each system service based on the memory swap policy corresponding to the memory group of each system service, thereby realizing targeted memory swap management on the memory pages of each system service and improving the accuracy of memory swap management; in addition, when it is determined that the target memory page in the target memory group of the target system service needs to be swapped out, the target memory page is swapped out to the storage area corresponding to the memory group, thereby realizing that the memory pages in the memory group of each system service can be swapped out to the corresponding destination.
[0079] See also Figure 5 , Figure 5 A schematic diagram of a memory management method provided by another embodiment of the present application is shown. The memory management method is applied to the above electronic device. Figure 5 The process shown is described in detail, and the memory management method may specifically include the following steps:
[0080] Step S510: Obtain current operating status parameters.
[0081] In an embodiment of the present application, the operating status parameters may include the remaining memory size of the electronic device, the number of running system services, the number of running applications, etc. It can be understood that, considering that when the electronic device performs memory swap management on the memory, it is mainly when there is insufficient memory (for example, the remaining memory is less than the set memory threshold, the memory requirements of the current process cannot be met, and memory space cannot be allocated for new processes, etc.), the memory pages that need to be swapped out will be selected and swapped out to other storage areas. Therefore, the current operating status parameters of the electronic device can be obtained, and the situations in which the electronic device may need to perform memory swap management can be determined based on the operating status parameters, and then the memory pages corresponding to the system services are grouped and memory swap management is performed.
[0082] Step S520: If the running status parameter meets the grouping parameter condition, the memory page corresponding to each currently running system service is divided into a corresponding memory group to obtain the memory group corresponding to each system service.
[0083] In an embodiment of the present application, after obtaining the current operating status parameters, it can be determined whether the operating status parameters meet the grouping parameter conditions; if it is determined that the operating status parameters meet the grouping parameter conditions, it means that the electronic device may be about to perform memory exchange management, so the memory pages corresponding to each currently running system service can be divided into corresponding memory groups; if the operating status parameters do not meet the grouping parameter conditions, the memory pages of the system services may not be grouped. Among them, when the operating status parameters meet the grouping parameter conditions, the memory pages corresponding to each system service can be divided into corresponding memory groups for each running system service. In this way, it is possible to group the memory pages of the running application before the electronic device may perform memory exchange management, so that before performing memory exchange management, the memory pages in the memory group can be managed according to the memory exchange policy of each memory group.
[0084] In some implementations, the above operating status parameters may include the remaining memory size, and if the remaining memory size is not greater than the first threshold value and is greater than the second threshold value, it can be determined that the operating status parameters meet the grouping parameter condition. The second threshold value is a threshold value for triggering the electronic device to perform memory swap management, that is, when the remaining memory size is not greater than the second threshold value, the memory swap management will be triggered. In this way, when the remaining memory size is small but the memory swap management is not triggered, the memory pages corresponding to the running system services can be grouped.
[0085] In some implementations, the above running status parameter may include the number of currently running applications. If the number of currently running applications is greater than a first number, it may be determined that the running status parameter meets the grouping parameter condition. The specific value of the first number may not be limited, for example, it may be 8, 10, 12, etc. It can be understood that when the number of currently running applications is greater than the first number, the electronic device is running more applications, and it is very likely that more processes will be added, resulting in insufficient memory. Therefore, in this case, the memory pages corresponding to the running system services may also be grouped.
[0086] In some embodiments, the above operating status parameters may include the number of currently running system services. If the number of currently running system services is greater than the second number, it can be determined that the operating status parameters meet the grouping parameter conditions. The specific value of the second number may not be limited, for example, it may be 3, 5, 8, etc. It can be understood that when the number of currently running system services is greater than the second number, the electronic device runs more system services, and it is very likely that more processes will be added, resulting in insufficient memory. Therefore, in this case, the memory pages corresponding to the running system services can also be grouped. Of course, if the operating status parameters include the number of currently running applications and system services, it can also be determined that the operating status parameters meet the grouping parameter conditions when the sum of the number of running applications and system services is greater than the third number.
[0087] In the above implementation, the electronic device groups the memory pages corresponding to the system services only when its current operating state parameters meet the grouping parameter conditions, that is, the memory group exists only when the operating state parameters meet the grouping parameter conditions. Therefore, when the current operating state parameters do not meet the grouping parameter conditions, there is no memory group, that is, the electronic device manages all existing memory pages in a unified manner, so a preset memory exchange strategy can be used to perform memory exchange management on all existing memory pages.
[0088] Step S530: Based on the memory swap policy corresponding to the memory group of each system service, memory swap management is performed on the memory pages in the memory group of each system service.
[0089] In the embodiment of the present application, step S530 can refer to the contents of the aforementioned embodiment and will not be described again here.
[0090] The memory management method provided in the embodiment of the present application obtains the current device status information of the electronic device. When the device status information meets the memory grouping condition, the memory pages of the application are divided into corresponding memory groups according to the user identifier corresponding to the application, and then the memory pages in the memory group are managed by memory exchange according to the memory exchange policy corresponding to the memory group. This method can not only realize targeted memory exchange management of the memory pages of the application and improve the accuracy of memory exchange management, but also can reduce the consumption of processing resources by eliminating the need to perform memory exchange management for each memory group separately when the device status information does not meet the memory grouping condition.
[0091] The memory management method provided in the embodiment of the present application obtains the current operating status parameters, and only divides the memory pages corresponding to each currently running system service into the corresponding memory group when the operating status parameters meet the grouping parameter conditions, so as to obtain the memory group corresponding to each system service, and then performs memory exchange management on the memory pages in the memory group of each system service based on the memory exchange policy corresponding to the memory group of each system service. This method can not only realize targeted memory exchange management of the memory pages of each system service, thereby improving the accuracy of memory exchange management; but also, when the operating status parameters do not meet the grouping parameter conditions, there is no need to maintain the memory groups of each system service and perform memory exchange management on each memory group separately, thereby reducing the consumption of processing resources.
[0092] See also Figure 6 , which shows a structural block diagram of a memory management device 600 provided in an embodiment of the present application. The memory management device 600 applies the above-mentioned electronic device, and the memory management device 600 includes: a memory grouping module 610 and a memory exchange module 620. Among them, the memory grouping module 610 is used to divide the memory pages corresponding to each currently running system service into corresponding memory groups to obtain the memory groups corresponding to each system service; the memory exchange module 620 is used to perform memory exchange management on the memory pages in the memory group of each system service based on the memory exchange policy corresponding to the memory group of each system service.
[0093] In some embodiments, the memory grouping module 610 can be specifically used to determine the memory page corresponding to each system service based on the process of each system service; divide the memory page corresponding to each system service into the corresponding memory group to obtain the memory group corresponding to each system service.
[0094] In a possible implementation, the memory grouping module 610 can also be used to filter out the first process from the processes of each system service to obtain the second process of each system service, where the first process belongs to multiple system services; and determine the memory page corresponding to the second process of each system service as the memory page corresponding to each system service.
[0095] In some embodiments, the memory management device 600 may further include a policy determination module. The policy determination module is used to determine the memory exchange policy corresponding to the memory group of each system service based on the target priority corresponding to each system service before performing memory exchange management on the memory pages in the memory group of each system service based on the memory exchange policy corresponding to the memory group of each system service, wherein the memory exchange policies corresponding to the memory groups of system services with different priorities are different.
[0096] In one possible implementation, the policy determination module may be specifically used to determine, for each system service, that if the target priority corresponding to the system service is the first priority, then determine that the memory swap policy corresponding to the memory group of the system service is the first policy of not performing memory swapping, and the first priority is the highest priority; if the target priority is not the first priority, then determine the target swap algorithm corresponding to the target priority from a plurality of page swap algorithms, and use the memory swap policy corresponding to the target swap algorithm as the memory swap policy corresponding to the memory group of the system service.
[0097] Optionally, the policy determination module can also be used to, if the target priority is the second priority, determine the least recently used algorithm from multiple page swap algorithms, and use the second policy corresponding to the least recently used algorithm as the memory swap policy corresponding to the memory group of the system service, and the second priority is lower than the first priority; if the target priority is the third priority, determine the first-in-first-out algorithm from multiple page swap algorithms, and use the third policy corresponding to the first-in-first-out algorithm as the memory swap policy corresponding to the memory group of the system service, and the third priority is lower than the second priority.
[0098] In some embodiments, the memory exchange module 620 can be specifically used to swap out the target memory page to the target storage area corresponding to the target memory group if it is determined that the target memory page in the target memory group needs to be swapped out based on the memory exchange policy corresponding to the target memory group served by the target system.
[0099] In a possible implementation, the memory exchange module 620 can also be used to determine the priority corresponding to the target system service if it is determined based on the memory exchange policy corresponding to the target memory group of the target system service that the target memory page in the target memory group needs to be swapped out; based on the priority corresponding to the target system service, determine the corresponding swap area as the target storage area, the data reading and writing speeds of the swap areas corresponding to different priorities are different; and swap out the target memory page to the target storage area.
[0100] In some embodiments, the memory grouping module 610 can be specifically used to obtain current operating status parameters; if the operating status parameters meet the grouping parameter conditions, the memory pages corresponding to each currently running system service are divided into corresponding memory groups to obtain the memory groups corresponding to each system service.
[0101] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the above-described devices and modules can refer to the corresponding processes in the aforementioned method embodiments, and will not be repeated here.
[0102] In several embodiments provided in the present application, the coupling between modules may be electrical, mechanical or other forms of coupling.
[0103] In addition, each functional module in each embodiment of the present application can be integrated into a processing module, or each module can exist physically separately, or two or more modules can be integrated into one module. The above integrated modules can be implemented in the form of hardware or software functional modules.
[0104] To summarize, the solution provided by the present application divides the memory pages corresponding to each currently running system service into corresponding memory groups to obtain the memory groups corresponding to each system service, and based on the memory swap policy corresponding to the memory group of each system service, performs memory swap management on the memory pages in the memory group of each system service, thereby realizing targeted memory swap management of the memory pages of each system service and improving the accuracy of memory swap management.
[0105] Please refer to Figure 7, which shows a structural block diagram of an electronic device provided in an embodiment of the present application. The electronic device 100 may be an electronic device capable of running applications, such as a smart phone, a tablet computer, a smart watch, an e-book, etc. The electronic device 100 in the present application may include one or more of the following components: a processor 110, a memory 120, and one or more applications, wherein the one or more applications may be stored in the memory 120 and configured to be executed by one or more processors 110, and the one or more applications are configured to execute the method described in the aforementioned method embodiment.
[0106] The processor 110 may include one or more processing cores. The processor 110 uses various interfaces and lines to connect various parts of the entire electronic device 100, and executes various functions and processes data of the electronic device 100 by running or executing instructions, programs, code sets or instruction sets stored in the memory 120, and calling data stored in the memory 120. Optionally, the processor 110 can be implemented in at least one hardware form of digital signal processing (DSP), field-programmable gate array (FPGA), and programmable logic array (PLA). The processor 110 can integrate one or a combination of a central processing unit (CPU), a graphics processing unit (GPU), and a modem. Among them, the CPU mainly processes the operating system, user interface, and application programs; the GPU is responsible for rendering and drawing display content; and the modem is used to process wireless communications. It can be understood that the above-mentioned modem may not be integrated into the processor 110, but may be implemented separately through a communication chip.
[0107] The memory 120 may include a random access memory (RAM) or a read-only memory (ROM). The memory 120 may be used to store instructions, programs, codes, code sets or instruction sets. The memory 120 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for implementing at least one function (such as a touch function, a sound playback function, an image playback function, etc.), instructions for implementing the following various method embodiments, etc. The data storage area may also store data (such as a phone book, audio and video data, chat record data) created by the electronic device 100 during use.
[0108] Please refer to Figure 8 , which shows a structural block diagram of a computer-readable storage medium provided in an embodiment of the present application. The computer-readable medium 800 stores program codes, which can be called by a processor to execute the method described in the above method embodiment.
[0109] The computer readable storage medium 800 may be an electronic memory such as a flash memory, an EEPROM (electrically erasable programmable read-only memory), an EPROM, a hard disk, or a ROM. Optionally, the computer readable storage medium 800 includes a non-transitory computer-readable storage medium. The computer readable storage medium 800 has storage space for program code 810 that performs any method step in the above method. These program codes can be read from or written to one or more computer program products. The program code 810 can be compressed, for example, in an appropriate form.
[0110] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A memory management method, characterized in that: The method comprises: Divide the memory pages corresponding to each currently running system service into corresponding memory groups to obtain the memory groups corresponding to each system service; Based on the memory swap policy corresponding to the memory group of each system service, memory swap management is performed on the memory pages in the memory group of each system service.
2. The method according to claim 1, characterized in that The dividing the memory page corresponding to each currently running system service into the corresponding memory group to obtain the memory group corresponding to each system service includes: Based on the process of each system service, determine the memory page corresponding to each system service; The memory page corresponding to each system service is divided into a corresponding memory group to obtain the memory group corresponding to each system service.
3. The method according to claim 2, characterized in that The determining, based on the process of each system service, a memory page corresponding to each system service includes: Filtering a first process from the processes of each system service to obtain a second process of each system service, wherein the first process belongs to a plurality of system services; The memory page corresponding to the second process of each system service is determined as the memory page corresponding to each system service.
4. The method according to claim 1, characterized in that: Before performing memory swap management on the memory pages in the memory group of each system service based on the memory swap policy corresponding to the memory group of each system service, the method further includes: Based on the target priority corresponding to each system service, a memory swap policy corresponding to the memory group of each system service is determined, wherein the memory groups of system services with different priorities correspond to different memory swap policies.
5. The method according to claim 4, characterized in that The determining, based on the target priority corresponding to each system service, a memory swap strategy corresponding to the memory group of each system service includes: For each of the system services, if the target priority corresponding to the system service is the first priority, determining that the memory swap policy corresponding to the memory group of the system service is the first policy of not performing memory swapping, and the first priority is the highest priority; If the target priority is not the first priority, a target swap algorithm corresponding to the target priority is determined from a plurality of page swap algorithms, and a memory swap policy corresponding to the target swap algorithm is used as a memory swap policy corresponding to the memory group of the system service.
6. The method according to claim 5, characterized in that If the target priority is not the first priority, determining a target swap algorithm corresponding to the target priority from a plurality of page swap algorithms, and using a memory swap strategy corresponding to the target swap strategy as a memory swap strategy corresponding to the memory group of the system service, including: If the target priority is the second priority, determining a least recently used algorithm from a plurality of page swap algorithms, and using a second strategy corresponding to the least recently used algorithm as a memory swap strategy corresponding to the memory group of the system service, the second priority being lower than the first priority; If the target priority is the third priority, a first-in-first-out algorithm is determined from a plurality of page swap algorithms, and a third strategy corresponding to the first-in-first-out algorithm is used as a memory swap strategy corresponding to the memory group of the system service, and the third priority is lower than the second priority.
7. The method according to any one of claims 1 to 6, characterized in that: The memory swapping management of the memory pages in the memory group of each system service based on the memory swapping policy corresponding to the memory group of each system service includes: If it is determined that a target memory page in the target memory group needs to be swapped out based on a memory swap policy corresponding to a target memory group served by a target system, the target memory page is swapped out to a target storage area corresponding to the target memory group.
8. The method according to claim 7, characterized in that If it is determined that a target memory page in the target memory group needs to be swapped out based on a memory swap policy corresponding to a target memory group served by the target system, swapping out the target memory page to a target storage area corresponding to the target memory group includes: If it is determined that the target memory page in the target memory group needs to be swapped out based on the memory swap policy corresponding to the target memory group of the target system service, then the priority corresponding to the target system service is determined; Based on the priority level corresponding to the target system service, determining the corresponding exchange area as the target storage area, wherein the data reading and writing speeds of the exchange areas corresponding to different priorities are different; The target memory page is swapped out to the target storage area.
9. The method according to any one of claims 1 to 6, characterized in that: The dividing the memory page corresponding to each currently running system service into the corresponding memory group to obtain the memory group corresponding to each system service includes: Get the current running status parameters; If the running status parameter meets the grouping parameter condition, the memory page corresponding to each currently running system service is divided into a corresponding memory group to obtain the memory group corresponding to each system service.
10. A memory management device, characterized in that: The device comprises: a memory grouping module and a memory switching module, wherein: The memory grouping module is used to divide the memory pages corresponding to each currently running system service into corresponding memory groups to obtain the memory groups corresponding to each system service; The memory exchange module is used to perform memory exchange management on the memory pages in the memory group of each system service based on the memory exchange policy corresponding to the memory group of each system service.
11. An electronic device, characterized in that: include: one or more processors; Memory; One or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors, and the one or more programs are configured to execute the method according to any one of claims 1 to 9.
12. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores program codes, which can be called by a processor to execute the method according to any one of claims 1 to 9.