[go: up one dir, main page]

CN113010228B - Memory processing method, memory processing device, electronic equipment and computer readable storage medium - Google Patents

Memory processing method, memory processing device, electronic equipment and computer readable storage medium Download PDF

Info

Publication number
CN113010228B
CN113010228B CN202110293624.7A CN202110293624A CN113010228B CN 113010228 B CN113010228 B CN 113010228B CN 202110293624 A CN202110293624 A CN 202110293624A CN 113010228 B CN113010228 B CN 113010228B
Authority
CN
China
Prior art keywords
memory page
application
foreground
background
memory
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202110293624.7A
Other languages
Chinese (zh)
Other versions
CN113010228A (en
Inventor
赵庆浩
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guangdong Oppo Mobile Telecommunications Corp Ltd
Original Assignee
Guangdong Oppo Mobile Telecommunications Corp Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Guangdong Oppo Mobile Telecommunications Corp Ltd filed Critical Guangdong Oppo Mobile Telecommunications Corp Ltd
Priority to CN202110293624.7A priority Critical patent/CN113010228B/en
Publication of CN113010228A publication Critical patent/CN113010228A/en
Application granted granted Critical
Publication of CN113010228B publication Critical patent/CN113010228B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44568Immediately runnable code
    • G06F9/44578Preparing or optimising for loading

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Memory System Of A Hierarchy Structure (AREA)

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.

Description

内存处理方法、装置、电子设备和计算机可读存储介质Memory processing method, device, electronic device and computer readable storage medium

技术领域Technical Field

本申请涉及计算机技术领域,特别是涉及一种内存处理方法、装置、电子设备和计算机可读存储介质。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

随着计算机技术的发展,出现了各种类型的应用程序。电子设备能够兼容多个应用程序,但仅能够在前台运行一个应用程序,在后台可能运行多个应用程序。应用程序在后台运行时,会与前台运行的应用进程抢占内存使用,导致前台应用响应速度慢。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

本申请实施例提供了一种内存处理方法、装置、电子设备、计算机可读存储介质,可以提高前台应用的响应速度。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.

一种内存处理方法,包括:A memory processing method, comprising:

获取当前运行的应用程序所对应的内存页标识集;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;

获取所述内存页标识集中与所述前台应用对应的前台内存页标识,调整所述前台内存页标识对应的前台内存页的优先级;调整后的所述前台内存页的优先级高于所述后台应用的后台内存页的优先级。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.

一种内存处理装置,所述装置包括:A memory processing device, the device comprising:

获取模块,用于获取当前运行的应用程序所对应的内存页标识集;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;

调整模块,用于获取所述内存页标识集中与所述前台应用对应的前台内存页标识,调整所述前台内存页标识对应的前台内存页的优先级;调整后的所述前台内存页的优先级高于所述后台应用的后台内存页的优先级。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.

一种计算机设备,包括存储器和处理器,所述存储器存储有计算机程序,所述处理器执行所述计算机程序时实现以下步骤: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:

获取当前运行的应用程序所对应的内存页标识集;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;

获取所述内存页标识集中与所述前台应用对应的前台内存页标识,调整所述前台内存页标识对应的前台内存页的优先级;调整后的所述前台内存页的优先级高于所述后台应用的后台内存页的优先级。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.

一种计算机可读存储介质,其上存储有计算机程序,所述计算机程序被处理器执行时实现以下步骤:A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the following steps:

获取当前运行的应用程序所对应的内存页标识集;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;

获取所述内存页标识集中与所述前台应用对应的前台内存页标识,调整所述前台内存页标识对应的前台内存页的优先级;调整后的所述前台内存页的优先级高于所述后台应用的后台内存页的优先级。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.

上述内存处理方法、装置、电子设备和计算机可读存储介质,获取当前运行的应用程序所对应的内存页标识集,确定当前运行的应用程序中的前台应用和后台应用,能够将当前运行的应用程序划分前、后台应用。获取内存页标识集中与前台应用对应的前台内存页标识,能够区分前台应用和后台应用的内存页,以调整前台内存页标识对应的前台内存页的优先级,能够提高前台内存页的优先级,使得调整后的前台内存页的优先级高于后台应用的后台内存页的优先级。通过提高前台内存页的优先级,使得前台应用能够获得更高的内存使用优先级,前台应用延迟更低,响应速度更快。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

为了更清楚地说明本申请实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。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 any creative work.

图1为一个实施例中内存处理方法的应用环境图;FIG1 is an application environment diagram of a memory processing method according to an embodiment;

图2为一个实施例中内存处理方法的流程图;FIG2 is a flow chart of a memory processing method in one embodiment;

图3为一个实施例中获取内存页标识集中与前台应用对应的前台内存页标识,调整前台内存页标识对应的前台内存页的优先级的流程图;3 is 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 one embodiment;

图4为一个实施例中内存处理方法的架构图;FIG4 is a schematic diagram of a memory processing method in one embodiment;

图5为一个实施例中调整内存页的优先级的示意图;FIG5 is a schematic diagram of adjusting the priority of a memory page in one embodiment;

图6为一个实施例中内存处理装置的结构框图;FIG6 is a block diagram of a memory processing device in one embodiment;

图7为一个实施例中电子设备的部分结构的框图。FIG. 7 is a block diagram of a partial structure of an electronic device in one embodiment.

具体实施方式DETAILED DESCRIPTION

为了使本申请的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本申请进行进一步详细说明。应当理解,此处所描述的具体实施例仅仅用以解释本申请,并不用于限定本申请。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.

可以理解,本申请所使用的术语“第一”、“第二”等可在本文中用于描述各种元件,但这些元件不受这些术语限制。这些术语仅用于将第一个元件与另一个元件区分。举例来说,在不脱离本申请的范围的情况下,可以将第一应用标识称为第二应用标识,且类似地,可将第二应用标识称为第一应用标识。第一应用标识和第二应用标识两者都是应用标识,但其不是同一应用标识。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.

本申请提供的内存处理方法,可以应用于如图1所示的应用环境中。其中,电子设备102通过网络与服务器104进行通信。在一个实施例中,电子设备102可单独执行本申请实施例中提供的内存处理方法。电子设备102和服务器104也可协同用于执行本申请实施例中提供的内存处理方法。当电子设备102和服务器104协同用于执行本申请实施例中提供的内存处理方法时,服务器104存储当前运行的应用程序所对应的内存页标识集。电子设备102可从服务器104获取获取当前运行的应用程序所对应的内存页标识集,电子设备102确定当前运行的应用程序中的前台应用和后台应用。电子设备102可获取内存页标识集中与前台应用对应的前台内存页标识,调整前台内存页标识对应的前台内存页的优先级;调整后的前台内存页的优先级高于后台应用的后台内存页的优先级。其中,电子设备102可以但不限于是各种个人计算机、笔记本电脑、智能手机、平板电脑、便携式可穿戴设备和电视,服务器104可以用独立的服务器或者是多个服务器组成的服务器集群来实现。The memory processing method provided in the present application can be applied in the application environment shown in FIG. 1. 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 adjusted priority of the 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.

图2为一个实施例中内存处理方法的流程图。本实施例中的内存处理方法,以运行于图1中的电子设备上为例进行描述。如图2所示,该内存处理方法包括步骤202至步骤206。Fig. 2 is a flow chart of a memory processing method in an embodiment. The memory processing method in this embodiment is described by taking the memory processing method running on the electronic device in Fig. 1 as an example. As shown in Fig. 2, the memory processing method includes steps 202 to 206.

步骤202,获取当前运行的应用程序所对应的内存页标识集。Step 202: Obtain a memory page identification set corresponding to the currently running application.

其中,当前运行的应用程序是指当前处于运行状态的应用程序,具体可以包括前台应用和后台应用中的至少一种。内存页标识集用于存放内存页对应的标识。前台应用是指用户在电子设备上正在操作状态的应用,后台应用是指用户没有操作但也在电子设备后台运行的应用。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.

具体地,电子设备可获取当前运行的应用程序,并获取当前运行的应用程序所对应的内存页标识集。该内存页标识集用于记录当前运行的应用程序所对应的内存页的标识。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.

在一个实施例中,内存页标识集用于记录当前运行的应用程序所使用的内存页的标识。In one embodiment, the memory page identification set is used to record the identification of the memory pages used by the currently running application.

在一个实施例中,在前台应用发生改变的情况下,电子设备可获取当前运行的应用程序,并获取当前运行的应用程序所对应的内存页标识集。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.

步骤204,确定当前运行的应用程序中的前台应用和后台应用。Step 204: Determine the foreground application and the background application in the currently running application.

具体地,电子设备可从当前运行的应用程序中,分别确定当前运行的前台应用和后台应用。Specifically, the electronic device can determine the currently running foreground application and the background application respectively from the currently running application programs.

在一个实施例中,电子设备可通过运行任务列表,确定当前运行的应用程序中的前台应用和后台应用。电子设备可获取预设时长内的运行任务列表,通过运行任务列表确定当前运行的应用程序中的前台应用和后台应用。即电子设备可获取一组最近运行任务的列表,按时间排序,最近使用的应用排在最前面,则排在最前面的即为前台应用,其余的应用为后台应用。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.

在一个实施例中,电子设备可获取自身运行的应用进程信息列表,根据应用进程信息列表确定当前运行的应用程序中的前台应用和后台应用。当进程中包含后台运行代码时,判定该进程对应的应用程序为后台应用。当应用进程信息列表中的某个进程处于最前端界面的展示状态时,判定该进程对应的应用程序为前台应用。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.

例如,前台应用从应用程序A切换为应用程序B,应用程序A进入后台继续运行,则应用程序A和应用程序B作为当前运行的应用程序,应用程序B为前台应用,应用程序A为后台应用。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.

步骤206,获取内存页标识集中与前台应用对应的前台内存页标识,调整前台内存页标识对应的前台内存页的优先级;调整后的前台内存页的优先级高于后台应用的后台内存页的优先级。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.

其中,前台内存页标识是指前台应用对应的内存页的标识,前台内存页是指前台应用对应的内存页。后台内存页是指后台应用对应的内存页。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.

具体地,优先级是指内存使用的优先级。电子设备可从内存页标识集中,获取与前台应用对应的前台内存页标识。电子设备可确定该前台内存页标识对应的前台内存页,并调整前台内存页的优先级,以提高前台内存页的优先级,使得前台内存页调整后的优先级高于后台应用的后台内存页的优先级。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.

在一个实施例中,电子设备还可从内存页标识集中,获取与后台应用对应的后台内存页标识。后台内存页标识是指后台应用对应的内存页的标识。电子设备可确定该后台内存页标识对应的后台内存页,电子设备可调整前台内存页的优先级,以提高前台内存页的优先级,使得前台内存页调整后的优先级高于后台内存页的优先级。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.

本实施例中,获取当前运行的应用程序所对应的内存页标识集,确定当前运行的应用程序中的前台应用和后台应用,能够将当前运行的应用程序划分前、后台应用。获取内存页标识集中与前台应用对应的前台内存页标识,能够区分前台应用和后台应用的内存页,以调整前台内存页标识对应的前台内存页的优先级,能够提高前台内存页的优先级,使得调整后的前台内存页的优先级高于后台应用的后台内存页的优先级。通过提高前台内存页的优先级,使得前台应用能够获得更高的内存使用优先级,前台应用延迟更低,响应速度更快。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 improved 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 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.

在一个实施例中,获取内存页标识集中与前台应用对应的前台内存页标识,调整前台内存页标识对应的前台内存页的优先级,包括: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:

获取内存页标识集中与前台应用对应的前台内存页标识,确定前台内存页标识对应的前台内存页所处的链表;在前台内存页处于非活动链表内的情况下,将前台内存页移动至活动链表;活动链表的优先级高于非活动链表的优先级。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.

其中,活动链表用于存放经常被访问的处于活跃状态的内存页。非活动链表用于存放可能关联到一个或者多个进程,但是并不经常使用的内存页。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.

具体地,电子设备从内存页标识集中,获取与前台应用对应的前台内存页标识。电子设备确定与前台内存页标识对应的前台内存页,并确定该前台内存页所处的链表。该链表包括活动链表和非活动链表。活动链表使用内存的优先级高于非活动链表。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.

在前台内存页处于非活动链表内时,表示该前台内存页被放置在并不经常访问的队列中,则电子设备将该前台内存页移动至活动链表,从而将前台内存页移动至经常被访问的队列中。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.

在一个实施例中,电子设备可确定处于非活动链表内的每个前台内存页,将每个前台内存页从非活动链表移动至活动链表。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.

在一个实施例中,该链表为LRU(Least Recently Used,最近最少使用)链表,LRU链表分为活动链表和非活动链表。活动链表表示为active链表,非活动链表表示为inactive链表。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.

本实施例中,活动链表的优先级高于非活动链表的优先级,将前台应用对应的前台内存页放置在活动链表中,能够将前台内存页放置在经常被访问的队列中,从而提高前台应用使用内存的优先级,能够减少前台应用的页反复加载错误的次数。页反复加载错误(Foreground Aware Eviction Scheme,简称FAE)是指一种第一次加载页到内存,一段时间未访问之后,该页内存空间被释放,然后再次访问时,再次产生缺页中断,需要再次从外存读取相关数据到内存的过程。而读取外存和直接读取内存的时间差距非常大,会导致应用的响应延迟。本实施例中,通过提高前台应用使用内存的优先级,减少前台应用的页反复加载错误的次数,从而能够加快前台应用的启动速度。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 repetitive loading errors of the foreground application. Page repetitive 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 response delay in the application. In this embodiment, by increasing the priority of the foreground application in using memory, the number of page repetitive loading errors of the foreground application is reduced, thereby speeding up the startup speed of the foreground application.

在一个实施例中,该方法还包括:在前台内存页处于活动链表内的情况下,将前台内存页保留在活动链表内。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.

具体地,电子设备从内存页标识集中,获取与前台应用对应的每个前台内存页标识。针对每个前台内存页标识,电子设备确定与前台内存页标识对应的前台内存页,得到每个前台内存页。针对每个前台内存页,电子设备确定前台内存页所处的链表。针对每个前台内存页,判断前台内存页是否处于活动链表内。在前台内存页处于活动链表内的情况下,不移动该前台内存页,以将该前台内存页保留在活动链表内。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.

本实施例中,在前台内存页处于活动链表内的情况下,将前台内存页保留在活动链表内,以将前台内存页保留在经常被访问的队列中,能够提高前台应用使用内存的优先级,从而提升前台应用的内存响应,提升前台应用的用户体验。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.

在一个实施例中,该方法还包括:获取内存页标识集中与后台应用对应的后台内存页标识,调整后台内存页标识对应的后台内存页的优先级;调整后的前台内存页的优先级高于调整后的后台内存页的优先级。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.

具体地,电子设备可从内存页标识集中,获取与前台应用对应的前台内存页标识。电子设备可确定该前台内存页标识对应的前台内存页,并调整前台内存页的优先级,以提高前台内存页的优先级。Specifically, the electronic device may 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.

并且,电子设备还可从内存页标识集中,获取与后台应用对应的后台内存页标识。电子设备可确定该后台内存页标识对应的后台内存页,电子设备可调整后台内存页的优先级,以降低前台内存页的优先级,使得前台内存页调整后的优先级高于后台内存页调整后的优先级。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.

在一个实施例中,电子设备可确定前台内存页标识对应的前台内存页和后台内存页标识对应的后台内存页,电子设备可获取前台内存页和后台内存页的优先级,将前台内存页和后台内存页的优先级进行对比。在前台内存页的优先级低于后台内存页的优先级的情况下,调整该前台内存页的优先级,以提高该前台内存页的优先级,使得该前台内存页的优先级高于该后台内存页的优先级。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.

在一个实施例,在前台内存页的优先级低于后台内存页的优先级的情况下,电子设备可调整该后台内存页的优先级,以降低该后台内存页的优先级,使得该前台内存页的优先级高于该后台内存页的优先级。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.

在一个实施例,在前台内存页的优先级低于后台内存页的优先级的情况下,电子设备可同时调整该前台内存页和后台内存页的优先级,以提高该前台内存页的优先级、降低该后台内存页的优先级,使得该前台内存页的优先级高于该后台内存页的优先级。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.

本实施例中,通过获取内存页标识集中与后台应用对应的后台内存页标识,以通过后台内存页标识快速准确查找后台应用正在使用后台内存页。通过调整后台内存页标识对应的后台内存页的优先级,使得调整后的前台内存页的优先级高于调整后的后台内存页的优先级,通过提高前台内存页的优先级,使得前台应用获得更高的内存使用优先级、后台应用获得更低的内存使用优先级,能够降低后台应用的对于内存的需求,提升前台应用的内存响应。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.

在一个实施例中,获取内存页标识集中与后台应用对应的后台内存页标识,调整后台内存页标识对应的后台内存页的优先级,包括: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:

获取内存页标识集中与后台应用对应的后台内存页标识,确定后台内存页标识对应的后台内存页所处的链表;在后台内存页处于活动链表内的情况下,将后台内存页移动至非活动链表;活动链表的优先级高于非活动链表的优先级。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.

具体地,电子设备从内存页标识集中,获取与后台应用对应的后台内存页标识。电子设备确定与后台内存页标识对应的后台内存页,并确定该后台内存页所处的链表。该链表包括活动链表和非活动链表。活动链表使用内存的优先级高于非活动链表。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.

在后台内存页处于活动链表内时,表示该后台内存页被放置在经常被访问的队列,则电子设备将该后台内存页移动至活动链表,从而将后台内存页移动至不经常被访问的队列。针对每个后台内存页进行相同的处理,以将每个处于活动链表内的后台内存页移动至非活动链表。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.

本实施例中,活动链表的优先级高于非活动链表的优先级。对于处于活动链表内的后台内存页,将后台内存页移动至非活动链表中,能够将后台内存页移动至不经常被访问的队列中,从而降低后台应用使用内存的优先级,能够加快前台应用的启动速度。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.

在一个实施例中,该方法还包括:在后台内存页处于非活动链表内的情况下,将后台内存页保留在非活动链表内。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.

具体地,电子设备从内存页标识集中,获取与后台应用对应的每个后台内存页标识。针对每个后台内存页标识,电子设备确定与后台内存页标识对应的后台内存页,得到每个后台内存页。针对每个后台内存页,电子设备确定后台内存页所处的链表。针对每个后台内存页,判断后台内存页是否处于非活动链表内。在后台内存页处于非活动链表内的情况下,移动该后台内存页,以将该后台内存页保留在活动链表内。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.

本实施例中,在后台内存页处于非活动链表内的情况下,将后台内存页保留在非活动链表内,以将后台内存页保留在不经常被访问的队列中,从而能够降低后台应用的对于内存的需求,为前台应用提供更多的内存。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.

在一个实施例中,该方法还包括:确定非活动链表中的干净内存页,并对干净内存页进行回收处理。In one embodiment, the method further includes: determining clean memory pages in the inactive linked list, and recycling the clean memory pages.

其中,干净内存页是指内存空间中未经修改的内存页,干净内存页可以为一个或多个内存页。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.

具体地,电子设备可确定非活动链表中的干净内存页,并通过回收进程对干净内存页进行回收处理。例如通过kswapd进程对非活动链表中的干净内存页进行回收处理。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.

本实施例中,通过对非活动链表中的干净内存页进行回收,能够增加可使用的内存空间,保证应用程序的正常运行。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.

在一个实施例中,该方法还包括:确定非活动链表中的脏内存页,并对脏内存页进行回收处理。In one embodiment, the method further includes: determining dirty memory pages in the inactive linked list, and recycling the dirty memory pages.

其中,脏内存页是指内存空间中经过修改的内存页,脏内存页可以为一个或多个内存页。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.

具体地,电子设备可确定非活动链表中的脏内存页,并通过回收进程对脏内存页进行存储和回收处理。例如通过kdflush进程对脏内存页进行存储处理和回收处理。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.

在一个实施例中,该方法还包括:确定非活动链表中的干净内存页和脏内存页,基于干净内存页的优先级高于脏内存页的优先级,依次干净内存页和脏内存页对进行回收处理。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.

具体地,电子设备可以直接对干净内存页进行回收处理,而在对脏内存页进行回收处理前,还需要将其进行存储,相比于干净内存页的处理时间,脏内存页的处理时间更长。本实施例中优先回收干净内存页,可以提高内存回收的效率。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.

在一个实施例中,如图3所示,获取内存页标识集中与前台应用对应的前台内存页标识,调整前台内存页标识对应的前台内存页的优先级,包括:In one embodiment, as shown in FIG. 3 , 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:

步骤302,获取前台应用的第一应用标识和后台应用的第二应用标识。Step 302: Obtain a first application identifier of a foreground application and a second application identifier of a background application.

具体地,在当前运行的应用程序被划分为前台应用和后台应用的情况下,应用程序的应用标识被相应划分为第一应用标识和第二应用标识。第一应用标识是指前台应用对应的应用标识,第二应用标识是指后台应用对应的应用标识。电子设备确定当前运行的应用程序后,可确定该当前运行的应用程序中的前台应用和后台应用。电子设备可获取该前台应用对应的第一应用标识和后台应用对应的第二应用标识。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.

在一个实施例中,电子设备可通过内核kernel获取前台应用的配置文件,从前台应用的配置文件中获取该前台应用的第一应用标识。电子设备可通过内核kernel获取后台应用的配置文件,从后台应用的配置文件中获取该后台应用的第二应用标识。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.

步骤304,从内存页标识集中,确定与第一应用标识相匹配的前台内存页标识。Step 304: Determine a foreground memory page identifier that matches the first application identifier from the memory page identifier set.

具体地,电子设备将第一应用标识和内存页标识集中的各个内存页标识进行匹配处理,以确定与第一应用标识相匹配的内存页标识。电子设备将内存页标识集中与第一应用标识相匹配的内存页标识,判定为前台内存页标识。按照相同的处理方式,电子设备可从内存页标识集中,筛选出每个与第一应用标识相匹配的前台内存页标识。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.

步骤306,调整前台内存页标识对应的前台内存页的优先级。Step 306: adjust the priority of the foreground memory page corresponding to the foreground memory page identifier.

具体地,电子设备可确定每个前台内存页标识分别对应的前台内存页,以调整每个前台内存页的优先级,使得每个前台内存页的优先级高于后台内存页的优先级。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.

在一个实施例中,电子设备在确定各个前台内存页后,确定每个前台内存页的优先级和每个后台内存页的优先级。筛选出优先级低于后台内存页的前台内存页,提高所筛选出的前台内存页的优先级,使得每个前台内存页的优先级高于后台内存页的优先级。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 page with a lower priority than the background memory page, and increases the priority of the selected foreground memory page so that the priority of each foreground memory page is higher than the priority of the background memory page.

获取内存页标识集中与后台应用对应的后台内存页标识,调整后台内存页标识对应的后台内存页的优先级,包括: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:

步骤308,从内存页标识集中,确定与第二应用标识相匹配的后台内存页标识。Step 308: Determine a background memory page identifier that matches the second application identifier from the memory page identifier set.

具体地,电子设备将第二应用标识和内存页标识集中的各个内存页标识进行匹配处理,以确定与第二应用标识相匹配的内存页标识。电子设备将内存页标识集中与第二应用标识相匹配的内存页标识,判定为后台内存页标识。按照相同的处理方式,电子设备可从内存页标识集中,筛选出每个与第二应用标识相匹配的后台内存页标识。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.

步骤310,调整后台内存页标识对应的后台内存页的优先级。Step 310: Adjust the priority of the background memory page corresponding to the background memory page identifier.

具体地,电子设备可确定每个后台内存页标识分别对应的后台内存页,调整每个后台内存页的优先级,以降低每个后台内存页的优先级,使得每个前台内存页的优先级高于后台内存页的优先级。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.

在一个实施例中,电子设备在确定各个后台内存页后,确定每个前台内存页的优先级和每个后台内存页的优先级。筛选出优先级高于前台内存页的后台内存页,降低所筛选出的后台内存页的优先级,使得每个前台内存页的优先级高于后台内存页的优先级。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.

可以理解,步骤304-306和步骤308-310的执行顺序不受限制,电子设备可先执行步骤304-306后执行308-310、也可以先执行步骤308-310后执行304-306,也可以同时执行步骤304-306和步骤308-310的操作。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.

本实施例中,同一应用程序的应用标识和内存页标识具有对应关系,则通过前台应用的第一应用标识和后台应用的第二应用标识,能够从内存页标识集中查找到相匹配的前台内存页标识和后台内存页标识,从而分别对前台内存页标识对应的前台内存页和后台内存页标识对应的后台内存页进行优先级调整,以提高前台内存页的优先级、降低后台内存页的优先级,使得前台应用获得更高的内存使用优先级,提升前台应用的启动速度。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.

在一个实施例中,该方法还包括:在应用程序存在更新的情况下,对更新的应用程序配置应用标识;对更新的应用程序的内存页,配置与应用标识相对应的内存页标识。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.

其中,应用标识是指电子设备为自身的应用程序配置的唯一标识,例如电子设备上安装了应用程序A、应用程序B和应用程序C,则电子设备可分别为应用程序A、应用程序B和应用程序C分配不同的应用标识。同一应用程序的应用标识和内存页标识具有对应关系。例如,应用程序A的标识为A,应用程序A对应的内存页标识为A-1、应用程序A的多个内存页可使用相同的内存页标识,也可以使用不同的内存页标识,例如A-1、A-2、A-3等。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.

具体地,电子设备在自身的应用程序存在更新的情况下,可确定存在更新的应用程序。应用程序存在更新是指电子设备中下载了新的应用程序或者更新了原有应用程序的版本。电子设备可对存在更新的应用程序进行配置,以对该应用程序分配唯一的应用标识。电子设备可确定该更新的应用程序所对应的内存页,对该更新的应用程序所对应的内存页配置内存页标识,所配置的内存页标识与该更新的应用程序的应用标识具有对应关系。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.

在一个实施例中,更新的应用程序被运行时,电子设备确定该更新的应用程序所使用的内存页,对所使用的内存页配置与应用标识对应的内存页标识。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.

在一个实施例中,电子设备在安装存在更新的应用程序时,对更新的应用程序配置应用标识。In one embodiment, when installing an updated application, the electronic device configures an application identifier for the updated application.

在一个实施例中,同一应用程序的应用标识和内存页标识可相同。电子设备可对内存页所属应用程序的应用标识,该应用标识作为内存页的内存页标识。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.

本实施例中,在应用程序存在更新的情况下,对更新的应用程序配置应用标识,能够对每个应用程序分配唯一的应用标识。对更新的应用程序的内存页,配置与应用标识相对应的内存页标识,通过内存页标识和应用标识的对应关系,能够准确确定各个应用程序对应的内存页,从而能够确定前台应用对应的内存页和后台应用的内存页,以提高前台应用对应的内存页的优先级,为前台应用获得更多的内存空间,提高内存使用效率。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.

如图4所示,为一个实施例中内存处理方法的架构图。电子设备中设置前台感知移除机制(Foreground Aware Eviction Scheme,简称FAE)。As shown in Fig. 4, it is an architecture diagram of a memory processing method in an embodiment. A foreground aware eviction scheme (FAE) is set in the electronic device.

①电子设备下载应用程序,或者对电子设备中已安装的应用程序进行版本更新;① Downloading applications to electronic devices, or updating the versions of applications installed in electronic devices;

②在电子设备安装该应用程序时,电子设备通过系统框架更新该应程序的配置文件,该配置文件中记录分配的应用标识。该应用标识可保存在系统页表(Page TableEntry,简称PTE)里面,并和应用程序包名对应起来。应用程序运行时,内存页中标记所属应用程序的应用标识,该应用标识作为内存页的内存页标识。在一个实施例中,电子设备使用安卓操作系统,应用程序运行于安卓操作系统上。② 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.

③当电子设备的前台应用发生变化时,执行④。③When the foreground application of the electronic device changes, execute ④.

④系统框架确定当前运行的前台应用,传送前台应用的应用标识。④The system framework determines the currently running foreground application and transmits the application ID of the foreground application.

⑤内核Kernel的前台感知移除机制可通过访问配置文件,获取电子设备的所有应用程序的应用标识。在一个实施例中,内核Kernel通过前台感知移除机制可获取当前运行的应用程序对应的应用标识。⑤ 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.

⑥内核Kernel通过前台感知移除机制访问前台应用的配置文件,从配置文件中获取前台应用的应用标识。⑥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.

前台感知移除机制能够动态获得前台应用的应用标识,通过应用标识识别前台应用的前台内存页,然后调整前台应用的前台内存页在活动链表和非活动链表中的优先级,从而提高前台应用使用内存的优先级。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.

如图5所示,为一个实施例中调整内存页的优先级的示意图。电子设备通过活动链表和非活动链表调整内存页的优先级。活动链表的优先级高于非活动链表的优先级。当内存页标识对应前台应用的应用标识时,表示该内存页标识对应的内存页为前台内存页。当内存页标识对应后台应用的应用标识时,表示该内存页标识对应的内存页为后台内存页。As shown in Figure 5, 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.

当活动链表或非活动链表中的内存页被访问时,电子设备可确定被访问的内存页为前台内存页还是后台内存页。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.

在被访问的内存页为后台内存页,且后台内存页处于活动链表内的情况下,电子设备将该后台内存页移动至非活动链表。在被访问的内存页为后台内存页,且后台内存页处于非活动链表内的情况下,将后台内存页保留在非活动链表内。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.

在被访问的内存页为前台内存页,且前台内存页处于非活动链表内的情况下,电子设备将前台内存页移动至活动链表。在被访问的内存页为前台内存页,且前台内存页处于活动链表内的情况下,电子设备将前台内存页保留在活动链表内。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.

电子设备从非活动链表的尾部开始回收内存页,当内存页为干净内存页,电子设备通过回收进程对干净内存页进行回收处理。当内存页为脏内存页时,将脏内存页从非活动链表的尾部回写至非活动链表的头部。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.

通过本实施的内存处理,调整前台应用、后台应用的内存分配回收优先级,前台应用、后台应用的内存页在系统中被回收的概率,能够降低后台应用的对于内存的需求,提升前台应用的内存响应,从而提升前台应用的用户体验。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 can be 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.

在一个实施例中,提供了一种内存处理方法,包括:In one embodiment, a memory processing method is provided, comprising:

电子设备下载应用程序,或对已安装的应用程序进行更新。The electronic device downloads an application or updates an installed application.

在安装应用程序时,电子设备对所安装的应用程序配置应用标识。When installing an application, the electronic device configures an application identifier for the installed application.

接着,电子设备对更新的应用程序的内存页,配置与应用标识相对应的内存页标识。Next, the electronic device configures a memory page identifier corresponding to the application identifier for the memory page of the updated application program.

当前台应用发生改变时,电子设备获取当前运行的应用程序所对应的内存页标识集。When the foreground application changes, the electronic device obtains the memory page identification set corresponding to the currently running application.

接着,电子设备确定当前运行的应用程序中的前台应用和后台应用,并获取前台应用的第一应用标识和后台应用的第二应用标识。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.

进一步地,电子设备从内存页标识集中,确定与第一应用标识相匹配的前台内存页标识。Furthermore, the electronic device determines a foreground memory page identifier that matches the first application identifier from the memory page identifier set.

接着,电子设备确定前台内存页标识对应的前台内存页所处的链表。Next, the electronic device determines the linked list where the foreground memory page corresponding to the foreground memory page identifier is located.

可选地,在前台内存页处于非活动链表内的情况下,电子设备将前台内存页移动至活动链表;在前台内存页处于活动链表内的情况下,电子设备将前台内存页保留在活动链表内;活动链表的优先级高于非活动链表的优先级。Optionally, when 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 foreground memory page is in the 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.

可选地,从内存页标识集中,电子设备确定与第二应用标识相匹配的后台内存页标识,并确定后台内存页标识对应的后台内存页所处的链表。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.

在后台内存页处于活动链表内的情况下,电子设备将后台内存页移动至非活动链表。When the background memory page is in the active linked list, the electronic device moves the background memory page to the inactive linked list.

可选地,在后台内存页处于非活动链表内的情况下,电子设备将后台内存页保留在非活动链表内。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.

进一步地,电子设备从非活动链表的尾部开始回收内存页,当内存页为干净内存页,电子设备通过回收进程对干净内存页进行回收处理。当内存页为脏内存页时,将脏内存页从非活动链表的尾部回写至非活动链表的头部。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.

本实施例中,对每个应用程序配置唯一的应用标识,在应用程序运行时,对应用程序的内存页标记语应用标识相对应的内存页标识。在前台应用发生改变时,通过内存页标识集记录当前运行的应用程序所对应的内存页的标识,从而根据应用标识和内存页标识之间的对应关系,准确确定前台应用对应的前台内存页和后台应用对应的后台内存页。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.

活动链表的优先级高于非活动链表的优先级,将前台内存页从非活动链表移动至活动链表,能够将前台内存页移动至经常被访问的队列中。在前台内存页处于活动链表内的情况下,将前台内存页保留在活动链表内,以将前台内存页保留在经常被访问的队列中,能够提高前台应用使用内存的优先级,减少前台应用的页反复加载错误的次数,从而能够加快前台应用的启动速度。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 retained in the active list to retain 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.

对于处于活动链表内的后台内存页,将后台内存页移动至非活动链表中,而处于非活动链表内的后台内存页不进行移动,能够将后台内存页全部放置在不经常被访问的队列中,能够降低后台应用使用内存的优先级,同样能够加快前台应用的启动速度。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. This can place all background memory pages 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.

并且,通过对非活动链表中的干净内存页进行回收,能够增加可使用的内存空间,保证应用程序的正常运行。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.

应该理解的是,虽然图2-图3的流程图中的各个步骤按照箭头的指示依次显示,但是这些步骤并不是必然按照箭头指示的顺序依次执行。除非本文中有明确的说明,这些步骤的执行并没有严格的顺序限制,这些步骤可以以其它的顺序执行。而且,图2-图3中的至少一部分步骤可以包括多个子步骤或者多个阶段,这些子步骤或者阶段并不必然是在同一时刻执行完成,而是可以在不同的时刻执行,这些子步骤或者阶段的执行顺序也不必然是依次进行,而是可以与其它步骤或者其它步骤的子步骤或者阶段的至少一部分轮流或者交替地执行。It should be understood that, although the various steps in the flow charts of Fig. 2-Fig. 3 are shown in sequence according to the indication of the arrows, these steps are not necessarily performed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be performed in other orders. Moreover, at least a portion of the steps in Fig. 2-Fig. 3 may include a plurality of sub-steps or a plurality of stages, and these sub-steps or stages are not necessarily performed at the same time, but can be performed at different times, and the execution order of these sub-steps or stages is not necessarily performed in sequence, but can be performed in turn or alternately with at least a portion of other steps or sub-steps or stages of other steps.

图6为一个实施例的内存处理装置的结构框图。如图6所示,该内存处理装置包括:获取模块602、确定模块604和调整模块606。其中,FIG6 is a block diagram of a memory processing device according to an embodiment. As shown in FIG6 , the memory processing device includes: an acquisition module 602, a determination module 604 and an adjustment module 606.

获取模块602,用于获取当前运行的应用程序所对应的内存页标识集。The acquisition module 602 is used to acquire the memory page identification set corresponding to the currently running application.

确定模块604,用于确定当前运行的应用程序中的前台应用和后台应用。The determination module 604 is used to determine the foreground application and the background application in the currently running application.

调整模块606,用于获取内存页标识集中与前台应用对应的前台内存页标识,调整前台内存页标识对应的前台内存页的优先级;调整后的前台内存页的优先级高于后台应用的后台内存页的优先级。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.

本实施例中,获取当前运行的应用程序所对应的内存页标识集,确定当前运行的应用程序中的前台应用和后台应用,能够将当前运行的应用程序划分前、后台应用。获取内存页标识集中与前台应用对应的前台内存页标识,能够区分前台应用和后台应用的内存页,以调整前台内存页标识对应的前台内存页的优先级,能够提高前台内存页的优先级,使得调整后的前台内存页的优先级高于后台应用的后台内存页的优先级。通过提高前台内存页的优先级,使得前台应用能够获得更高的内存使用优先级,前台应用延迟更低,响应速度更快。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 improved 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 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.

在一个实施例中,该调整模块606还用于:获取内存页标识集中与前台应用对应的前台内存页标识,确定前台内存页标识对应的前台内存页所处的链表;在前台内存页处于非活动链表内的情况下,将前台内存页移动至活动链表;活动链表的优先级高于非活动链表的优先级。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.

本实施例中,活动链表的优先级高于非活动链表的优先级,将前台应用对应的前台内存页放置在活动链表中,能够将前台内存页放置在经常被访问的队列中,从而提高前台应用使用内存的优先级,能够减少前台应用的页反复加载错误的次数。页反复加载错误是指一种第一次加载页到内存,一段时间未访问之后,该页内存空间被释放,然后再次访问时,再次产生缺页中断,需要再次从外存读取相关数据到内存的过程。而读取外存和直接读取内存的时间差距非常大,会导致应用的响应延迟。本实施例中,通过提高前台应用使用内存的优先级,减少前台应用的页反复加载错误的次数,从而能够加快前台应用的启动速度。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 internal 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.

在一个实施例中,该调整模块606还用于:在前台内存页处于活动链表内的情况下,将前台内存页保留在活动链表内。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.

本实施例中,在前台内存页处于活动链表内的情况下,将前台内存页保留在活动链表内,以将前台内存页保留在经常被访问的队列中,能够提高前台应用使用内存的优先级,从而提升前台应用的内存响应,提升前台应用的用户体验。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.

在一个实施例中,该调整模块606还用于:获取内存页标识集中与后台应用对应的后台内存页标识,调整后台内存页标识对应的后台内存页的优先级;调整后的前台内存页的优先级高于调整后的后台内存页的优先级。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.

本实施例中,通过获取内存页标识集中与后台应用对应的后台内存页标识,以通过后台内存页标识快速准确查找后台应用正在使用后台内存页。通过调整后台内存页标识对应的后台内存页的优先级,使得调整后的前台内存页的优先级高于调整后的后台内存页的优先级,通过提高前台内存页的优先级,使得前台应用获得更高的内存使用优先级、后台应用获得更低的内存使用优先级,能够降低后台应用的对于内存的需求,提升前台应用的内存响应。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.

在一个实施例中,该调整模块606还用于:获取内存页标识集中与后台应用对应的后台内存页标识,确定后台内存页标识对应的后台内存页所处的链表;在后台内存页处于活动链表内的情况下,将后台内存页移动至非活动链表;活动链表的优先级高于非活动链表的优先级。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.

本实施例中,活动链表的优先级高于非活动链表的优先级。对于处于活动链表内的后台内存页,将后台内存页移动至非活动链表中,能够将后台内存页移动至不经常被访问的队列中,从而降低后台应用使用内存的优先级,能够加快前台应用的启动速度。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.

在一个实施例中,该调整模块606还用于:在后台内存页处于非活动链表内的情况下,将后台内存页保留在非活动链表内。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.

本实施例中,在后台内存页处于非活动链表内的情况下,将后台内存页保留在非活动链表内,以将后台内存页保留在不经常被访问的队列中,从而能够降低后台应用的对于内存的需求,为前台应用提供更多的内存。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.

在一个实施例中,该装置还包括:回收模块。该回收模块用于确定非活动链表中的干净内存页,并对干净内存页进行回收处理。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.

本实施例中,通过对非活动链表中的干净内存页进行回收,能够增加可使用的内存空间,保证应用程序的正常运行。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.

在一个实施例中,该回收模块还用于确定非活动链表中的脏内存页,并对脏内存页进行回收处理。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.

在一个实施例中,该回收模块还用于确定非活动链表中的干净内存页和脏内存页,基于干净内存页的优先级高于脏内存页的优先级,依次干净内存页和脏内存页对进行回收处理。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.

在一个实施例中,该调整模块606还用于:获取前台应用的第一应用标识和后台应用的第二应用标识;从内存页标识集中,确定与第一应用标识相匹配的前台内存页标识;调整前台内存页标识对应的前台内存页的优先级;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;

该调整模块606还用于:从内存页标识集中,确定与第二应用标识相匹配的后台内存页标识;调整后台内存页标识对应的后台内存页的优先级。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.

本实施例中,同一应用程序的应用标识和内存页标识具有对应关系,则通过前台应用的第一应用标识和后台应用的第二应用标识,能够从内存页标识集中查找到相匹配的前台内存页标识和后台内存页标识,从而分别对前台内存页标识对应的前台内存页和后台内存页标识对应的后台内存页进行优先级调整,以提高前台内存页的优先级、降低后台内存页的优先级,使得前台应用获得更高的内存使用优先级,提升前台应用的启动速度。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.

在一个实施例中,该装置还包括:配置模块。该配置模块用于在应用程序存在更新的情况下,对更新的应用程序配置应用标识;对更新的应用程序的内存页,配置与应用标识相对应的内存页标识。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.

本实施例中,在应用程序存在更新的情况下,对更新的应用程序配置应用标识,能够对每个应用程序分配唯一的应用标识。对更新的应用程序的内存页,配置与应用标识相对应的内存页标识,通过内存页标识和应用标识的对应关系,能够准确确定各个应用程序对应的内存页,从而能够确定前台应用对应的内存页和后台应用的内存页,以提高前台应用对应的内存页的优先级,为前台应用获得更多的内存空间,提高内存使用效率。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.

上述内存处理装置中各个模块的划分仅用于举例说明,在其他实施例中,可将内存处理装置按照需要划分为不同的模块,以完成上述内存处理装置的全部或部分功能。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.

关于内存处理装置的具体限定可以参见上文中对于内存处理方法的限定,在此不再赘述。上述内存处理装置中的各个模块可全部或部分通过软件、硬件及其组合来实现。上述各模块可以硬件形式内嵌于或独立于计算机设备中的处理器中,也可以以软件形式存储于计算机设备中的存储器中,以便于处理器调用执行以上各个模块对应的操作。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.

图7为一个实施例中电子设备的内部结构示意图。如图7所示,该电子设备包括通过系统总线连接的处理器和存储器。其中,该处理器用于提供计算和控制能力,支撑整个电子设备的运行。本实施例中,该处理器用于获取当前运行的应用程序所对应的内存页标识集,该处理器确定当前运行的应用程序中的前台应用和后台应用;该处理器获取内存页标识集中与前台应用对应的前台内存页标识,调整前台内存页标识对应的前台内存页的优先级,以使调整后的前台内存页的优先级高于后台应用的后台内存页的优先级。存储器可包括非易失性存储介质及内存储器。非易失性存储介质存储有操作系统和计算机程序。本实施例中,该存储器用于存储当前运行的应用程序对应的内存页标识集。该计算机程序可被处理器所执行,以用于实现以下各个实施例所提供的一种内存处理方法。内存储器为非易失性存储介质中的操作系统计算机程序提供高速缓存的运行环境。该电子设备可以是手机、平板电脑、PDA(Personal Digital Assistant,个人数字助理)、POS(Point of Sales,销售终端)、车载电脑、穿戴式设备等任意终端设备。FIG7 is a schematic diagram of the internal structure of an electronic device in an embodiment. As shown in FIG7 , 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.

本申请实施例中提供的内存处理装置中的各个模块的实现可为计算机程序的形式。该计算机程序可在终端或服务器上运行。该计算机程序构成的程序模块可存储在电子设备的存储器上。该计算机程序被处理器执行时,实现本申请实施例中所描述方法的步骤。The implementation of each module in the memory processing device provided in the embodiment of the present application may be in the form of a computer program. The computer program may be run on a terminal or a server. The program module constituted by the computer program may be stored in the memory of an electronic device. When the computer program is executed by a processor, the steps of the method described in the embodiment of the present application are implemented.

本申请实施例还提供了一种计算机可读存储介质。一个或多个包含计算机可执行指令的非易失性计算机可读存储介质,当所述计算机可执行指令被一个或多个处理器执行时,使得所述处理器执行内存处理方法的步骤。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.

一种包含指令的计算机程序产品,当其在计算机上运行时,使得计算机执行内存处理方法。A computer program product comprising instructions, when executed on a computer, causes the computer to execute a memory processing method.

本申请所使用的对存储器、存储、数据库或其它介质的任何引用可包括非易失性和/或易失性存储器。非易失性存储器可包括只读存储器(ROM)、可编程ROM(PROM)、电可编程ROM(EPROM)、电可擦除可编程ROM(EEPROM)或闪存。易失性存储器可包括随机存取存储器(RAM),它用作外部高速缓冲存储器。作为说明而非局限,RAM以多种形式可得,诸如静态RAM(SRAM)、动态RAM(DRAM)、同步DRAM(SDRAM)、双数据率SDRAM(DDR SDRAM)、增强型SDRAM(ESDRAM)、同步链路(Synchlink)DRAM(SLDRAM)、存储器总线(Rambus)直接RAM(RDRAM)、直接存储器总线动态RAM(DRDRAM)、以及存储器总线动态RAM(RDRAM)。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).

以上所述实施例仅表达了本申请的几种实施方式,其描述较为具体和详细,但并不能因此而理解为对本申请专利范围的限制。应当指出的是,对于本领域的普通技术人员来说,在不脱离本申请构思的前提下,还可以做出若干变形和改进,这些都属于本申请的保护范围。因此,本申请专利的保护范围应以所附权利要求为准。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 (10)

1. A memory processing method, comprising:
Acquiring a memory page identification set corresponding to a currently running application program;
determining a foreground application and a background application in the currently running application program;
Accessing a configuration file of the foreground application through a foreground perception removal mechanism, and acquiring 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 acquiring a second application identifier of the background application from the configuration file of the background application;
Determining a foreground memory page identifier matched with the first application identifier from the memory page identifier set through the foreground perception removal mechanism, and determining a linked list where a foreground memory page corresponding to the foreground memory page identifier is located;
under the condition that the foreground memory page is in an inactive linked list, the foreground memory page is moved to the active linked list through the foreground perception removing mechanism; the memory use priority of the active linked list is higher than the memory use priority of the inactive linked list;
Determining a background memory page identifier matched with the second application identifier from the memory page identifier set through the foreground perception removal mechanism, and determining a linked list where a background memory page corresponding to the background memory page identifier is located;
when the background memory page is in the active linked list, the background memory page is moved to the inactive linked list through the foreground perception removing mechanism;
determining a clean memory page and a dirty memory page in the inactive linked list, and sequentially recycling the clean memory page and the dirty memory page based on the priority of the clean memory page and the priority of the dirty memory page; the clean memory pages have a higher priority than the dirty memory pages.
2. The method according to claim 1, wherein the method further comprises:
and under the condition that the background memory page is in an inactive linked list, the background memory page is reserved in the inactive linked list.
3. The method of claim 1, wherein the set of memory page identifiers is used to record an identifier of a memory page corresponding to a currently running application.
4. A method according to any one of claims 1 to 3, further comprising:
In the case that the application program has an update, configuring an application identifier for the updated application program;
and configuring a memory page identifier corresponding to the application identifier for the memory page of the updated application program.
5. A memory processing apparatus, comprising:
The acquisition module is used for acquiring a memory page identification set corresponding to the currently running application program;
The determining module is used for determining a foreground application and a background application in the currently running application program;
The adjusting module is used for accessing the configuration file of the foreground application through a foreground perception removing mechanism and acquiring 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 acquiring a second application identifier of the background application from the configuration file of the background application; determining a foreground memory page identifier matched with the first application identifier from the memory page identifier set, and determining a linked list where a foreground memory page corresponding to the foreground memory page identifier is located; moving the foreground memory page to an active linked list under the condition that the foreground memory page is in the inactive linked list; the memory use priority of the active linked list is higher than the memory use priority of the inactive linked list; determining a background memory page identifier matched with the second application identifier from the memory page identifier set, and determining a linked list where a background memory page corresponding to the background memory page identifier is located; moving the background memory page to the inactive linked list under the condition that the background memory page is in the active linked list;
The recovery module is used for determining a clean memory page and a dirty memory page in the inactive linked list, and sequentially carrying out recovery processing on the clean memory page and the dirty memory page based on the priority of the clean memory page and the priority of the dirty memory page; the clean memory pages have a higher priority than the dirty memory pages.
6. The apparatus of claim 5, wherein the adjustment module is further configured to retain the background memory page in the inactive linked list if the background memory page is in the inactive linked list.
7. The apparatus according to any one of claims 5 to 6, further comprising:
The configuration module is used for configuring application identification for the updated application program under the condition that the application program is updated; and configuring a memory page identifier corresponding to the application identifier for the memory page of the updated application program.
8. An electronic device comprising a memory and a processor, the memory having stored therein a computer program which, when executed by the processor, causes the processor to perform the steps of the method of any of claims 1 to 4.
9. A computer readable storage medium, on which a computer program is stored, characterized in that the computer program, when being executed by a processor, implements the steps of the method according to any one of claims 1 to 4.
10. A computer program product comprising a computer program, characterized in that the computer program, when executed by a processor, implements the steps of the method of any of claims 1 to 4.
CN202110293624.7A 2021-03-19 2021-03-19 Memory processing method, memory processing device, electronic equipment and computer readable storage medium Active CN113010228B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110293624.7A CN113010228B (en) 2021-03-19 2021-03-19 Memory processing method, memory processing device, electronic equipment and computer readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110293624.7A CN113010228B (en) 2021-03-19 2021-03-19 Memory processing method, memory processing device, electronic equipment and computer readable storage medium

Publications (2)

Publication Number Publication Date
CN113010228A CN113010228A (en) 2021-06-22
CN113010228B true CN113010228B (en) 2024-08-27

Family

ID=76402783

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110293624.7A Active CN113010228B (en) 2021-03-19 2021-03-19 Memory processing method, memory processing device, electronic equipment and computer readable storage medium

Country Status (1)

Country Link
CN (1) CN113010228B (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109684090A (en) * 2018-12-19 2019-04-26 三星电子(中国)研发中心 A kind of resource allocation methods and device
CN111352863A (en) * 2020-03-10 2020-06-30 腾讯科技(深圳)有限公司 Memory management method, device, equipment and storage medium
CN111984413A (en) * 2020-08-20 2020-11-24 Oppo(重庆)智能科技有限公司 Memory recovery method and device, electronic equipment and storage medium
CN112256997A (en) * 2020-11-11 2021-01-22 Oppo广东移动通信有限公司 Page management method, page management device, storage medium and electronic device

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR102148948B1 (en) * 2013-12-06 2020-08-27 삼성전자주식회사 Multi tasking method of electronic apparatus and electronic apparatus thereof

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109684090A (en) * 2018-12-19 2019-04-26 三星电子(中国)研发中心 A kind of resource allocation methods and device
CN111352863A (en) * 2020-03-10 2020-06-30 腾讯科技(深圳)有限公司 Memory management method, device, equipment and storage medium
CN111984413A (en) * 2020-08-20 2020-11-24 Oppo(重庆)智能科技有限公司 Memory recovery method and device, electronic equipment and storage medium
CN112256997A (en) * 2020-11-11 2021-01-22 Oppo广东移动通信有限公司 Page management method, page management device, storage medium and electronic device

Also Published As

Publication number Publication date
CN113010228A (en) 2021-06-22

Similar Documents

Publication Publication Date Title
CN111221476B (en) Front-end command processing method and device for improving SSD performance, computer equipment and storage medium
CA3128540C (en) Cache system hotspot data access method, apparatus, computer device and storage medium
US20250190362A1 (en) Hypercall method and apparatus for kernel-mode program of extended berkeley packet filter
CN110941395A (en) Dynamic random access memory, memory management method, system and storage medium
CN106293849B (en) An application update method and terminal
CN105138382A (en) Method and terminal for upgrading Android system
CN111324303B (en) SSD garbage recycling method, SSD garbage recycling device, computer equipment and storage medium
US11288185B2 (en) Method and computer program product for performing data writes into a flash memory
US11593003B2 (en) Method and systems for recommending storage management actions based on capacities of storage systems
CN110019063B (en) Method for computing node data disaster recovery playback, terminal device and storage medium
CN111400091B (en) Factory setting restoration method, factory setting restoration device and mobile terminal
CN109495432B (en) An authentication method and server for an anonymous account
CN109521970B (en) Data processing method and related equipment
CN111488323A (en) Data processing method and device and electronic equipment
CN113010228B (en) Memory processing method, memory processing device, electronic equipment and computer readable storage medium
CN111258676B (en) Module preloading method, device, equipment and readable storage medium
CN110515718B (en) Method, device, equipment and medium for batch task breakpoint continuation
CN106933604A (en) A kind of method for upgrading system and device
CN111078714B (en) Data processing method and device
CN114518844A (en) Data processing method
CN109683813B (en) NVME SSD automatic formatting method, device, terminal and storage medium
CN111562983A (en) Memory optimization method and device, electronic equipment and storage medium
CN109144399B (en) Data storage method and device and electronic equipment
CN114357481A (en) Access method, apparatus, computer device and storage medium for storage circuit
CN109542531B (en) File layout adjustment method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant