Memory processing method, device, electronic device and computer readable storage medium

By adjusting the memory page priority of the foreground and background applications, the problem of slow response speed of the foreground application is solved, and higher memory usage efficiency and response speed are achieved.

CN113010228BActive Publication Date: 2024-08-27GUANGDONG OPPO MOBILE TELECOMMUNICATIONS CORP LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202110293624.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-03-19
Publication Date
2024-08-27
Estimated Expiration
2041-03-19

AI Technical Summary

Technical Problem

In electronic devices, memory competition between foreground applications and background applications results in slow response speed of the foreground application, and it is difficult for existing technologies to effectively solve this problem.

Method used

By obtaining the memory page identifier set of the currently running application, the foreground and background applications are determined, and the priority of the foreground memory page is adjusted to make it higher than the priority of the background memory page, thereby improving the memory usage priority of the foreground application.

Benefits of technology

It improves the response speed and latency of foreground applications, reduces the number of page loading errors, and improves user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113010228B
    Figure CN113010228B
Patent Text Reader

Abstract

The present application relates to a memory processing method, device, electronic device and computer-readable storage medium. The method includes: obtaining a memory page identification set corresponding to a currently running application, determining a foreground application and a background application in the currently running application, obtaining a foreground memory page identification corresponding to the foreground application in the memory page identification set, and adjusting the priority of the foreground memory page corresponding to the foreground memory page identification; the adjusted priority of the foreground memory page is higher than the priority of the background memory page of the background application. The use of this method can improve the response speed of the foreground application.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a memory processing method, device, electronic device and computer-readable storage medium. Background Art

[0002] With the development of computer technology, various types of applications have emerged. Electronic devices can be compatible with multiple applications, but can only run one application in the foreground, and may run multiple applications in the background. When an application runs in the background, it will compete with the application process running in the foreground for memory usage, resulting in a slow response speed of the foreground application. Summary of the invention

[0003] The embodiments of the present application provide a memory processing method, device, electronic device, and computer-readable storage medium, which can improve the response speed of foreground applications.

[0004] A memory processing method, comprising:

[0005] Get the memory page identification set corresponding to the currently running application;

[0006] Determine a foreground application and a background application in the currently running application;

[0007] Obtain a foreground memory page identifier corresponding to the foreground application in the memory page identifier set, and adjust the priority of the foreground memory page corresponding to the foreground memory page identifier; the adjusted priority of the foreground memory page is higher than the priority of the background memory page of the background application.

[0008] A memory processing device, the device comprising:

[0009] An acquisition module is used to acquire a memory page identification set corresponding to a currently running application;

[0010] A determination module, used to determine a foreground application and a background application in the currently running application;

[0011] The adjustment module is used to obtain the foreground memory page identifier corresponding to the foreground application in the memory page identifier set, and adjust the priority of the foreground memory page corresponding to the foreground memory page identifier; the adjusted priority of the foreground memory page is higher than the priority of the background memory page of the background application.

[0012] A computer device comprises a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:

[0013] Get the memory page identification set corresponding to the currently running application;

[0014] Determine a foreground application and a background application in the currently running application;

[0015] Obtain a foreground memory page identifier corresponding to the foreground application in the memory page identifier set, and adjust the priority of the foreground memory page corresponding to the foreground memory page identifier; the adjusted priority of the foreground memory page is higher than the priority of the background memory page of the background application.

[0016] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the following steps:

[0017] Get the memory page identification set corresponding to the currently running application;

[0018] Determine a foreground application and a background application in the currently running application;

[0019] Obtain a foreground memory page identifier corresponding to the foreground application in the memory page identifier set, and adjust the priority of the foreground memory page corresponding to the foreground memory page identifier; the adjusted priority of the foreground memory page is higher than the priority of the background memory page of the background application.

[0020] The above-mentioned memory processing method, device, electronic device and computer-readable storage medium obtain the memory page identification set corresponding to the currently running application, determine the foreground application and the background application in the currently running application, and can divide the currently running application into the foreground and background applications. Obtaining the foreground memory page identification corresponding to the foreground application in the memory page identification set can distinguish the memory pages of the foreground application and the background application, so as to adjust the priority of the foreground memory page corresponding to the foreground memory page identification, and can improve the priority of the foreground memory page so that the adjusted foreground memory page has a higher priority than the background memory page of the background application. By improving the priority of the foreground memory page, the foreground application can obtain a higher memory usage priority, the foreground application has lower latency, and the response speed is faster. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0022] Figure 1 An application environment diagram of a memory processing method in one embodiment;

[0023] Figure 2 is a flowchart of a memory processing method in one embodiment;

[0024] Figure 3 A flowchart of obtaining a foreground memory page identifier corresponding to a foreground application in a memory page identifier set and adjusting the priority of a foreground memory page corresponding to the foreground memory page identifier in an embodiment;

[0025] Figure 4 is an architectural diagram of a memory processing method in one embodiment;

[0026] Figure 5 A schematic diagram of adjusting the priority of a memory page in one embodiment;

[0027] Figure 6 is a structural block diagram of a memory processing device in one embodiment;

[0028] Figure 7 FIG. 1 is a block diagram of a partial structure of an electronic device in an embodiment. DETAILED DESCRIPTION

[0029] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0030] It is understood that the terms "first", "second", etc. used in this application may be used herein to describe various elements, but these elements are not limited by these terms. These terms are only used to distinguish a first element from another element. For example, without departing from the scope of this application, a first application identifier may be referred to as a second application identifier, and similarly, a second application identifier may be referred to as a first application identifier. Both the first application identifier and the second application identifier are application identifiers, but they are not the same application identifier.

[0031] The memory processing method provided in this application can be applied to Figure 1In the application environment shown. Among them, the electronic device 102 communicates with the server 104 through the network. In one embodiment, the electronic device 102 can independently execute the memory processing method provided in the embodiment of the present application. The electronic device 102 and the server 104 can also be used in conjunction to execute the memory processing method provided in the embodiment of the present application. When the electronic device 102 and the server 104 are used in conjunction to execute the memory processing method provided in the embodiment of the present application, the server 104 stores the memory page identification set corresponding to the currently running application. The electronic device 102 can obtain the memory page identification set corresponding to the currently running application from the server 104, and the electronic device 102 determines the foreground application and the background application in the currently running application. The electronic device 102 can obtain the foreground memory page identification corresponding to the foreground application in the memory page identification set, and adjust the priority of the foreground memory page corresponding to the foreground memory page identification; the priority of the adjusted foreground memory page is higher than the priority of the background memory page of the background application. Among them, the electronic device 102 can be, but is not limited to, various personal computers, laptops, smart phones, tablet computers, portable wearable devices and televisions, and the server 104 can be implemented with an independent server or a server cluster consisting of multiple servers.

[0032] Figure 2 FIG. 1 is a flowchart of a memory processing method in an embodiment. The memory processing method in this embodiment is executed on Figure 1 The electronic device in the example is used to describe. Figure 2 As shown, the memory processing method includes steps 202 to 206.

[0033] Step 202: Obtain a memory page identification set corresponding to the currently running application.

[0034] Among them, the currently running application refers to the application that is currently in operation, which may specifically include at least one of a foreground application and a background application. The memory page identification set is used to store the identification corresponding to the memory page. The foreground application refers to the application that the user is operating on the electronic device, and the background application refers to the application that the user is not operating but is running in the background of the electronic device.

[0035] Specifically, the electronic device can obtain the currently running application and obtain the memory page identification set corresponding to the currently running application. The memory page identification set is used to record the identification of the memory page corresponding to the currently running application.

[0036] In one embodiment, the memory page identification set is used to record the identification of the memory page used by the currently running application.

[0037] In one embodiment, when the foreground application changes, the electronic device may obtain the currently running application and obtain the memory page identification set corresponding to the currently running application.

[0038] Step 204: Determine the foreground application and the background application in the currently running application.

[0039] Specifically, the electronic device can determine the currently running foreground application and the background application respectively from the currently running application programs.

[0040] In one embodiment, the electronic device can determine the foreground application and the background application in the currently running application through the running task list. The electronic device can obtain the running task list within a preset time, and determine the foreground application and the background application in the currently running application through the running task list. That is, the electronic device can obtain a list of a group of recently run tasks, sorted by time, with the most recently used application at the front, then the front is the foreground application, and the rest of the applications are background applications.

[0041] In one embodiment, the electronic device can obtain the application process information list running on itself, and determine the foreground application and the background application in the currently running application according to the application process information list. When the process contains background running code, the application corresponding to the process is determined to be a background application. When a process in the application process information list is in the display state of the front-end interface, the application corresponding to the process is determined to be a foreground application.

[0042] For example, the foreground application switches from application A to application B, and application A continues to run in the background. Then, application A and application B are the currently running applications, application B is the foreground application, and application A is the background application.

[0043] Step 206, obtain the foreground memory page identifier corresponding to the foreground application in the memory page identifier set, and adjust the priority of the foreground memory page corresponding to the foreground memory page identifier; the adjusted priority of the foreground memory page is higher than the priority of the background memory page of the background application.

[0044] The foreground memory page identifier refers to the identifier of the memory page corresponding to the foreground application, the foreground memory page refers to the memory page corresponding to the foreground application, and the background memory page refers to the memory page corresponding to the background application.

[0045] Specifically, the priority refers to the priority of memory use. The electronic device can obtain the foreground memory page identifier corresponding to the foreground application from the memory page identifier set. The electronic device can determine the foreground memory page corresponding to the foreground memory page identifier and adjust the priority of the foreground memory page to increase the priority of the foreground memory page, so that the adjusted priority of the foreground memory page is higher than the priority of the background memory page of the background application.

[0046] In one embodiment, the electronic device may also obtain a background memory page identifier corresponding to the background application from the memory page identifier set. The background memory page identifier refers to the identifier of the memory page corresponding to the background application. The electronic device may determine the background memory page corresponding to the background memory page identifier, and the electronic device may adjust the priority of the foreground memory page to increase the priority of the foreground memory page, so that the adjusted priority of the foreground memory page is higher than the priority of the background memory page.

[0047] In this embodiment, the memory page identification set corresponding to the currently running application is obtained, and the foreground application and the background application in the currently running application are determined, so that the currently running application can be divided into the foreground application and the background application. By obtaining the foreground memory page identification corresponding to the foreground application in the memory page identification set, the memory pages of the foreground application and the background application can be distinguished to adjust the priority of the foreground memory page corresponding to the foreground memory page identification, and the priority of the foreground memory page can be increased so that the adjusted priority of the foreground memory page is higher than the priority of the background memory page of the background application. By increasing the priority of the foreground memory page, the foreground application can obtain a higher memory usage priority, the foreground application has lower latency, and the response speed is faster.

[0048] In one embodiment, obtaining a foreground memory page identifier corresponding to a foreground application in a memory page identifier set and adjusting a priority of a foreground memory page corresponding to the foreground memory page identifier includes:

[0049] Obtain the foreground memory page identifier corresponding to the foreground application in the memory page identifier set, and determine the linked list where the foreground memory page corresponding to the foreground memory page identifier is located; if the foreground memory page is in the inactive linked list, move the foreground memory page to the active linked list; the priority of the active linked list is higher than the priority of the inactive linked list.

[0050] Among them, the active linked list is used to store frequently accessed active memory pages. The inactive linked list is used to store memory pages that may be associated with one or more processes but are not frequently used.

[0051] Specifically, the electronic device obtains the foreground memory page identifier corresponding to the foreground application from the memory page identifier set. The electronic device determines the foreground memory page corresponding to the foreground memory page identifier, and determines the linked list where the foreground memory page is located. The linked list includes an active linked list and an inactive linked list. The priority of the active linked list in using memory is higher than that of the inactive linked list.

[0052] When the foreground memory page is in the inactive linked list, it means that the foreground memory page is placed in a queue that is not frequently accessed, and the electronic device moves the foreground memory page to the active linked list, thereby moving the foreground memory page to the frequently accessed queue.

[0053] In one embodiment, the electronic device may determine each foreground memory page in the inactive linked list, and move each foreground memory page from the inactive linked list to the active linked list.

[0054] In one embodiment, the linked list is an LRU (Least Recently Used) linked list, and the LRU linked list is divided into an active linked list and an inactive linked list. The active linked list is represented as an active linked list, and the inactive linked list is represented as an inactive linked list.

[0055] In this embodiment, the priority of the active linked list is higher than the priority of the inactive linked list. The foreground memory page corresponding to the foreground application is placed in the active linked list, and the foreground memory page can be placed in the queue that is frequently accessed, thereby increasing the priority of the foreground application in using memory, and reducing the number of page repeated loading errors of the foreground application. Page repeated loading error (Foreground Aware Eviction Scheme, referred to as FAE) refers to a process in which a page is loaded into the memory for the first time, and after a period of non-access, the memory space of the page is released, and then when it is accessed again, a page fault interrupt is generated again, and the relevant data needs to be read from the external memory to the memory again. The time difference between reading the external memory and directly reading the memory is very large, which will cause a delay in the response of the application. In this embodiment, by increasing the priority of the foreground application in using memory, the number of page repeated loading errors of the foreground application is reduced, thereby speeding up the startup speed of the foreground application.

[0056] In one embodiment, the method further includes: if the foreground memory page is in the active linked list, retaining the foreground memory page in the active linked list.

[0057] Specifically, the electronic device obtains each foreground memory page identifier corresponding to the foreground application from the memory page identifier set. For each foreground memory page identifier, the electronic device determines the foreground memory page corresponding to the foreground memory page identifier to obtain each foreground memory page. For each foreground memory page, the electronic device determines the linked list where the foreground memory page is located. For each foreground memory page, it is determined whether the foreground memory page is in the active linked list. In the case where the foreground memory page is in the active linked list, the foreground memory page is not moved to keep the foreground memory page in the active linked list.

[0058] In this embodiment, when the foreground memory page is in the active linked list, the foreground memory page is retained in the active linked list to keep the foreground memory page in a frequently accessed queue, which can increase the priority of the foreground application in using memory, thereby improving the memory response of the foreground application and improving the user experience of the foreground application.

[0059] In one embodiment, the method also includes: obtaining a background memory page identifier corresponding to a background application in a memory page identifier set, and adjusting the priority of a background memory page corresponding to the background memory page identifier; the priority of the adjusted foreground memory page is higher than the priority of the adjusted background memory page.

[0060] Specifically, the electronic device can obtain a foreground memory page identifier corresponding to the foreground application from the memory page identifier set, determine the foreground memory page corresponding to the foreground memory page identifier, and adjust the priority of the foreground memory page to increase the priority of the foreground memory page.

[0061] Furthermore, the electronic device may also obtain a background memory page identifier corresponding to the background application from the memory page identifier set. The electronic device may determine the background memory page corresponding to the background memory page identifier, and the electronic device may adjust the priority of the background memory page to reduce the priority of the foreground memory page, so that the adjusted priority of the foreground memory page is higher than the adjusted priority of the background memory page.

[0062] In one embodiment, the electronic device can determine the foreground memory page corresponding to the foreground memory page identifier and the background memory page corresponding to the background memory page identifier, and the electronic device can obtain the priorities of the foreground memory page and the background memory page, and compare the priorities of the foreground memory page and the background memory page. When the priority of the foreground memory page is lower than the priority of the background memory page, the priority of the foreground memory page is adjusted to increase the priority of the foreground memory page, so that the priority of the foreground memory page is higher than the priority of the background memory page.

[0063] In one embodiment, when the priority of the foreground memory page is lower than the priority of the background memory page, the electronic device may adjust the priority of the background memory page to lower the priority of the background memory page so that the priority of the foreground memory page is higher than the priority of the background memory page.

[0064] In one embodiment, when the priority of the foreground memory page is lower than the priority of the background memory page, the electronic device may adjust the priorities of the foreground memory page and the background memory page at the same time to increase the priority of the foreground memory page and lower the priority of the background memory page, so that the priority of the foreground memory page is higher than the priority of the background memory page.

[0065] In this embodiment, by obtaining the background memory page identifier corresponding to the background application in the memory page identifier set, the background memory page that the background application is using can be quickly and accurately found through the background memory page identifier. By adjusting the priority of the background memory page corresponding to the background memory page identifier, the priority of the adjusted foreground memory page is higher than the priority of the adjusted background memory page. By increasing the priority of the foreground memory page, the foreground application obtains a higher memory usage priority and the background application obtains a lower memory usage priority, which can reduce the memory demand of the background application and improve the memory response of the foreground application.

[0066] In one embodiment, obtaining a background memory page identifier corresponding to a background application in a memory page identifier set and adjusting a priority of a background memory page corresponding to the background memory page identifier includes:

[0067] Obtain the background memory page identifier corresponding to the background application in the memory page identifier set, and determine the linked list where the background memory page corresponding to the background memory page identifier is located; if the background memory page is in the active linked list, move the background memory page to the inactive linked list; the priority of the active linked list is higher than the priority of the inactive linked list.

[0068] Specifically, the electronic device obtains a background memory page identifier corresponding to the background application from the memory page identifier set. The electronic device determines the background memory page corresponding to the background memory page identifier, and determines the linked list where the background memory page is located. The linked list includes an active linked list and an inactive linked list. The priority of the active linked list in using memory is higher than that of the inactive linked list.

[0069] When the background memory page is in the active linked list, it means that the background memory page is placed in the frequently accessed queue, and the electronic device moves the background memory page to the active linked list, thereby moving the background memory page to the queue that is not frequently accessed. The same process is performed for each background memory page to move each background memory page in the active linked list to the inactive linked list.

[0070] In this embodiment, the priority of the active linked list is higher than that of the inactive linked list. For the background memory page in the active linked list, the background memory page is moved to the inactive linked list, and the background memory page can be moved to a queue that is not frequently accessed, thereby reducing the priority of the background application to use memory and speeding up the startup speed of the foreground application.

[0071] In one embodiment, the method further includes: if the background memory page is in the inactive linked list, retaining the background memory page in the inactive linked list.

[0072] Specifically, the electronic device obtains each background memory page identifier corresponding to the background application from the memory page identifier set. For each background memory page identifier, the electronic device determines the background memory page corresponding to the background memory page identifier to obtain each background memory page. For each background memory page, the electronic device determines the linked list where the background memory page is located. For each background memory page, it is determined whether the background memory page is in an inactive linked list. In the case that the background memory page is in an inactive linked list, the background memory page is moved to keep the background memory page in the active linked list.

[0073] In this embodiment, when the background memory page is in the inactive linked list, the background memory page is retained in the inactive linked list to keep the background memory page in a queue that is not frequently accessed, thereby reducing the memory demand of the background application and providing more memory for the foreground application.

[0074] In one embodiment, the method further includes: determining clean memory pages in the inactive linked list, and recycling the clean memory pages.

[0075] The clean memory page refers to an unmodified memory page in the memory space, and the clean memory page may be one or more memory pages.

[0076] Specifically, the electronic device may determine the clean memory pages in the inactive linked list, and recycle the clean memory pages through a recycling process, for example, recycling the clean memory pages in the inactive linked list through a kswapd process.

[0077] In this embodiment, by recycling clean memory pages in the inactive linked list, available memory space can be increased to ensure the normal operation of the application.

[0078] In one embodiment, the method further includes: determining dirty memory pages in the inactive linked list, and recycling the dirty memory pages.

[0079] The dirty memory page refers to a modified memory page in the memory space, and the dirty memory page may be one or more memory pages.

[0080] Specifically, the electronic device may determine the dirty memory pages in the inactive linked list, and perform storage and recycling processing on the dirty memory pages through a recycling process, such as performing storage and recycling processing on the dirty memory pages through a kdflush process.

[0081] In one embodiment, the method further includes: determining clean memory pages and dirty memory pages in the inactive linked list, and recycling the clean memory pages and dirty memory pages in turn based on the fact that the priority of the clean memory pages is higher than that of the dirty memory pages.

[0082] Specifically, the electronic device can directly recycle clean memory pages, but before recycling dirty memory pages, they need to be stored, and the processing time of dirty memory pages is longer than that of clean memory pages. In this embodiment, clean memory pages are recycled first, which can improve the efficiency of memory recycling.

[0083] In one embodiment, Figure 3 As shown, obtaining the foreground memory page identifier corresponding to the foreground application in the memory page identifier set, and adjusting the priority of the foreground memory page corresponding to the foreground memory page identifier, including:

[0084] Step 302: Obtain a first application identifier of a foreground application and a second application identifier of a background application.

[0085] Specifically, when the currently running application is divided into a foreground application and a background application, the application identifier of the application is correspondingly divided into a first application identifier and a second application identifier. The first application identifier refers to the application identifier corresponding to the foreground application, and the second application identifier refers to the application identifier corresponding to the background application. After the electronic device determines the currently running application, it can determine the foreground application and the background application in the currently running application. The electronic device can obtain the first application identifier corresponding to the foreground application and the second application identifier corresponding to the background application.

[0086] In one embodiment, the electronic device can obtain a configuration file of a foreground application through a kernel, and obtain a first application identifier of the foreground application from the configuration file of the foreground application. The electronic device can obtain a configuration file of a background application through a kernel, and obtain a second application identifier of the background application from the configuration file of the background application.

[0087] Step 304: Determine a foreground memory page identifier that matches the first application identifier from the memory page identifier set.

[0088] Specifically, the electronic device matches the first application identifier with each memory page identifier in the memory page identifier set to determine the memory page identifier that matches the first application identifier. The electronic device determines the memory page identifier that matches the first application identifier in the memory page identifier set as the foreground memory page identifier. In the same processing manner, the electronic device can filter out each foreground memory page identifier that matches the first application identifier from the memory page identifier set.

[0089] Step 306: adjust the priority of the foreground memory page corresponding to the foreground memory page identifier.

[0090] Specifically, the electronic device may determine the foreground memory page corresponding to each foreground memory page identifier to adjust the priority of each foreground memory page so that the priority of each foreground memory page is higher than the priority of the background memory page.

[0091] In one embodiment, after determining each foreground memory page, the electronic device determines the priority of each foreground memory page and the priority of each background memory page, selects the foreground memory pages with a lower priority than the background memory pages, and increases the priority of the selected foreground memory pages so that the priority of each foreground memory page is higher than the priority of the background memory pages.

[0092] Obtain the background memory page identifier corresponding to the background application in the memory page identifier set, and adjust the priority of the background memory page corresponding to the background memory page identifier, including:

[0093] Step 308: Determine a background memory page identifier that matches the second application identifier from the memory page identifier set.

[0094] Specifically, the electronic device matches the second application identifier with each memory page identifier in the memory page identifier set to determine the memory page identifier that matches the second application identifier. The electronic device determines the memory page identifier that matches the second application identifier in the memory page identifier set as the background memory page identifier. In the same processing manner, the electronic device can filter out each background memory page identifier that matches the second application identifier from the memory page identifier set.

[0095] Step 310: Adjust the priority of the background memory page corresponding to the background memory page identifier.

[0096] Specifically, the electronic device can determine the background memory page corresponding to each background memory page identifier, and adjust the priority of each background memory page to reduce the priority of each background memory page so that the priority of each foreground memory page is higher than the priority of the background memory page.

[0097] In one embodiment, after determining each background memory page, the electronic device determines the priority of each foreground memory page and the priority of each background memory page, filters out background memory pages with a higher priority than the foreground memory page, and lowers the priority of the filtered background memory pages so that the priority of each foreground memory page is higher than the priority of the background memory page.

[0098] It can be understood that the execution order of steps 304-306 and steps 308-310 is not limited. The electronic device can execute steps 304-306 first and then 308-310, or execute steps 308-310 first and then 304-306, or execute steps 304-306 and 308-310 at the same time.

[0099] In this embodiment, the application identifier and memory page identifier of the same application program have a corresponding relationship. Then, through the first application identifier of the foreground application and the second application identifier of the background application, the matching foreground memory page identifier and the background memory page identifier can be found from the memory page identifier set, so as to adjust the priority of the foreground memory page corresponding to the foreground memory page identifier and the background memory page corresponding to the background memory page identifier, so as to increase the priority of the foreground memory page and reduce the priority of the background memory page, so that the foreground application obtains a higher memory usage priority and improves the startup speed of the foreground application.

[0100] In one embodiment, the method further includes: when there is an update to the application, configuring an application identifier for the updated application; and configuring a memory page identifier corresponding to the application identifier for the memory page of the updated application.

[0101] Among them, the application identifier refers to the unique identifier configured by the electronic device for its own application. For example, if application A, application B, and application C are installed on the electronic device, the electronic device can assign different application identifiers to application A, application B, and application C respectively. The application identifier and memory page identifier of the same application have a corresponding relationship. For example, the identifier of application A is A, and the memory page identifier corresponding to application A is A-1. Multiple memory pages of application A can use the same memory page identifier or different memory page identifiers, such as A-1, A-2, A-3, etc.

[0102] Specifically, when an electronic device has an update to its own application, it can determine that there is an updated application. The existence of an application update means that a new application has been downloaded to the electronic device or the version of the original application has been updated. The electronic device can configure the updated application to assign a unique application identifier to the application. The electronic device can determine the memory page corresponding to the updated application, configure a memory page identifier for the memory page corresponding to the updated application, and the configured memory page identifier has a corresponding relationship with the application identifier of the updated application.

[0103] In one embodiment, when the updated application is executed, the electronic device determines the memory page used by the updated application, and configures a memory page identifier corresponding to the application identifier for the used memory page.

[0104] In one embodiment, when installing an updated application, the electronic device configures an application identifier for the updated application.

[0105] In one embodiment, the application identifier and the memory page identifier of the same application may be the same. The electronic device may use the application identifier of the application to which the memory page belongs as the memory page identifier of the memory page.

[0106] In this embodiment, when there is an update to an application, an application identifier is configured for the updated application, and a unique application identifier can be assigned to each application. A memory page identifier corresponding to the application identifier is configured for the memory page of the updated application, and the memory page corresponding to each application can be accurately determined through the correspondence between the memory page identifier and the application identifier, so that the memory page corresponding to the foreground application and the memory page of the background application can be determined, so as to increase the priority of the memory page corresponding to the foreground application, obtain more memory space for the foreground application, and improve the memory usage efficiency.

[0107] like Figure 4 FIG. 1 is an architecture diagram of a memory processing method in an embodiment. A foreground aware eviction scheme (FAE) is set in the electronic device.

[0108] ① Downloading applications to electronic devices, or updating the versions of applications installed in electronic devices;

[0109] ② When the electronic device installs the application, the electronic device updates the configuration file of the application through the system framework, and the configuration file records the assigned application identifier. The application identifier can be saved in the system page table (Page Table Entry, referred to as PTE) and corresponds to the application package name. When the application is running, the application identifier of the application to which it belongs is marked in the memory page, and the application identifier is used as the memory page identifier of the memory page. In one embodiment, the electronic device uses the Android operating system, and the application runs on the Android operating system.

[0110] ③When the foreground application of the electronic device changes, execute ④.

[0111] ④The system framework determines the currently running foreground application and transmits the application ID of the foreground application.

[0112] ⑤ The foreground-aware removal mechanism of the kernel can obtain the application identifiers of all application programs of the electronic device by accessing the configuration file. In one embodiment, the kernel can obtain the application identifier corresponding to the currently running application program through the foreground-aware removal mechanism.

[0113] ⑥The kernel accesses the configuration file of the foreground application through the foreground perception removal mechanism and obtains the application identifier of the foreground application from the configuration file.

[0114] The foreground-aware removal mechanism can dynamically obtain the application ID of the foreground application, identify the foreground memory page of the foreground application through the application ID, and then adjust the priority of the foreground memory page of the foreground application in the active list and the inactive list, thereby improving the priority of the foreground application in using memory.

[0115] like Figure 5 As shown, it is a schematic diagram of adjusting the priority of a memory page in one embodiment. The electronic device adjusts the priority of the memory page through an active linked list and an inactive linked list. The priority of the active linked list is higher than the priority of the inactive linked list. When the memory page identifier corresponds to the application identifier of the foreground application, it means that the memory page corresponding to the memory page identifier is the foreground memory page. When the memory page identifier corresponds to the application identifier of the background application, it means that the memory page corresponding to the memory page identifier is the background memory page.

[0116] When a memory page in the active linked list or the inactive linked list is accessed, the electronic device may determine whether the accessed memory page is a foreground memory page or a background memory page.

[0117] When the accessed memory page is a background memory page and the background memory page is in the active linked list, the electronic device moves the background memory page to the inactive linked list. When the accessed memory page is a background memory page and the background memory page is in the inactive linked list, the background memory page is retained in the inactive linked list.

[0118] When the accessed memory page is a foreground memory page and the foreground memory page is in the inactive linked list, the electronic device moves the foreground memory page to the active linked list. When the accessed memory page is a foreground memory page and the foreground memory page is in the active linked list, the electronic device retains the foreground memory page in the active linked list.

[0119] The electronic device starts to recycle memory pages from the tail of the inactive linked list. When the memory page is a clean memory page, the electronic device recycles the clean memory page through a recycling process. When the memory page is a dirty memory page, the dirty memory page is written back from the tail of the inactive linked list to the head of the inactive linked list.

[0120] Through the memory processing implemented in this embodiment, the memory allocation and recovery priorities of foreground applications and background applications are adjusted, and the probability of memory pages of foreground applications and background applications being recovered in the system is increased, which can reduce the memory demand of background applications and improve the memory response of foreground applications, thereby improving the user experience of foreground applications.

[0121] In one embodiment, a memory processing method is provided, comprising:

[0122] The electronic device downloads an application or updates an installed application.

[0123] When installing an application, the electronic device configures an application identifier for the installed application.

[0124] Next, the electronic device configures a memory page identifier corresponding to the application identifier for the memory page of the updated application program.

[0125] When the foreground application changes, the electronic device obtains the memory page identification set corresponding to the currently running application.

[0126] Next, the electronic device determines a foreground application and a background application in the currently running application program, and obtains a first application identifier of the foreground application and a second application identifier of the background application.

[0127] Furthermore, the electronic device determines a foreground memory page identifier that matches the first application identifier from the memory page identifier set.

[0128] Next, the electronic device determines the linked list where the foreground memory page corresponding to the foreground memory page identifier is located.

[0129] Optionally, when the foreground memory page is in an inactive linked list, the electronic device moves the foreground memory page to an active linked list; when the foreground memory page is in an active linked list, the electronic device retains the foreground memory page in the active linked list; the priority of the active linked list is higher than the priority of the inactive linked list.

[0130] Optionally, the electronic device determines a background memory page identifier that matches the second application identifier from the memory page identifier set, and determines a linked list where the background memory page corresponding to the background memory page identifier is located.

[0131] When the background memory page is in the active linked list, the electronic device moves the background memory page to the inactive linked list.

[0132] Optionally, when the background memory page is in the inactive linked list, the electronic device retains the background memory page in the inactive linked list.

[0133] Furthermore, the electronic device starts to recycle memory pages from the tail of the inactive linked list, and when the memory page is a clean memory page, the electronic device recycles the clean memory page through a recycling process. When the memory page is a dirty memory page, the dirty memory page is written back from the tail of the inactive linked list to the head of the inactive linked list.

[0134] In this embodiment, a unique application identifier is configured for each application, and when the application is running, the memory page of the application is marked with a memory page identifier corresponding to the application identifier. When the foreground application changes, the identifier of the memory page corresponding to the currently running application is recorded through the memory page identifier set, so that the foreground memory page corresponding to the foreground application and the background memory page corresponding to the background application can be accurately determined based on the corresponding relationship between the application identifier and the memory page identifier.

[0135] The priority of the active list is higher than that of the inactive list. Moving the foreground memory page from the inactive list to the active list can move the foreground memory page to the frequently accessed queue. When the foreground memory page is in the active list, the foreground memory page is kept in the active list to keep the foreground memory page in the frequently accessed queue, which can increase the priority of the foreground application in using memory and reduce the number of repeated page loading errors of the foreground application, thereby speeding up the startup speed of the foreground application.

[0136] For background memory pages in the active linked list, the background memory pages are moved to the inactive linked list, while the background memory pages in the inactive linked list are not moved. All background memory pages can be placed in a queue that is not frequently accessed, which can reduce the priority of background applications in using memory and also speed up the startup speed of foreground applications.

[0137] In addition, by recycling clean memory pages in the inactive linked list, the available memory space can be increased to ensure the normal operation of the application.

[0138] It should be understood that although Figure 2-Figure 3 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 2-Figure 3 At least part of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.

[0139] Figure 6 FIG. 1 is a structural block diagram of a memory processing device according to an embodiment. Figure 6 As shown, the memory processing device includes: an acquisition module 602, a determination module 604 and an adjustment module 606. Among them,

[0140] The acquisition module 602 is used to acquire the memory page identification set corresponding to the currently running application.

[0141] The determination module 604 is used to determine the foreground application and the background application in the currently running application.

[0142] The adjustment module 606 is used to obtain the foreground memory page identifier corresponding to the foreground application in the memory page identifier set, and adjust the priority of the foreground memory page corresponding to the foreground memory page identifier; the adjusted priority of the foreground memory page is higher than the priority of the background memory page of the background application.

[0143] In this embodiment, the memory page identification set corresponding to the currently running application is obtained, and the foreground application and the background application in the currently running application are determined, so that the currently running application can be divided into the foreground application and the background application. By obtaining the foreground memory page identification corresponding to the foreground application in the memory page identification set, the memory pages of the foreground application and the background application can be distinguished to adjust the priority of the foreground memory page corresponding to the foreground memory page identification, and the priority of the foreground memory page can be increased so that the adjusted priority of the foreground memory page is higher than the priority of the background memory page of the background application. By increasing the priority of the foreground memory page, the foreground application can obtain a higher memory usage priority, the foreground application has lower latency, and the response speed is faster.

[0144] In one embodiment, the adjustment module 606 is also used to: obtain the foreground memory page identifier corresponding to the foreground application in the memory page identifier set, determine the linked list where the foreground memory page corresponding to the foreground memory page identifier is located; when the foreground memory page is in the inactive linked list, move the foreground memory page to the active linked list; the priority of the active linked list is higher than the priority of the inactive linked list.

[0145] In this embodiment, the priority of the active linked list is higher than the priority of the inactive linked list. The foreground memory page corresponding to the foreground application is placed in the active linked list, and the foreground memory page can be placed in a queue that is frequently accessed, thereby increasing the priority of the foreground application in using memory, and reducing the number of page repeated loading errors of the foreground application. Page repeated loading error refers to a process in which a page is loaded into the memory for the first time, and after not being accessed for a period of time, the memory space of the page is released, and then when it is accessed again, a page fault interrupt is generated again, and the relevant data needs to be read from the external memory to the memory again. The time difference between reading the external memory and directly reading the memory is very large, which will cause a response delay in the application. In this embodiment, by increasing the priority of the foreground application in using memory and reducing the number of page repeated loading errors of the foreground application, the startup speed of the foreground application can be accelerated.

[0146] In one embodiment, the adjustment module 606 is further configured to: when the foreground memory page is in the active linked list, retain the foreground memory page in the active linked list.

[0147] In this embodiment, when the foreground memory page is in the active linked list, the foreground memory page is retained in the active linked list to keep the foreground memory page in a frequently accessed queue, which can increase the priority of the foreground application in using memory, thereby improving the memory response of the foreground application and improving the user experience of the foreground application.

[0148] In one embodiment, the adjustment module 606 is also used to: obtain the background memory page identifier corresponding to the background application in the memory page identifier set, and adjust the priority of the background memory page corresponding to the background memory page identifier; the priority of the adjusted foreground memory page is higher than the priority of the adjusted background memory page.

[0149] In this embodiment, by obtaining the background memory page identifier corresponding to the background application in the memory page identifier set, the background memory page that the background application is using can be quickly and accurately found through the background memory page identifier. By adjusting the priority of the background memory page corresponding to the background memory page identifier, the priority of the adjusted foreground memory page is higher than the priority of the adjusted background memory page. By increasing the priority of the foreground memory page, the foreground application obtains a higher memory usage priority and the background application obtains a lower memory usage priority, which can reduce the memory demand of the background application and improve the memory response of the foreground application.

[0150] In one embodiment, the adjustment module 606 is also used to: obtain the background memory page identifier corresponding to the background application in the memory page identifier set, determine the linked list where the background memory page corresponding to the background memory page identifier is located; when the background memory page is in the active linked list, move the background memory page to the inactive linked list; the priority of the active linked list is higher than the priority of the inactive linked list.

[0151] In this embodiment, the priority of the active linked list is higher than that of the inactive linked list. For the background memory page in the active linked list, the background memory page is moved to the inactive linked list, and the background memory page can be moved to a queue that is not frequently accessed, thereby reducing the priority of the background application to use memory and speeding up the startup speed of the foreground application.

[0152] In one embodiment, the adjustment module 606 is further configured to: when the background memory page is in the inactive linked list, keep the background memory page in the inactive linked list.

[0153] In this embodiment, when the background memory page is in the inactive linked list, the background memory page is retained in the inactive linked list to keep the background memory page in a queue that is not frequently accessed, thereby reducing the memory demand of the background application and providing more memory for the foreground application.

[0154] In one embodiment, the device further includes: a recycling module. The recycling module is used to determine the clean memory pages in the inactive linked list and recycle the clean memory pages.

[0155] In this embodiment, by recycling clean memory pages in the inactive linked list, available memory space can be increased to ensure the normal operation of the application.

[0156] In one embodiment, the recycling module is further used to determine dirty memory pages in the inactive linked list and recycle the dirty memory pages.

[0157] In one embodiment, the recycling module is also used to determine clean memory pages and dirty memory pages in the inactive linked list, and based on the fact that the priority of clean memory pages is higher than that of dirty memory pages, the clean memory pages and dirty memory pages are recycled in turn.

[0158] In one embodiment, the adjustment module 606 is further used to: obtain a first application identifier of a foreground application and a second application identifier of a background application; determine a foreground memory page identifier that matches the first application identifier from a memory page identifier set; and adjust the priority of a foreground memory page corresponding to the foreground memory page identifier;

[0159] The adjustment module 606 is further used to: determine the background memory page identifier that matches the second application identifier from the memory page identifier set; and adjust the priority of the background memory page corresponding to the background memory page identifier.

[0160] In this embodiment, the application identifier and memory page identifier of the same application program have a corresponding relationship. Then, through the first application identifier of the foreground application and the second application identifier of the background application, the matching foreground memory page identifier and the background memory page identifier can be found from the memory page identifier set, so as to adjust the priority of the foreground memory page corresponding to the foreground memory page identifier and the background memory page corresponding to the background memory page identifier, so as to increase the priority of the foreground memory page and reduce the priority of the background memory page, so that the foreground application obtains a higher memory usage priority and improves the startup speed of the foreground application.

[0161] In one embodiment, the device further includes: a configuration module. The configuration module is used to configure an application identifier for the updated application when there is an update to the application; and to configure a memory page identifier corresponding to the application identifier for the memory page of the updated application.

[0162] In this embodiment, when there is an update to an application, an application identifier is configured for the updated application, and a unique application identifier can be assigned to each application. A memory page identifier corresponding to the application identifier is configured for the memory page of the updated application, and the memory page corresponding to each application can be accurately determined through the correspondence between the memory page identifier and the application identifier, so that the memory page corresponding to the foreground application and the memory page of the background application can be determined, so as to increase the priority of the memory page corresponding to the foreground application, obtain more memory space for the foreground application, and improve the memory usage efficiency.

[0163] The division of the various modules in the above-mentioned memory processing device is only for illustration. In other embodiments, the memory processing device may be divided into different modules as needed to complete all or part of the functions of the above-mentioned memory processing device.

[0164] For the specific definition of the memory processing device, please refer to the definition of the memory processing method above, which will not be repeated here. Each module in the above-mentioned memory processing device can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.

[0165] Figure 7 FIG. 1 is a schematic diagram of the internal structure of an electronic device in one embodiment. Figure 7 As shown, the electronic device includes a processor and a memory connected via a system bus. Among them, the processor is used to provide computing and control capabilities to support the operation of the entire electronic device. In this embodiment, the processor is used to obtain a memory page identification set corresponding to the currently running application, and the processor determines the foreground application and the background application in the currently running application; the processor obtains the foreground memory page identification corresponding to the foreground application in the memory page identification set, and adjusts the priority of the foreground memory page corresponding to the foreground memory page identification, so that the priority of the adjusted foreground memory page is higher than the priority of the background memory page of the background application. The memory may include a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. In this embodiment, the memory is used to store a memory page identification set corresponding to the currently running application. The computer program can be executed by the processor to implement a memory processing method provided in each of the following embodiments. The internal memory provides a cache operating environment for the operating system computer program in the non-volatile storage medium. The electronic device can be any terminal device such as a mobile phone, a tablet computer, a PDA (Personal Digital Assistant), a POS (Point of Sales), a car computer, a wearable device, etc.

[0166] The implementation of each module in the memory processing device provided in the embodiment of the present application can be in the form of a computer program. The computer program can be run on a terminal or a server. The program module constituted by the computer program can be stored in the memory of the electronic device. When the computer program is executed by the processor, the steps of the method described in the embodiment of the present application are implemented.

[0167] The embodiment of the present application also provides a computer-readable storage medium, one or more non-volatile computer-readable storage media containing computer-executable instructions, which, when executed by one or more processors, enable the processors to perform the steps of the memory processing method.

[0168] A computer program product comprising instructions, when executed on a computer, causes the computer to execute a memory processing method.

[0169] Any reference to memory, storage, database or other medium used in this application may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM), which is used as an external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).

[0170] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. A memory processing method, It is characterized in that include: Get the memory page identification set corresponding to the currently running application; Determine a foreground application and a background application in the currently running application; Accessing a configuration file of the foreground application through a foreground awareness removal mechanism, and obtaining a first application identifier of the foreground application from the configuration file of the foreground application; Accessing the configuration file of the background application through the foreground perception removal mechanism, and obtaining the second application identifier of the background application from the configuration file of the background application; Determine, from the memory page identifier set, a foreground memory page identifier that matches the first application identifier, and determine a linked list of foreground memory pages corresponding to the foreground memory page identifier; In the case where the foreground memory page is in the inactive linked list, the foreground memory page is moved to the active linked list through the foreground perception removal mechanism; the memory usage priority of the active linked list is higher than the memory usage priority of the inactive linked list; Determine, from the memory page identifier set, a background memory page identifier that matches the second application identifier through the foreground-aware removal mechanism, and determine a linked list of background memory pages corresponding to the background memory page identifier; In the case where the background memory page is in the active linked list, moving the background memory page to the inactive linked list through the foreground-aware removal mechanism; Determine the clean memory pages and dirty memory pages in the inactive linked list, and based on the priorities of the clean memory pages and the dirty memory pages, recycle the clean memory pages and the dirty memory pages in turn; the priority of the clean memory page is higher than the priority of the dirty memory page.

2. The method according to claim 1, It is characterized in that The method further comprises: In the case that the background memory page is in the inactive linked list, the background memory page is retained in the inactive linked list.

3. The method according to claim 1, It is characterized in that The memory page identification set is used to record the identification of the memory page corresponding to the currently running application program.

4. The method according to any one of claims 1 to 3, It is characterized in that The method further comprises: If there is an update to the application, configure an application identifier for the updated application; A memory page identifier corresponding to the application identifier is configured for the memory page of the updated application program.

5. A memory processing device, It is characterized in that include: An acquisition module is used to acquire a memory page identification set corresponding to a currently running application; A determination module, used to determine a foreground application and a background application in the currently running application; An adjustment module, configured to access a configuration file of the foreground application through a foreground awareness removal mechanism, and obtain a first application identifier of the foreground application from the configuration file of the foreground application; Accessing the configuration file of the background application through the foreground perception removal mechanism, obtaining the second application identifier of the background application from the configuration file of the background application; determining the foreground memory page identifier that matches the first application identifier from the memory page identifier set, and determining the linked list of the foreground memory page corresponding to the foreground memory page identifier; In the case where the foreground memory page is in the inactive linked list, the foreground memory page is moved to the active linked list; the memory usage priority of the active linked list is higher than the memory usage priority of the inactive linked list; from the memory page identifier set, a background memory page identifier matching the second application identifier is determined, and the linked list where the background memory page corresponding to the background memory page identifier is located is determined; When the background memory page is in the active linked list, moving the background memory page to the inactive linked list; A recycling module is used to determine the clean memory pages and dirty memory pages in the inactive linked list, and based on the priority of the clean memory pages and the priority of the dirty memory pages, recycle the clean memory pages and the dirty memory pages in turn; the priority of the clean memory pages is higher than the priority of the dirty memory pages.

6. The device according to claim 5, It is characterized in that The adjustment module is further configured to retain the background memory page in the inactive linked list when the background memory page is in the inactive linked list.

7. The device according to any one of claims 5 to 6, It is characterized in that The device also includes: The configuration module is used to configure an application identifier for the updated application when there is an update to the application; and to configure a memory page identifier corresponding to the application identifier for the memory page of the updated application.

8. An electronic device comprising a memory and a processor, wherein a computer program is stored in the memory, and when the computer program is executed by the processor, the processor executes the steps of the method according to any one of claims 1 to 4.

9. A computer-readable storage medium having a computer program stored thereon, It is characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 4 are implemented.

10. A computer program product comprising a computer program, It is characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 4 are implemented.

Citation Information

Patent Citations

  • A resource allocation method and device

    CN109684090A

  • Memory management method, device and equipment and storage medium

    CN111352863A

  • Memory recovery method and device, electronic equipment and storage medium

    CN111984413A

  • Page management method, page management device, storage medium and electronic equipment

    CN112256997A

  • Multitasking method and electronic device therefor

    US20150160976A1