Memory management method and device, electronic equipment and storage medium

By obtaining and analyzing the status of running applications and selecting appropriate page replacement strategies, the problem of insufficient flexibility in existing memory management methods is solved, and the flexibility and operational performance of memory management are improved.

CN119537263APending Publication Date: 2025-02-28GUANGDONG OPPO MOBILE TELECOMMUNICATIONS CORP LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311092845.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-08-28
Publication Date
2025-02-28

AI Technical Summary

Technical Problem

The existing memory management methods are not flexible enough and lack tunability, which affects the operational performance and user experience of the application.

Method used

By obtaining the running status of the running application, determining the target application to be processed, and selecting the appropriate page replacement policy based on the running status of the target application, page replacement processing is performed on the memory pages in the target memory group.

Benefits of technology

Improves the flexibility of memory management and memory operation performance, reduces the frequency of page replacement of important applications, and ensures the normal operation and user experience of the application.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119537263A_ABST
    Figure CN119537263A_ABST
Patent Text Reader

Abstract

The invention discloses a memory management method and device, electronic equipment and a storage medium, and relates to the technical field of data storage. The method comprises the following steps: acquiring the running state of a running application; determining a to-be-processed target application according to the running state; and performing page replacement processing on memory pages in a target memory group of the target application by utilizing a target page replacement strategy corresponding to the running state of the target application. Therefore, according to the running state of the running application, the target application more suitable for page replacement processing can be determined; and according to the running state of the target application, a more adaptive and effective target page replacement strategy is flexibly called, and page replacement processing is performed on the memory pages in the target memory group of the target application, so that the flexibility of memory management and the running performance of the memory are greatly improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of data storage, and in particular to a memory management method, device, electronic device and storage medium. Background Art

[0002] In the related art, Swap is generally used for memory management. Swap allows the operating system to "swap out" the data in the memory to the hard disk (or 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 hard disk to the memory. However, this memory management method is not flexible enough and lacks adjustability, which in turn affects the running performance of the application and the user experience. Summary of the invention

[0003] The present application proposes a memory management method, device, electronic device and storage medium to improve the flexibility of memory management.

[0004] In a first aspect, an embodiment of the present application provides a memory management method, the method comprising: obtaining the running status of a running application; determining a target application to be processed based on the running status; and performing page replacement processing on memory pages in a target memory group of the target application using a target page replacement strategy corresponding to the running status of the target application.

[0005] In a second aspect, an embodiment of the present application provides a memory management device, the device comprising: a state acquisition module, an application determination module and a page replacement module. The state acquisition module is used to acquire the running state of the running application; the application determination module is used to determine the target application to be processed according to the running state; the page replacement module is used to perform page replacement processing on the memory pages in the target memory group of the target application using the target page replacement strategy corresponding to the running state of the target application.

[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 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 above-mentioned method.

[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 above method.

[0008] In the solution provided by the present application, the running status of the running application is obtained; according to the running status, the target application to be processed is determined; and the target page replacement strategy corresponding to the running status of the target application is used to perform page replacement processing on the memory pages in the target memory group of the target application. In this way, according to the running status of the running application, a target application that is more suitable for page replacement processing can be determined; and according to the running status of the target application, a more suitable and effective target page replacement strategy can be flexibly called to perform page replacement processing on the memory pages in the target memory group of the target application, which greatly improves the flexibility of memory management and memory operation performance. 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 flowchart of a memory management method provided in an embodiment of the present application is shown.

[0011] Figure 2 A flowchart of a memory management method provided by another embodiment of the present application is shown.

[0012] Figure 3 Shows Figure 2 A flowchart of the sub-steps of step S210 in one implementation manner.

[0013] Figure 4 Shows Figure 2 Schematic diagram of the flow chart of the sub-steps of step S210 in another implementation manner.

[0014] Figure 5 It is a block diagram of a memory management device provided according to an embodiment of the present application.

[0015] Figure 6 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.

[0016] Figure 7 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

[0017] In order to enable those skilled in the art to better understand the present application, the technical solutions 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. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.

[0018] It should be noted that in some processes described in the specification, claims and the above-mentioned drawings of the present application, multiple operations that appear in a specific order are included, and these operations may not be executed or executed in parallel in the order in which they appear in this article. The sequence numbers of operations such as S110, S120, etc. are only used to distinguish different operations, and the sequence numbers themselves do not represent any execution order. In addition, these processes may include more or less operations, and these operations may be executed in sequence or in parallel. And, the terms "first", "second", etc. in the specification, claims and the above-mentioned drawings of the present application are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequential order. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described here can be implemented in an order other than those illustrated or described here. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product, or server that includes a series of steps or sub-modules is not necessarily limited to those steps or sub-modules explicitly listed, but may include other steps or sub-modules that are not explicitly listed or that are inherent to these processes, methods, products, or devices.

[0019] The inventor proposes a memory management method, device, electronic device and storage medium. The memory management method provided by the embodiment of the present application is described in detail below.

[0020] Please refer to Figure 1 , Figure 1 A flowchart of a memory management method provided in an embodiment of the present application is shown below. Figure 1 The memory management method provided in the embodiment of the present application is described in detail. The memory management method may include the following steps:

[0021] Step S110: Obtain the running status of the running application.

[0022] In this embodiment, when the memory replacement condition of the electronic device is met, the running state of the running application can be further obtained, and then the memory page replacement process can be implemented more flexibly according to the running state of the application.

[0023] The running application is not just the application running in the foreground in the electronic device, but can be understood as the application that has been started in the electronic device. The started application can be running in the foreground, in the background, in a suspended state, etc.

[0024] It is understandable that the application is in different running states and the application's requirements for calling memory data are also different. Therefore, in order to avoid memory replacement application to the actual running of the application, the running status of all running applications in the electronic device can be further obtained when the memory replacement conditions of the electronic device are met.

[0025] In some embodiments, to determine whether the electronic device currently meets the memory replacement condition, the current remaining first memory size can be obtained; if the first memory size is less than the first memory threshold, it is determined that the memory replacement condition is met; if the first memory size is greater than or equal to the first memory remaining threshold, it is determined that the memory replacement condition is not met. Among them, the first memory threshold can be a pre-set minimum memory threshold, that is, the electronic device currently has at least the first memory threshold remaining, so as to ensure that the running state of the application running in the electronic device is not affected, and there will be no problems such as freezing or flashing. In other words, the electronic device can detect its current remaining memory size in real time, and then perform memory replacement processing when the memory is insufficient (that is, the memory replacement condition is met), release more memory, and thus ensure the normal operation of the application running in the electronic device.

[0026] In other embodiments, determining whether the electronic device currently meets the memory replacement condition can also be in response to a memory allocation request, obtaining the difference between the current remaining first memory size and the second memory size as the target memory difference, wherein the second memory size is the memory size requested to be allocated by the memory allocation request; if the target memory difference is less than the second memory threshold, it is determined that the memory replacement condition is met; if the target memory difference is greater than or equal to the second memory threshold, it is determined that the memory replacement condition is not met. Wherein, the second memory threshold is also a pre-set minimum memory threshold, and the second memory threshold can be the same as the size of the aforementioned first memory threshold, or it can be different, and this embodiment does not limit this. That is to say, the electronic device can also pre-determine whether the remaining target memory difference reaches the second memory threshold at which the application state of the application in the electronic device will not be affected after the memory size required by the memory allocation request is allocated when receiving the memory allocation request. If it is less than the second memory threshold, it indicates that after the electronic device responds to the memory allocation request, there will be insufficient memory, which will affect the normal operation of the electronic device. In this case, it can also be determined that the electronic device currently meets the memory replacement condition, and replaces and frees up enough memory space before responding to the memory allocation request.

[0027] Step S120: Determine the target application to be processed according to the running status.

[0028] It is understandable that the importance of applications in different running states is also different. For example, some running applications cannot perform page replacement processing, while other running applications can perform page replacement processing. It is understandable that in other applications that are allowed to perform page replacement processing, there will also be a processing priority for page replacement processing, that is, the application with the highest processing priority is determined as the target application to be processed.

[0029] Optionally, applications with the top N processing priorities may be determined as target applications to be processed, where N is an integer greater than 0. That is, page replacement processing may be performed on one or more target applications to release more memory space as quickly as possible to ensure the normal operation of the electronic device and the running speed of other applications in the electronic device.

[0030] Step S130: using the target page replacement strategy corresponding to the running state of the target application, performing page replacement processing on the memory pages in the target memory group of the target application.

[0031] In this embodiment, a plurality of preset page replacement strategies and mapping relationships between a plurality of target page replacement strategies and a plurality of operating states may be pre-set. Based on this, after determining the target application to be processed, the preset page replacement strategy corresponding to the operating state of the target application may be queried and obtained according to the aforementioned mapping relationship as the aforementioned target page replacement strategy; and then the target page replacement strategy may be used to perform page replacement processing on the memory pages in the target memory group of the target application. Among them, the page replacement processing can be generally understood as the operating system of the electronic device selecting a page in the memory and moving it out of the memory to make room for the page to be called in.

[0032] Among them, the various preset page replacement strategies generally include the First Input First Output (FIFO) algorithm and the Least Recently Used (LRU) algorithm. Among them, the FIFO algorithm sorts the data items according to the order in which they enter the cache. When the cache space is full, the data that enters the cache earliest is replaced. It is simple to implement and only needs to maintain a queue structure. It is suitable for application scenarios where the data access pattern is relatively stable and lacks obvious temporal locality. The LRU algorithm sorts the data items according to their most recent access time. When the cache space is full, the data that has not been accessed for the longest time is replaced. It can make better use of the locality principle and is suitable for scenarios where the access pattern has obvious temporal locality.

[0033] In this way, the target page replacement strategy corresponding to the running state is called according to the memory group of the application that needs to perform page replacement processing, so that the page replacement strategy that better meets the needs of the application can be used.

[0034] Optionally, in addition to the FIFO algorithm and the LRU algorithm, the aforementioned multiple preset page replacement strategies may also include one or more other replacement algorithms such as the optimal replacement (OPT) algorithm, the second chance algorithm, the not recently used (NRU) algorithm, the least frequently used (LFU) replacement algorithm and the clock replacement algorithm; which page replacement algorithms are specifically set as the aforementioned multiple preset page replacement strategies can be pre-set according to actual needs, and this embodiment does not impose any restrictions on this.

[0035] In this embodiment, when the memory replacement conditions for the electronic device are met, a more adaptive and effective target page replacement strategy is flexibly called according to the running state of the target application, and page replacement processing is performed on the memory pages in the target memory group of the target application, which greatly improves the flexibility of memory management and memory operation performance; at the same time, it also reduces the page replacement frequency of important applications to ensure the operation performance of important applications.

[0036] Please refer to Figure 2 , Figure 2 A flowchart of a memory management method provided in an embodiment of the present application is shown below. Figure 2 The memory management method provided in the embodiment of the present application is described in detail. The memory management method may include the following steps:

[0037] Step S210: Obtain the running status of the running application.

[0038] In some embodiments, see Figure 3 , step S210 may include the following steps S211A to S212A:

[0039] Step S211A: Based on the memory size occupied by the thread of the running application, determine the running score of the running application, the running score is used to represent the processing priority of the running application, and the processing priority is positively correlated with the running score.

[0040] In this embodiment, the electronic device can use OOM (Out of Memory) killer to manage memory. OOM killer can start working when the system memory of the electronic device is seriously insufficient. This situation occurs because the process on the server is consuming a large amount of memory, and the system needs more memory to be allocated to other processes. Specifically, when the system memory allocation of the electronic device fails, OOM killer can call the out_of_memory() function, and the select_bad_process() function is called in the out_of_memory() function. Select_bad_process() obtains the running score corresponding to each process through the badness() function. There is a set of rules inside the badness() function to select the target process: the kernel reserves the minimum memory required for operation for itself and tries to recycle a large amount of memory; prioritizes the elimination of processes with high memory usage and tries to kill the least number of processes; some algorithms can adjust the priority of the process being terminated. In other words, OOM killer can score the application corresponding to the thread based on the memory size occupied by the running thread, and obtain the running score of the running application. Among them, the running score can be used to characterize the processing priority of the corresponding application, and the processing priority is positively correlated with the running score; that is, the higher the running score, the larger the memory occupied by the thread of the application, and the electronic device can give priority to trying to perform page replacement processing on the memory group of the application with a higher running score to release more available memory.

[0041] Step S212A: Acquire a preset running state that matches the running score as the running state of the running application.

[0042] In one possible implementation, the electronic device may be pre-set with a plurality of preset operating states, and the plurality of preset operating states correspond one-to-one to a plurality of preset scores, and then, after obtaining the operating score of the running application, a preset score matching the operating score of the running application may be determined as the target preset score; and then the preset operating state corresponding to the target preset score may be obtained as the operating state of the running application.

[0043] Optionally, the preset score that matches the running score of the running application may refer to a preset score that is the same as the running score of the running application, or a preset score whose score difference with the preset score of the running application is within a first score threshold.

[0044] In another possible implementation, the electronic device may be pre-set with a plurality of preset operating states, and the plurality of preset operating states correspond one-to-one to a plurality of preset score ranges, and then, when the operating score of the running application is obtained, the preset score range in which the operating score of the running application is located can be determined as the target preset score range; and then the preset operating state corresponding to the target preset score range is obtained as the operating state of the running application.

[0045] Among them, the aforementioned multiple preset running states may at least include Foreground App, Visible App, Perceptible App, Heavy Weight App, Secondary Server and other running states. Foreground App represents the application that the user is interacting with, that is, the running state of being interacted; Visible App represents the application that the user can see but is not currently interacting with, that is, the running state that can be seen but no interaction occurs; Heavy Weight App represents the background application that requires a large amount of memory or central processing unit (CPU) resources, that is, the running state that occupies a large amount of memory or CPU resources.

[0046] In some other embodiments, see Figure 4 , step S210 may include the following steps S211B to S212B:

[0047] Step S211B: Get the process status of the running process.

[0048] Step S212B: Based on the process status of the running process, determine the running status of the corresponding running application.

[0049] In this manner, the ProcState process state of the running process may be obtained, and then the obtained process state may be used as the running state of the running application corresponding to the process.

[0050] In this embodiment, the ProcState process state includes at least: FOREGROUND_APP, VISIBLE_APP, PERCEPTIBLE_APP, HEAVY_WEIGHT_APP, BACKUP_APP, SERVICE, HOME_APP, CACHED_APP and other running state categories.

[0051] Among them, FOREGROUND_APP is used to characterize the running status of the application that the user is interacting with; VISI BLE_APP is used to characterize the running status of the application that the user can see but is not currently interacting with (such as starting another application but not closing this application); PERCEPTIBLE_APP is used to characterize the running status of the application that the user cannot see but can still perceive (such as playing music in the background); HEAVY_WEIGHT_APP is used to characterize the running status of some background applications that require a lot of memory or CPU resources; BA CKUP_APP is used to characterize the running status of the application that is performing data backup; SERVICE is used to characterize the running status of the running service; HOME_APP is used to characterize the running status of the desktop application; PREVIOUS_APP is used to characterize the running status of the application that was recently run but is now switched to the background; CACHED_APP is used to characterize the running status of the application in the cache.

[0052] That is to say, in this embodiment, two methods are provided to classify the running status of running applications. One is to score all running applications through the OOM killer scoring mechanism mentioned in the aforementioned embodiment, thereby obtaining the running score of each running application, and then obtaining the corresponding OMM running category according to the running score. The other is to directly obtain the ProcState running category of the application process as mentioned in the aforementioned embodiment. It can be understood that which of the two classification methods is used can be pre-set; of course, it is also possible to select one of the two classification methods for classification, and this embodiment does not limit this.

[0053] Step S220: Determine the target application to be processed according to the running status.

[0054] In this embodiment, no matter which of the aforementioned classification methods is used, there are corresponding processing priorities for the various operating states under the classification method. Among them, the higher the processing priority of the application, the smaller the impact on the current user of the electronic device after the replacement of the memory page in the memory group of the application, or the current user of the electronic device is not aware that the page replacement process has been performed.

[0055] In some implementations, if the OOM killer scoring mechanism is used, the processing priority of the application is positively correlated with the running score; based on this, the application corresponding to the running state with the largest running score can be obtained from multiple running applications as the target application to be processed. In other words, the application with the highest processing priority is determined from multiple running applications as the target application to be processed.

[0056] In another possible implementation, if it is based on the ProcState classification mechanism, under this classification, each ProcState running category corresponds to a processing priority; based on this, the application corresponding to the running state with the highest processing priority can be directly obtained from multiple running applications as the target application to be processed. For example, under the ProcState classification mechanism, the processing priority is: FOREGROUN D_APP <VISIBLE_APP<PERCEPTIBLE_APP<HEAVY_WEIGHT_APP<BACK UP_APP<SERVICE<HOME_APP<PREVIOUS_APP<CACHED_APP。

[0057] That is to say, the application CACHED_APP in the cache is prioritized as the target application to be processed, that is, the memory page data in the memory group of the application in the cache, even if it is swapped from the memory to the flash memory or disk, will not affect the application currently being used by the user, for example, the application the user is interacting with. However, the application FOREGROUND_APP with the lowest processing priority that the user is interacting with will not be used as the target application to be processed. For example, if the application the user is interacting with is a game, if the memory replacement conditions are met, the memory group of the game application is directly replaced, such as moving the data in the memory group to the flash memory for storage, which will cause problems such as game freeze or game flash back; in this way, according to the running status of the running application, the processing priority of each application is determined, and the target application that needs to be paged out is determined based on the processing priority, so as to avoid page replacement processing for the application that the user is using or that the user can perceive, causing problems such as application freeze or flash back, thereby ensuring the user experience of the electronic device.

[0058] Step S230: determining a target storage medium corresponding to the running state of the target application from a plurality of preset storage media, wherein different preset storage media have different data reading and writing rates.

[0059] Among them, the multiple preset storage media may include memory, flash memory (Falsh) and disk (DISK). Among them, the memory can be understood as the internal memory of the electronic device, which is the component that the CPU directly communicates with and uses to store data. It stores the data and programs currently in use (i.e., being executed). The characteristics are that data can be read and written at any time, and the data reading and writing rate is very fast. Flash memory and disk can both be understood as auxiliary memory of electronic devices, i.e., external memory. The external memory can store information for a long time and does not rely on electricity to save information. That is, the data stored in the external memory can also be kept after power failure. However, it is driven by mechanical components, and the data reading and writing rate is slower than that of the memory; the data reading and writing rate of the disk is slower than that of the flash memory, but the storage space of the disk is larger than that of the flash memory.

[0060] It is understandable that applications in different running states have different requirements for data read and write rates. Therefore, after determining the target application to be processed, a preset storage medium corresponding to the running state of the target application can be obtained from a variety of preset storage media as the target storage medium. That is, the target storage medium that is most suitable for the application in the current running state is selected.

[0061] Step S240: using a target page replacement strategy corresponding to the running state of the target application, storing page data of the memory pages in the target memory group to the target storage medium.

[0062] Furthermore, after the target storage medium is used to replace the page data of the memory page in the target memory group of the target application, the target page replacement strategy corresponding to the running state of the target application can be used to store the page data of the memory page in the target memory group to the target storage medium. In other words, even for the same application, in different running states, the present application will call different page replacement strategies to perform page replacement processing, which greatly improves the flexibility of memory management.

[0063] Optionally, the page data of the memory pages in the target memory group can be directly moved to the target storage medium for storage; or the page data of the memory pages in the target memory group can be compressed and then moved to the target storage medium for storage. In this way, the destination of page replacement is diversified for the memory groups of applications in different running states, and different types of storage media are effectively utilized.

[0064] In some embodiments, before the page data of the memory page in the target memory group is stored in the target storage medium, whether to compress the page data can be determined according to the real-time nature of the data required by the target application. If the real-time nature of the data required by the target application is high, for example, data reading or data writing must be completed within the first target time length, that is, data reading or data writing must be completed in a shorter time, then compression processing may not be required; if data reading or data writing does not need to be completed within the first target time length, that is, the target application has a low requirement for the real-time nature of the data, then compression processing can be performed before storing it in the target storage medium. In this way, the consumption of storage space of the storage medium in the electronic device can be reduced to a certain extent.

[0065] The real-time requirement of the target application may be determined based on the current running state, or may be determined based on the current running state and the application type of the target application, which is not limited in this embodiment.

[0066] In this embodiment, a strategy for automatic grouping based on the running status of applications is proposed. For the memory groups of applications in different running statuses, the storage media for page replacement is diversified, and different types of storage media are effectively utilized. At the same time, this application is also highly scalable, and the running status classification and the page replacement strategy and storage media required for each running status can be adjusted according to different hardware configurations and system requirements. Obviously, the flexibility of memory management is improved, and it can be appropriately adjusted according to the status and requirements of the application. Through an effective page replacement strategy, the page replacement frequency of important applications can be reduced, thereby improving their running performance. Different resources are allocated to different processes or applications, so that the memory can be managed more efficiently. Especially in the performance optimization of game applications, the memory management method provided by this application can greatly improve the running efficiency and running smoothness of the game.

[0067] Please refer to Figure 5 , which shows a structural block diagram of a memory management device 300 provided by an embodiment of the present application. The device 300 may include: a state acquisition module 310, an application determination module 320 and a page replacement module 330.

[0068] The status acquisition module 310 is used to acquire the running status of the running application.

[0069] The application determination module 320 is used to determine the target application to be processed according to the running status.

[0070] The page replacement module 330 is used to perform page replacement processing on the memory pages in the target memory group of the target application by using the target page replacement strategy corresponding to the running state of the target application.

[0071] In some embodiments, the page replacement module 330 can be specifically used to: determine the target storage medium corresponding to the running state of the target application from a plurality of preset storage media, different preset storage media having different data read and write rates; and utilize the target page replacement strategy corresponding to the running state of the target application to store the page data of the memory pages in the target memory group to the target storage medium.

[0072] In some embodiments, the state acquisition module 310 may include: a scoring unit and a state determination unit. The scoring unit may be used to determine the running score of the running application based on the memory size occupied by the thread of the running application, and the running score is used to characterize the processing priority of the running application, and the processing priority is positively correlated with the running score. The state determination unit may be used to obtain a preset running state matching the running score as the running state of the running application.

[0073] In this manner, the application determination module 320 may be specifically configured to: obtain, from among a plurality of running applications, an application corresponding to the running state with the largest running score as the target application to be processed.

[0074] In some other implementations, the status acquisition module 310 may be specifically used to: acquire the process status of a running process; and determine the running status of a corresponding running application based on the process status of the running process.

[0075] In some implementations, the memory management device 300 may further include: a memory replacement determination module. The memory replacement determination module may be used to obtain a currently remaining first memory size before obtaining the running status of the running application; if the first memory size is less than a first memory threshold, determine that the memory replacement condition is met, and execute the obtaining the running status of the running application.

[0076] In some embodiments, the memory management device 300 may further include: a memory difference acquisition module and a memory replacement determination module. The memory difference acquisition module may be used to obtain the difference between the currently remaining first memory size and the second memory size in response to a memory allocation request before obtaining the running status of the running application, as a target memory difference, and the second memory size is the memory size requested to be allocated by the memory allocation request. The memory replacement determination module may be used to determine that the memory replacement condition is met if the target memory difference is less than the second memory threshold, and execute the obtaining of the running status of the running application.

[0077] 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.

[0078] In several embodiments provided in the present application, the coupling between modules may be electrical, mechanical or other forms of coupling.

[0079] 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.

[0080] In summary, a strategy for automatic grouping based on the running status of applications is proposed. For the memory groups of applications in different running statuses, the storage media for page replacement is diversified, and different types of storage media are effectively utilized. At the same time, this application is also highly scalable, and the running status classification and the page replacement strategy and storage media required for each running status can be adjusted according to different hardware configurations and system requirements. Obviously, the flexibility of memory management is improved, and it can be appropriately adjusted according to the status and requirements of the application. Through an effective page replacement strategy, the page replacement frequency of important applications can be reduced, thereby improving their running performance.

[0081] The following will be combined Figure 6 An electronic device provided by the present application is described.

[0082] Reference Figure 6 , Figure 6The structural block diagram of an electronic device 400 provided in an embodiment of the present application is shown, and the above method provided in an embodiment of the present application can be executed by the electronic device 400. The electronic device can be an electronic terminal with a data processing function, and the electronic terminal includes but is not limited to a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart watch, an e-book reader, an MP3 (Moving Picture Experts Group Audio Layer III, Moving Picture Experts Group Audio Layer 3) player, an MP4 (Moving Picture Experts Group Audio Layer IV, Moving Picture Experts Group Audio Layer 4) player, and smart home devices, etc.; of course, the electronic device can also be a server, and the server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, network acceleration services (Content Delivery Network, CDN), and basic cloud computing services such as big data and artificial intelligence platforms.

[0083] The electronic device 400 in the embodiment of the present application may include one or more of the following components: a processor 401, a memory 402, and one or more applications, wherein the one or more applications may be stored in the memory 402 and configured to be executed by one or more processors 401, and the one or more programs are configured to execute the method as described in the aforementioned method embodiment.

[0084] The processor 401 may include one or more processing cores. The processor 401 uses various interfaces and lines to connect the various parts of the entire electronic device 400, and executes various functions and processes data of the electronic device 400 by running or executing instructions, programs, code sets or instruction sets stored in the memory 402, and calling data stored in the memory 402. Optionally, the processor 401 can be implemented in at least one hardware form of digital signal processing (Digital Signal Processing, DSP), field programmable gate array (Field-Programmable Gate Array, FPGA), and programmable logic array (Programmable Logic Array, PLA). The processor 401 can integrate one or a combination of a central processing unit (Central Processing Unit, CPU), a graphics processing unit (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 can also be integrated into the processor 401 and implemented separately through a communication chip.

[0085] The memory 402 may include a random access memory (RAM) or a read-only memory (ROM). The memory 402 may be used to store instructions, programs, codes, code sets or instruction sets. The memory 402 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 the various corresponding relationships described above) created by the electronic device 400 during use.

[0086] 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.

[0087] In several embodiments provided in the present application, the coupling or direct coupling or communication connection between the modules shown or discussed may be an indirect coupling or communication connection through some interfaces, devices or modules, which may be electrical, mechanical or other forms.

[0088] 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.

[0089] Please refer to Figure 7 , which shows a structural block diagram of a computer-readable storage medium provided in an embodiment of the present application. The computer-readable medium 500 stores program codes, which can be called by a processor to execute the method described in the above method embodiment.

[0090] The computer readable storage medium 500 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 500 includes a non-transitory computer-readable storage medium. The computer readable storage medium 500 has storage space for program code 510 that performs any method step of the above method. These program codes can be read from or written to one or more computer program products. The program code 510 can be compressed, for example, in an appropriate form.

[0091] In some embodiments, a computer program product or computer program is provided, the computer program product or computer program includes computer instructions, the computer instructions are stored in a computer-readable storage medium. A processor of an electronic device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the electronic device performs the steps in the above-mentioned method embodiments.

[0092] 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: Get the running status of the running application; Determining a target application to be processed according to the running status; Using the target page replacement strategy corresponding to the running state of the target application, a page replacement process is performed on the memory pages in the target memory group of the target application.

2. The method according to claim 1, characterized in that The using the target page replacement strategy corresponding to the running state of the target application to perform page replacement processing on the memory pages in the target memory group of the target application includes: Determining a target storage medium corresponding to the running state of the target application from a plurality of preset storage media, wherein different preset storage media have different data reading and writing rates; The target page replacement strategy corresponding to the running state of the target application is used to store the page data of the memory pages in the target memory group to the target storage medium.

3. The method according to claim 1, characterized in that The obtaining the running status of the running application includes: Determine, based on the memory size occupied by the thread of the running application, a running score of the running application, wherein the running score is used to represent a processing priority of the running application, and the processing priority is positively correlated with the running score; A preset running state matching the running score is obtained as the running state of the running application.

4. The method according to claim 3, characterized in that There are multiple applications running, and determining the target application to be processed according to the running status includes: From the multiple running applications, an application corresponding to the running state with the largest running score is obtained as the target application to be processed.

5. The method according to claim 1, characterized in that The obtaining the running status of the running application includes: Get the process status of a running process; Based on the process status of the running process, the running status of the corresponding running application is determined.

6. The method according to any one of claims 1 to 5, characterized in that: Before obtaining the running status of the running application, the method further includes: Get the current remaining first memory size; If the first memory size is smaller than a first memory threshold, it is determined that a memory replacement condition is met, and the step of obtaining the running status of the running application is performed.

7. The method according to any one of claims 1 to 5, characterized in that: Before obtaining the running status of the running application, the method further includes: In response to a memory allocation request, obtaining a difference between a currently remaining first memory size and a second memory size as a target memory difference, wherein the second memory size is a memory size requested to be allocated by the memory allocation request; If the target memory difference is less than the second memory threshold, it is determined that the memory replacement condition is met, and the step of obtaining the running status of the running application is performed.

8. A memory management device, characterized in that: The device comprises: A status acquisition module is used to obtain the running status of the running application; An application determination module, used to determine a target application to be processed according to the running state; The page replacement module is used to perform page replacement processing on the memory pages in the target memory group of the target application by using the target page replacement strategy corresponding to the running state of the target application.

9. 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 7.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores program code, which can be called by a processor to execute the method according to any one of claims 1 to 7.