WO2020211791A1 - 匿名页面管理方法、装置、终端设备及可读存储介质 - Google Patents

匿名页面管理方法、装置、终端设备及可读存储介质 Download PDF

Info

Publication number
WO2020211791A1
WO2020211791A1 PCT/CN2020/084989 CN2020084989W WO2020211791A1 WO 2020211791 A1 WO2020211791 A1 WO 2020211791A1 CN 2020084989 W CN2020084989 W CN 2020084989W WO 2020211791 A1 WO2020211791 A1 WO 2020211791A1
Authority
WO
WIPO (PCT)
Prior art keywords
target
priority
anonymous
page
executed
Prior art date
Application number
PCT/CN2020/084989
Other languages
English (en)
French (fr)
Inventor
林庚佑
Original Assignee
深圳市万普拉斯科技有限公司
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 深圳市万普拉斯科技有限公司 filed Critical 深圳市万普拉斯科技有限公司
Priority to EP20792131.3A priority Critical patent/EP3958120A4/en
Publication of WO2020211791A1 publication Critical patent/WO2020211791A1/zh
Priority to US17/501,994 priority patent/US20220035655A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR 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/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4812Task transfer initiation or dispatching by interrupt, e.g. masked
    • G06F9/4818Priority circuits therefor
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/08Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/0223User address space allocation, e.g. contiguous or non contiguous base addressing
    • G06F12/023Free address space management
    • G06F12/0253Garbage collection, i.e. reclamation of unreferenced memory
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/08Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
    • G06F12/0802Addressing of a memory level in which the access to the desired data or data block requires associative addressing means, e.g. caches
    • G06F12/0862Addressing of a memory level in which the access to the desired data or data block requires associative addressing means, e.g. caches with prefetch
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/08Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
    • G06F12/10Address translation
    • G06F12/1009Address translation using page tables, e.g. page table structures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/08Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
    • G06F12/12Replacement control
    • G06F12/121Replacement control using replacement algorithms
    • G06F12/126Replacement control using replacement algorithms with special data handling, e.g. priority of data or instructions, handling errors or pinning
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR 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/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
    • G06F9/4881Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR 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/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • G06F9/5016Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals the resource being the memory
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR 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/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • G06F9/5022Mechanisms to release resources
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/48Indexing scheme relating to G06F9/48
    • G06F2209/484Precedence
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2212/00Indexing scheme relating to accessing, addressing or allocation within memory systems or architectures
    • G06F2212/10Providing a specific technical effect
    • G06F2212/1016Performance improvement
    • G06F2212/1024Latency reduction
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2212/00Indexing scheme relating to accessing, addressing or allocation within memory systems or architectures
    • G06F2212/10Providing a specific technical effect
    • G06F2212/1041Resource optimization
    • G06F2212/1044Space efficiency improvement

Definitions

  • the present disclosure relates to the technical field of process execution management but is not limited to the technical field of process execution management. Specifically, it relates to an anonymous page management method, device, terminal device, and readable storage medium.
  • Terminal devices for example, smart phones
  • Terminal devices run multiple applications to provide users with corresponding services, but also face limited memory space.
  • the terminal device usually reclaims the anonymous pages corresponding to the application process that are not frequently used according to the LRU (Least Recently Used) mechanism and the Kswapd process from the memory space to the swap space (Swap Space). Release the memory space corresponding to the anonymous page to the terminal device.
  • LRU Location Recently Used
  • a terminal device When a terminal device is executing a process that has an anonymous page that has been recycled into the swap space, it usually needs to block the process and immediately extract the anonymous page corresponding to the process from the swap space, and then use the method of constructing a page fault.
  • the anonymous page is rewritten into the memory space to formally execute the process based on the anonymous page written into the memory space.
  • the time consumed by the page extraction process is much greater than the time consumed by the page fault construction process.
  • the present disclosure provides an anonymous page management method, device, terminal equipment and readable storage medium.
  • the embodiment of the present disclosure provides an anonymous page management method, which is applied to a terminal device.
  • the method includes:
  • the target anonymous page is pre-read from the swap space, so as to directly use the target anonymous page when the target to-be-executed process is executed. page.
  • the embodiment of the present disclosure also provides an anonymous page management method, which is applied to a terminal device.
  • the method includes:
  • the anonymous page management method can reclaim anonymous pages according to the priority change of each process, instead of directly reclaiming anonymous pages that are not frequently used as in the prior art, so as to avoid directly reclaiming current anonymous pages as in the prior art.
  • the phenomenon of infrequently used anonymous pages corresponding to the processes that need to be executed immediately or being executed is recycled, so as to flexibly recycle the anonymous pages and reduce the memory pressure of the terminal device.
  • the embodiment of the present disclosure provides an anonymous page management apparatus, which is applied to terminal equipment.
  • the device includes:
  • a process monitoring module configured to monitor whether there is a process whose priority changes in the terminal device
  • the process determination module is configured to determine the target process to be executed according to the monitored priority changes of each process
  • the page detection module is configured to detect whether the target anonymous page corresponding to the target to-be-executed process is stored in the swap space, where the swap space is used to reclaim anonymous pages;
  • the page pre-reading module is configured to, if it is detected that the target anonymous page is stored in the swap space, pre-read the target anonymous page from the swap space to be executed in the target to-be-executed process When, use the target anonymous page directly.
  • the embodiment of the present disclosure provides another anonymous page management device, which is applied to terminal equipment.
  • the device includes:
  • a process monitoring module configured to monitor whether there is a process whose priority changes in the terminal device
  • the process determination module is configured to determine the target process to be recycled according to the monitored priority changes of each process
  • the page detection module is configured to detect whether the target anonymous page corresponding to the target to-be-reclaimed process is stored in the memory space;
  • the page recycling module is configured to, if it is detected that the target anonymous page is stored in the memory space, recover at least one of the target anonymous pages from the memory space to the swap space, wherein the swap space is used for Recycle anonymous pages.
  • the embodiment of the present disclosure provides a terminal device, the terminal device includes a processor and a non-volatile memory storing computer instructions, and when the computer instructions are executed by the processor, the terminal device executes the aforementioned anonymous page Management methods.
  • the embodiment of the present disclosure provides a readable storage medium, the readable storage medium includes a computer program, and when the computer program runs, the terminal device where the readable storage medium is located is controlled to execute the aforementioned anonymous page management method.
  • the anonymous page management method can reduce the number of to-be-executed processes when the anonymous page is stored in the swap space. The probability of random stalls in the process ensures the execution efficiency of the process to be executed.
  • the method monitors whether there is a process whose priority changes in the terminal device, and determines the target process to be executed according to the monitored priority change of each process; then, the method detects the target process to be executed Whether the corresponding target anonymous page is stored in the swap space; finally, when the method detects that the target anonymous page is stored in the swap space, pre-read the target anonymous page from the swap space to When the target to-be-executed process is executed, the pre-read target anonymous page is directly used, thereby reducing the probability of random stalls in the to-be-executed process and ensuring the execution efficiency of the to-be-executed process.
  • FIG. 1 is a schematic block diagram of a terminal device provided by an embodiment of the disclosure
  • FIG. 2 is a schematic diagram of the first flow of an anonymous page management method provided by an embodiment of the present disclosure
  • FIG. 3 is a schematic flowchart of sub-steps included in step S220 shown in FIG. 2;
  • FIG. 4 is a schematic diagram of a second flow of an anonymous page management method provided by an embodiment of the present disclosure
  • FIG. 5 is a schematic flowchart of sub-steps included in step S250 shown in FIG. 4;
  • FIG. 6 is a schematic diagram of a third process of an anonymous page management method provided by an embodiment of the present disclosure.
  • FIG. 7 is a first block diagram of an anonymous page management apparatus provided by an embodiment of the present disclosure.
  • FIG. 8 is a second block diagram of an anonymous page management apparatus provided by an embodiment of the present disclosure.
  • FIG. 9 is a third block diagram of an anonymous page management apparatus provided by an embodiment of the disclosure.
  • Icon 10-terminal device; 11-memory; 12-processor; 13-communication unit; 100-anonymous page management device; 110-process monitoring module; 120-process determination module; 130-page detection module; 140-page pre Reading module; 150-page recycling module.
  • FIG. 1 is a block diagram of a terminal device 10 according to an embodiment of the present disclosure.
  • the terminal device 10 can be used to execute processes corresponding to different applications to realize the functions corresponding to each application.
  • the number of processes corresponding to each application is at least one.
  • the application program can be, but is not limited to, a video program, an audio program, a browser program, etc.
  • the terminal device 10 may be, but is not limited to, a smart phone, a personal computer (PC), a tablet computer, a personal digital assistant (PDA), a mobile Internet device (MID) Wait.
  • the terminal device 10 is a smart phone.
  • the terminal device 10 includes an anonymous page management apparatus 100, a memory 11, a processor 12, and a communication unit 13.
  • the components of the anonymous page management device 100, the memory 11, the processor 12, and the communication unit 13 are directly or indirectly electrically connected to each other to realize data transmission or interaction.
  • the memory 11, the processor 12, and the communication unit 13 may be electrically connected to each other through one or more communication buses or signal lines.
  • the memory 11 is a non-volatile memory, and the memory 11 can be used to store processes included in multiple applications. Each process under the same application corresponds to multiple anonymous pages. The page can be occupied by multiple processes switching.
  • the memory 11 can be divided into multiple storage spaces, and the storage 11 uses one storage space among the multiple storage spaces as the memory space of the terminal device 10, and uses one storage space among the multiple storage spaces as the terminal device 10. Exchange space for device 10. When the terminal device 10 needs to execute a process, all anonymous pages corresponding to the process need to be written into the memory space, so that the terminal device 10 executes the process based on all the anonymous pages corresponding to the process The corresponding program code.
  • the terminal device 10 can reclaim part or all of the anonymous pages corresponding to the process into the swap space to release all reclaimed anonymous pages.
  • the storage resources corresponding to the part of the anonymous pages or all the anonymous pages in the memory space are ensured to ensure that the memory space can provide sufficient storage resources for other processes.
  • the terminal device 10 can adopt the LRU mechanism and the Kswapd process as in the prior art to reclaim the anonymous pages corresponding to the application process that are not frequently used from the memory space to the swap.
  • the memory 11 is also used to store the priority of each process at the terminal device 10, and the priority is used to indicate the priority of the corresponding process to be executed at the terminal device 10.
  • the priority of the same process can change with user operations at different times.
  • the terminal device 10 will correspondingly execute the process.
  • a process with a higher priority is more likely to be executed by the terminal device 10.
  • the operating system of the terminal device 10 is the Android system, and the terminal device 10 may adopt the Android system to define the priority (adj) (priority corresponding to adj0). The largest, the priority corresponding to adj1000 is the smallest) to represent the current priority of each process.
  • the memory 11 is also used to store a first preset priority and a second preset priority.
  • the second preset priority is not higher than the first preset priority.
  • the first preset priority and the second preset priority are used to classify the current priority of each process numerically.
  • the first preset priority and the second preset priority are represented by the first preset priority in the corresponding adj values shown in the terminal device 10 whose operating system is the Android system
  • the output adj value is not greater than the adj value indicated by the second preset priority to ensure that the second preset priority is not higher than the first preset priority.
  • the memory 11 is also used to store computer instructions or computer programs, and the processor 12 can execute the computer instructions or the computer programs accordingly after receiving the execution instructions.
  • the processor 12 may be an integrated circuit chip with signal processing capability.
  • the processor 12 may be a general-purpose processor, including a central processing unit (Central Processing Unit, CPU), a graphics processing unit (Graphics Processing Unit, GPU), a network processor (Network Processor, NP), and so on.
  • the general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc., and may implement or execute the methods, steps, and logical block diagrams disclosed in the embodiments of the present disclosure.
  • the communication unit 13 is used to establish a communication connection between the terminal device 10 and other external devices through a network, and to send and receive data through the network.
  • the terminal device 10 downloads a corresponding application program from an application server through the communication unit 13.
  • the anonymous page management apparatus 100 includes at least one software function module that can be stored in the memory 11 in the form of software or firmware or solidified in the operating system of the terminal device 10.
  • the processor 12 may be used to execute executable modules stored in the memory 11, such as software function modules and computer programs included in the anonymous page management apparatus 100.
  • FIG. 1 is only a schematic structural composition diagram of the terminal device 10, and the terminal device 10 may also include more or fewer components than those shown in FIG. Different configurations are shown.
  • the components shown in FIG. 1 can be implemented by hardware, software, or a combination thereof.
  • the embodiment of the present application provides a method, including:
  • the current storage space here includes: swap space or cache space. For example, if the target execution process does not involve anonymous pages, the current storage space of the anonymous page is determined to be cache space; and/or, for example, if the target execution process involves anonymous pages, the current storage space of the anonymous page is determined to be swap space.
  • the anonymous pages are dumped to the swap space, thereby freeing the cache space; and if the target execution process involves anonymous pages and the anonymous pages are stored in the swap space, then The anonymous page will be dumped to the cache space to accelerate the execution efficiency of the target execution process.
  • FIG. 2 is a schematic diagram of the first flow of an anonymous page management method provided by an embodiment of the present disclosure.
  • the anonymous page management method shown in FIG. 2 is applied to the above-mentioned terminal device 10, and is used to pre-read the anonymous page of the to-be-executed process stored in the swap space in order to execute the to-be-executed process
  • the pre-read anonymous pages are directly used during the process, thereby reducing the probability of random stalls in the process to be executed, and ensuring the execution efficiency of the process to be executed.
  • the specific process and steps of the anonymous page management method shown in FIG. 2 will be described in detail below.
  • step S210 It is monitored whether there is a process whose priority has changed in the terminal device, for example, as shown in step S210, in step S210, whether there is a process whose priority has changed in the terminal device 10 is monitored in real time.
  • the terminal device 10 will perform priority monitoring on the process corresponding to each application in real time to monitor whether the current priority of each process has changed. Whether there is a process whose priority changes in the terminal device may also include: periodically monitoring whether there is a process whose priority changes in the terminal device.
  • Step S220 Determine the target process to be executed according to the monitored priority change of each process.
  • the terminal device 10 After the terminal device 10 obtains the current priority change of each process, it will determine the target to-be-executed process from all the processes currently stored in the terminal device 10, wherein the to-be-executed process It is a process that may currently need to be executed by the terminal device 10, and at this time, the priority change of the process to be executed is that the priority becomes higher.
  • step S220 determines the target to-be-executed process based on the first preset priority. At this time, the step S220 includes sub-step S221, sub-step S222, and sub-step S223. .
  • Sub-step S221 according to the monitored priority changes of each process, filter out all pending processes whose current priority has become higher.
  • the terminal device 10 after detecting the priority change of each process, the terminal device 10 will filter out all the stored processes to be executed with the current priority higher. Wherein, when the current priority of a certain to-be-executed process becomes higher, it indicates that the probability that the to-be-executed process is currently executed by the terminal device 10 has increased.
  • sub-step S222 for each selected process to be executed, it is detected whether the priority of the process to be executed becomes higher than the first preset priority.
  • the terminal device 10 will detect whether the priority of the process to be executed is not lower than the first preset priority to determine the process to be executed. Whether the execution process currently requires anonymous page pre-reading.
  • the first preset priority is the adj value indicated in the terminal device 10 whose operating system is the Android system is not greater than the adj value indicated by the current priority of a certain process to be executed, it indicates The current priority of the process to be executed is not lower than the first preset priority.
  • sub-step S223 if it is detected that the priority of the to-be-executed process becomes higher than the first preset priority, the to-be-executed process is selected as a target to-be-executed process.
  • the terminal device 10 when the terminal device 10 detects that the priority of a certain to-be-executed process is not lower than the first preset priority, the terminal device 10 will select the to-be-executed Process as a target to be executed process.
  • the target to-be-executed process may be a to-be-executed process whose priority before becoming higher is lower than the first preset priority and the priority after becoming higher is not lower than the first preset priority, It may also be a process to be executed whose priority before and after the increase is not lower than the first preset priority.
  • the step S220 does not need to determine the target to-be-executed process based on the first preset priority.
  • the terminal device 10 can change the priority according to the monitored priority. After screening out all the processes to be executed whose current priority has become higher, directly use the selected processes to be executed as the corresponding target to-be-executed process. At this time, the priority of the target to-be-executed process before and after the change is the same as The first preset priority has no association relationship.
  • Step S230 Detect whether the target anonymous page corresponding to the target to-be-executed process is stored in the swap space, where the swap space is used to reclaim the anonymous page.
  • the swap space is used to reclaim anonymous pages.
  • the terminal device 10 determines a target to-be-executed process, it will detect whether the target anonymous page corresponding to the target to-be-executed process (part of the anonymous page or all anonymous pages of the target to-be-executed process) is stored in the exchange In the space.
  • Step S240 If it is detected that the target anonymous page is stored in the swap space, the target anonymous page is pre-read from the swap space, so that when the target to-be-executed process is executed, the target anonymous page is directly used. Describe the target anonymous page.
  • the terminal device 10 when the terminal device 10 detects that a target anonymous page corresponding to a target to-be-executed process is stored in the swap space, the terminal device 10 will pre-read from the swap space
  • the target anonymous page corresponding to the target to-be-executed process so that when the target-to-be-executed process is executed, the terminal device 10 does not need to immediately respond when the target to-be-executed process is blocked.
  • the anonymous pages recovered in the swap space of the target to-be-executed process are extracted, and the pre-read target anonymous pages can be written into the memory space directly based on the page fault mechanism to directly use all the anonymous pages.
  • the target anonymous page executes the target to-be-executed process, thereby reducing the probability of random stalls when the target to-be-executed process is executed, and ensuring the execution efficiency of the to-be-executed process.
  • the anonymous page management method shown in Figure 2 can adopt the LRU mechanism and Kswapd process as in the prior art to reclaim anonymous pages corresponding to the process of the application program that are not frequently used from the memory space to the swap space, so as to realize page reclaim. deal with.
  • FIG. 4 is a schematic diagram of a second flow of an anonymous page management method provided by an embodiment of the present disclosure.
  • the anonymous page management method shown in FIG. 4 further includes step S250, step S260, and step S270.
  • the anonymous page management method can execute all In the manner of step S250, step S260, and step S270, the anonymous page of a certain process to be recycled is recycled.
  • the step S250, the step S260, and the step S270 enable the terminal device 10 to reclaim anonymous pages according to the priority changes of each process, instead of directly reclaiming infrequently used pages as in the prior art.
  • the method can flexibly recycle the anonymous pages and reduce the memory pressure of the terminal device 10.
  • Step S250 Determine the target process to be recycled according to the monitored priority change of each process.
  • the to-be-reclaimed process is a process that needs to reclaim anonymous pages
  • the current priority change of the to-be-reclaimed process is that the priority becomes lower.
  • the terminal device 10 After the terminal device 10 obtains the current priority change of each process, it will filter out all processes currently stored in the terminal device 10 to be reclaimed processes whose priority has become lower and need to reclaim anonymous pages, and determine accordingly The target is to be recycled.
  • step S250 needs to determine the target to-be-reclaimed process based on the second preset priority and the first preset priority.
  • the step S250 includes sub-step S251 and sub-step S251.
  • Sub-step S251 according to the monitored priority changes of each process, filter out all the processes to be recycled whose current priority has become lower and need to recycle anonymous pages.
  • the terminal device 10 after detecting the priority change of each process, the terminal device 10 will filter out all processes to be recycled whose current priority has become lower. Wherein, when the current priority of a certain process to be reclaimed becomes low, it indicates that the probability that the process to be reclaimed is currently executed by the terminal device 10 is reduced, and the terminal device 10 can preferably the anonymous page of the process to be reclaimed Perform recycling processing to reduce the memory pressure of the terminal device 10.
  • sub-step S252 for each selected process to be recycled, the priority of the process to be recycled is compared with a second preset priority.
  • the terminal device 10 compares the priority of the process to be reclaimed currently lowered with the second preset priority to determine according to the comparison result Whether the process to be recycled needs to be recycled for anonymous pages. Wherein, when the adj value indicated by the second preset priority in the terminal device 10 whose operating system is the Android system is greater than the adj value indicated by the current priority of a certain process to be recycled, it indicates that the The current priority of the process to be recycled is lower than the second preset priority.
  • sub-step S253 if the priority of the process to be recycled is lower than the second preset priority, the process to be recycled is selected as a target process to be recycled.
  • the terminal device 10 when the terminal device 10 detects that the priority of a certain process to be recycled is lower than the second preset priority, the terminal device 10 will select the process to be recycled As a target to be recycled process.
  • the target to-be-reclaimed process may be a to-be-reclaimed process whose priority before and after the decrease is lower than the second preset priority, or it may be that the priority before the decrease is not lower than the second preset priority.
  • Set the priority and the lower priority is lower than the to-be-reclaimed process of the second preset priority.
  • the condition that the priority before the lowering is not lower than the second preset priority includes that the priority before the lowering is not lower than the first preset priority, and the priority before the lowering is at the same level.
  • sub-step S254 if the priority of the process to be reclaimed is lower than the second preset priority, then the priority before and after the process to be reclaimed is lowered is compared with the first preset priority, and the When the priority of the process to be recycled is not lower than the first preset priority and the priority after the decrease is lower than the first preset priority, the process to be recycled is selected as a target to be recycled process.
  • the terminal device 10 when the terminal device 10 detects that the priority of a certain process to be recycled is not lower than the second preset priority, the terminal device 10 will The priority before and after the process is lowered is compared with the first preset priority to determine whether the to-be-reclaimed process currently needs to be reclaimed anonymous pages according to the comparison result.
  • the terminal device 10 when the priority of the process to be reclaimed is not lower than the first preset priority, and the priority of the process to be reclaimed is lower than the first preset priority When the time, it indicates that the current priority of the process to be reclaimed has never been lower than the first preset priority to be lower than the first preset priority, and the priority of the process to be reclaimed is lower after being lower If the first preset priority is not lower than the second preset priority, the terminal device 10 will also use the process to be recycled as a target process to be recycled.
  • the step S250 does not need to determine the target to-be-reclaimed process based on the first preset priority and the second preset priority.
  • the terminal device 10 After filtering out all the processes to be reclaimed whose current priority has become lower according to the monitored priority changes, the selected processes to be reclaimed can be directly used as the corresponding target to be reclaimed processes.
  • the target The priority before and after the change of the process to be recycled has no relationship with the first preset priority and the second preset priority.
  • Step S260 detecting whether the target anonymous page corresponding to the target to-be-reclaimed process is stored in the memory space.
  • the terminal device 10 After the terminal device 10 determines a target process to be recycled, it will detect the target anonymous page corresponding to the target process to be recycled (part of the anonymous page or all anonymous pages of the target process to be recycled) Whether it is saved in the memory space.
  • Step S270 If it is detected that the target anonymous page is stored in the memory space, at least one of the target anonymous page is recovered from the memory space to the swap space.
  • the terminal device 10 when the terminal device 10 detects that a target anonymous page corresponding to a target to-be-reclaimed process is stored in the memory space, the terminal device 10 will compare the target anonymous page with the target from the memory space. At least one target anonymous page corresponding to the process to be reclaimed is reclaimed into the swap space to release the storage resources occupied by the target anonymous page in the memory space, thereby reducing the memory pressure of the terminal device 10.
  • the step of reclaiming at least one target anonymous page from the memory space into the swap space includes:
  • the target to-be-executed process is a to-be-executed process whose current priority is not lower than the first preset priority and has a higher priority.
  • the terminal device 10 reclaims all the target anonymous pages into the swap space ;
  • the terminal device 10 will take all target anonymous pages that are not occupied by other target to-be-executed processes Recycle to the swap space.
  • the step of reclaiming at least one of the target anonymous pages from the memory space into the swap space includes:
  • the terminal device 10 does not need to care about the anonymous page occupation relationship between the target to-be-reclaimed process and other processes (including other to-be-reclaimed processes and other to-be-reclaimed processes), and detects the target corresponding to the target to-be-reclaimed process
  • the terminal device 10 will directly reclaim all target anonymous pages currently stored in the memory space by the target to-be-reclaimed process into the swap space to release the memory.
  • the storage resource occupied by the target anonymous page in the space thereby reducing the memory pressure of the terminal device 10.
  • FIG. 6 is a schematic diagram of the third process of the anonymous page management method provided by the embodiment of the present disclosure.
  • the anonymous page management method shown in FIG. 6 does not include the relevant steps of the anonymous page management method shown in FIG. Steps S310, S320, S330, and S340 of flexible recycling processing are performed on each anonymous page in the terminal device 10.
  • the anonymous page management method shown in FIG. 6 enables the terminal device 10 to reclaim anonymous pages according to the priority changes of each process, instead of directly reclaiming anonymous pages that are not frequently used as in the prior art, so as to avoid occurrences.
  • step S310 the phenomenon that anonymous pages that are not frequently used corresponding to processes that need to be executed immediately or are being executed are directly recycled, so that each anonymous page can be recycled flexibly, and the terminal device 10 is reduced. Memory pressure.
  • step S310, step S320, step S330, and step S340 refer to the detailed description of step S210, step S250, step S260, and step S270 above in turn.
  • Step S310 monitoring whether there is a process with a priority change in the terminal device 10, for example, but not limited to: monitoring whether there is a process with a priority change in the terminal device 10 in real time.
  • Step S320 Determine the target process to be recycled according to the monitored priority change of each process.
  • Step S330 detecting whether the target anonymous page corresponding to the target to-be-reclaimed process is stored in the memory space.
  • Step S340 If it is detected that the target anonymous page is stored in the memory space, at least one of the target anonymous page is recovered from the memory space to the swap space, where the swap space is used to recover anonymous pages .
  • the step S320 may determine the target to-be-reclaimed process based on the second preset priority and the first preset priority, or it may not be based on the first preset priority and the first preset priority.
  • the preset priority is used to determine the target to-be-reclaimed process.
  • the second preset priority is not higher than the first preset priority.
  • the step S320 when the step S320 needs to determine the target to-be-reclaimed process based on the second preset priority and the first preset priority, then the step S320 includes:
  • the process to be recycled is selected as a target process to be recycled
  • the priority before and after the process to be reclaimed is lowered is compared with the first preset priority, and the process to be reclaimed is changed
  • the process to be recycled is selected as a target process to be recycled.
  • the terminal device 10 may directly use the selected process to be recycled as the corresponding target process to be recycled after filtering out all the processes to be recycled whose current priority is lowered according to the monitored priority changes. At this time, the priority before and after the change of the target to-be-reclaimed process has no relationship with the first preset priority and the second preset priority.
  • the step S340 can correspond to two implementation manners.
  • One of the implementation manners needs to consider other pending priorities whose current priority has become higher and the higher priority is not lower than the first preset priority.
  • the impact of the execution process that is, the target process to be executed
  • another implementation method does not need to consider the impact of the target process to be executed.
  • the step of reclaiming at least one of the target anonymous pages from the memory space into the swap space includes:
  • the step of reclaiming at least one of the target anonymous pages from the memory space into the swap space includes:
  • step S340 For the execution process of the two implementation manners corresponding to step S340, please refer to the detailed description of the two implementation manners included in step S270 above in turn, which will not be repeated here.
  • FIG. 7 is a first block diagram of an anonymous page management apparatus 100 provided by an embodiment of the present disclosure.
  • the anonymous page management apparatus 100 shown in FIG. 7 can execute the anonymous page management method shown in FIG. 2.
  • the anonymous page management apparatus 100 includes a process monitoring module 110, a process determining module 120, and a page detection module. 130 and the page pre-reading module 140.
  • the process monitoring module 110 is configured to monitor in real time whether there is a process whose priority changes in the terminal device 10.
  • the process monitoring module 110 can perform step S210 in FIG. 2, and for specific description, refer to the detailed description of step S210 above.
  • the process determining module 120 is configured to determine the target process to be executed according to the monitored priority changes of each process.
  • the process determining module 120 may be configured to
  • the to-be-executed process is selected as a target to-be-executed process.
  • the process determining module 120 can execute step S220 in FIG. 2 and sub-step S221, sub-step S222, and sub-step S223 in FIG. 3.
  • step S220, sub-step S221, and sub-steps please refer to the above description of step S220, sub-step S221, and sub-steps. Detailed description of S222 and sub-step S223.
  • the page detection module 130 is configured to detect whether the target anonymous page corresponding to the target to-be-executed process is stored in the swap space, where the swap space is used to reclaim anonymous pages.
  • the page detection module 130 can execute step S230 in FIG. 2, and for specific description, refer to the detailed description of step S230 above.
  • the page pre-reading module 140 is configured to, if it is detected that the target anonymous page is stored in the swap space, pre-read the target anonymous page from the swap space, so as to be executed in the target When the process is executed, the target anonymous page is directly used.
  • the page pre-reading module 140 can execute step S240 in FIG. 2, and for specific description, refer to the detailed description of step S240 above.
  • FIG. 8 is a second block diagram of the anonymous page management apparatus 100 provided by an embodiment of the present disclosure.
  • the anonymous page management apparatus 100 shown in FIG. 8 can execute the anonymous page management methods shown in FIGS. 2 and 4.
  • the anonymous page management apparatus 100 shown in FIG. 7 can execute the anonymous page management methods shown in FIGS. 2 and 4.
  • the anonymous page management apparatus 100 shown in FIG. The anonymous page management device 100 also includes a page recycling module 150.
  • the process determining module 120 is further configured to determine the target process to be recycled according to the monitored priority change of each process.
  • the process determination module 120 is further configured to filter out all pending processes whose current priority has become lower and need to reclaim anonymous pages, according to the monitored priority changes of each process;
  • the process to be recycled is selected as a target process to be recycled
  • the priority before and after the process to be reclaimed is lowered is compared with the first preset priority, and the process to be reclaimed is changed
  • the process to be recycled is selected as a target process to be recycled.
  • the process determination module 120 can also perform step S250 in FIG. 4 and sub-step S251, sub-step S252, sub-step S253, and sub-step S254 in FIG. 5.
  • step S250 sub-step S251, sub-step S252, sub-step S253, and sub-step S254
  • the page detection module 130 is further configured to detect whether the target anonymous page corresponding to the target to-be-reclaimed process is stored in the memory space.
  • the page detection module 130 may also perform step S260 in FIG. 4, and for specific description, refer to the detailed description of step S260 above.
  • the page recycling module 150 is configured to, if it is detected that the target anonymous page is stored in the memory space, recover at least one of the target anonymous pages from the memory space into the swap space.
  • the page recycling module 150 is configured to detect whether each target anonymous page currently stored in the memory space of the target to-be-reclaimed process is occupied by the target to-be-executed process;
  • the page recycling module 150 is configured to
  • the page recycling module 150 can execute step S270 in FIG. 4, and the specific description can refer to the detailed description of step S270 above.
  • FIG. 9 is a third block diagram of the anonymous page management apparatus 100 provided by an embodiment of the present disclosure.
  • the anonymous page management apparatus 100 shown in FIG. 9 can execute the anonymous page management method shown in FIG. 6.
  • the anonymous page management apparatus 100 includes a process monitoring module 110, a process determining module 120, and a page detection module. 130 and page recovery module 150.
  • the process monitoring module 110 is configured to monitor in real time whether there is a process whose priority changes in the terminal device 10.
  • the process monitoring module 110 may execute step S310 in FIG. 6, and for specific description, refer to the detailed description of step S310 above.
  • the process determining module 120 is configured to determine the target process to be recycled according to the monitored priority change of each process.
  • the process determining module 120 may execute step S320 in FIG. 6, and for specific description, refer to the detailed description of step S320 above. In an implementation manner of this embodiment, the process determining module 120 determines the target process to be recycled according to the monitored priority changes of each process, including:
  • the process to be recycled is selected as a target process to be recycled
  • the priority before and after the process to be reclaimed is lowered is compared with the first preset priority, and the process to be reclaimed is changed
  • the process to be recycled is selected as a target process to be recycled.
  • the page detection module 130 is configured to detect whether the target anonymous page corresponding to the target to-be-reclaimed process is stored in the memory space.
  • the page detection module 130 can execute step S330 in FIG. 6, and for specific description, refer to the detailed description of step S330 above.
  • the page recycling module 150 is configured to, if detecting that the target anonymous page is stored in the memory space, recover at least one of the target anonymous pages from the memory space to the swap space, wherein the swap Space is used to reclaim anonymous pages.
  • the page recycling module 150 can execute step S340 in FIG. 6, and for specific description, refer to the detailed description of step S340 above.
  • the way that the page recycling module 150 reclaims at least one of the target anonymous pages from the memory space to the swap space includes:
  • the manner in which the page recycling module 150 reclaims at least one of the target anonymous pages from the memory space into the swap space includes:
  • the embodiment of the present disclosure also provides a readable storage medium that stores a computer program, and when the computer program runs, controls the terminal device 10 where the readable storage medium is located to execute the aforementioned anonymous page management method.
  • the readable storage medium may be any available medium that can be accessed by the terminal device 10 (for example, a personal computer, a server, etc.) or a data storage device such as a server or a data center integrated with one or more available media.
  • the usable medium may be a magnetic medium, (for example, a floppy disk, a hard disk, a magnetic tape), an optical medium (for example, a DVD), or a semiconductor medium (for example, a solid state hard disk (SSD)) and other media that can store program codes .
  • SSD solid state hard disk
  • the anonymous page management method can be executed when the anonymous page is stored in the swap space to be executed. At this time, the probability of random stalls in the process to be executed is reduced, and the execution efficiency of the process to be executed is ensured.
  • the method monitors whether there is a process whose priority changes in the terminal device, and determines the target process to be executed according to the monitored priority change of each process; then, the method detects the target process to be executed Whether the corresponding target anonymous page is stored in the swap space; finally, when the method detects that the target anonymous page is stored in the swap space, pre-read the target anonymous page from the swap space to When the target to-be-executed process is executed, the pre-read target anonymous page is directly used, thereby reducing the probability of random stalls in the to-be-executed process and ensuring the execution efficiency of the to-be-executed process.
  • Any anonymous page management device may include: a processor and a memory; the memory stores executable codes, the processor is connected to the memory, and is configured to execute the executable codes on the memory to implement any embodiment of the present disclosure Provide an anonymous page management method.
  • the executable code includes but is not limited to: source code and/or object code.

Landscapes

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

Abstract

一种匿名页面管理方法、装置、终端设备及可读存储介质。所述方法包括:实时监测终端设备中是否存在优先级发生变化的进程(S210);根据监测到的每个进程的优先级变化情况确定目标待执行进程(S220);检测所述目标待执行进程对应的目标匿名页面是否保存在交换空间中,其中所述交换空间用于回收匿名页面(S230);若检测到所述目标匿名页面保存在所述交换空间中,则从所述交换空间中预读取所述目标匿名页面,以在所述目标待执行进程被执行时,直接使用所述目标匿名页面(S240)。

Description

匿名页面管理方法、装置、终端设备及可读存储介质
本公开是基于申请为:201910300812.0,申请日为2019年04月15日提出的中国申请提出的,并要求该中国申请的优先权。该中国申请的全部内容在此引入本公开作为参考。
技术领域
本公开涉及进程执行管理技术领域但不限于进程执行管理技术领域,具体而言,涉及一种匿名页面管理方法、装置、终端设备及可读存储介质。
背景技术
随着科学技术的不断发展,各式各样的应用程序被开发了出来,终端设备(例如,智能手机)在运行有多个应用程序以向用户提供相应服务的同时,也面临着内存空间有限的现状。为此终端设备通常会根据LRU(Least Recently Used,最近最少使用)机制及Kswapd进程将不常使用的与应用程序的进程对应的匿名页面,从内存空间回收到交换空间(Swap Space)中,以将该匿名页面所对应的内存空间释放给终端设备。
而当终端设备在执行某个存在被回收到交换空间内的匿名页面的进程时,通常需阻塞该进程并当即从交换空间中提取出该进程对应匿名页面,而后通过构建页面错误的方式将该匿名页面重新写入到内存空间中,才能根据被写入到内存空间中的匿名页面正式执行该进程。在这个过程中,页面提取过程所消耗的时长要远远大于页面错误构建过程所消耗的时长,接连发生的这两个过程容易给该进程造成随机卡顿,影响该进程的执行效能。
发明内容
本公开提供一种匿名页面管理方法、装置、终端设备及可读存储介质。
本公开实施例提供一种匿名页面管理方法,所述方法应用于终端设备。所述方法包括:
监测所述终端设备中是否存在优先级发生变化的进程;
根据监测到的每个进程的优先级变化情况确定目标待执行进程;
检测所述目标待执行进程对应的目标匿名页面是否保存在交换空间中,其中所述交换空间用于回收匿名页面;
若检测到所述目标匿名页面保存在所述交换空间中,则从所述交换空间中预读取所述目标匿名页面,以在所述目标待执行进程被执行时,直接使用所述目标匿名页面。
本公开实施例还提供一种匿名页面管理方法,所述方法应用于终端设备。所述方法包括:
监测所述终端设备中是否存在优先级发生变化的进程;
根据监测到的每个进程的优先级变化情况确定目标待回收进程;
检测所述目标待回收进程对应的目标匿名页面是否保存在内存空间中;
若检测到所述目标匿名页面保存在所述内存空间中,则从所述内存空间中将至少一个所述目标匿名页面回收到交换空间中,其中交换空间用于回收匿名页面。所述匿名页面管理方法可根据每个进程的优先级变化情况来回收匿名页面,而非如现有技术那般直接回收不常使用的匿名页面,以避免出现如现有技术那般直接将当前需要马上执行或正在执行的进程所对应的属于不常使用的匿名页面进行回收处理的现象,从而灵活地对各匿名页面进行回收处理,降低终端设备的内存压力。
本公开实施例提供一种匿名页面管理装置,所述装置应用于终端设备。所述装置包括:
进程监测模块,配置为监测所述终端设备中是否存在优先级发生变化的进程;
进程确定模块,配置为根据监测到的每个进程的优先级变化情况确定目标待执行进程;
页面检测模块,配置为检测所述目标待执行进程对应的目标匿名页面是否保存在交换空间中,其中所述交换空间用于回收匿名页面;
页面预读取模块,配置为若检测到所述目标匿名页面保存在所述交换空间中,则从所述交换空间中预读取所述目标匿名页面,以在所述目标待执行进程被执行时,直接使用所述目标匿名页面。
本公开实施例提供还一种匿名页面管理装置,所述装置应用于终端设备。所述装置包括:
进程监测模块,配置为监测所述终端设备中是否存在优先级发生变化的进程;
进程确定模块,配置为根据监测到的每个进程的优先级变化情况确定目标待回收进程;
页面检测模块,配置为检测所述目标待回收进程对应的目标匿名页面是否保存在内存空间中;
页面回收模块,配置为若检测到所述目标匿名页面保存在所述内存空间中,则从所述内存空间中将至少一个所述目标匿名页面回收到交换空间中,其中所述交换空间用于回收匿名页面。
本公开实施例提供一种终端设备,所述终端设备包括处理器及存储有计算机指令的非易失性存储器,所述计算机指令被所述处理器执行时,所述终端设备执行上述的匿名页面管理方法。
本公开实施例提供一种可读存储介质,所述可读存储介质包括计算机程序,所述计算机程序运行时控制所述可读存储介质所在终端设备执行上述的匿名页面管理方法。
本公开实施例提供的匿名页面管理方法、装置、终端设备及可读存储介质中:所述匿名页面管理方法可在对匿名页面保存在交换空间内的待执行进程进行执行时,降低该待执行进程出现随机卡顿的概率,确保该待执行进程的执行效能。首先,所述方法监测所述终端设备中是否存在优先级发生变化的进程,并根据监测到的每个进程的优先级变化情况确定目标待执行进程;然后,所述方法检测该目标待执行进程对应的目标匿名页面是否保存在交换空间中;最后,所述方法在检测到所述目标匿名页面保存在所述交换空间中时,从所述交换空间中预读取所述目标匿名页面,以在该目标待执行进程被执行时,直接使用被预读取出的所述目标匿名页面,从而降低该待执行进程出现随机卡顿的概率,确保该待执行进程的执行效能。
为使本公开的上述目的、特征和优点能更明显易懂,下文特举本公开较佳实施例,并配合所附附图,作详细说明如下。
附图说明
为了更清楚地说明本公开实施例的技术方案,下面将对实施例中所需要使用的附图作简单地介绍,应当理解,以下附图仅示出了本公开的某些实施例,因此不应被看作是对本公开权利要求保护范围的限定,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他相关的附图。
图1为本公开实施例提供的终端设备的一种方框示意图;
图2为本公开实施例提供的匿名页面管理方法的第一种流程示意图;
图3为图2中所示的步骤S220包括的子步骤的流程示意图;
图4为本公开实施例提供的匿名页面管理方法的第二种流程示意图;
图5为图4中所示的步骤S250包括的子步骤的流程示意图;
图6为本公开实施例提供的匿名页面管理方法的第三种流程示意图;
图7为本公开实施例提供的匿名页面管理装置的第一种方框示意图;
图8为本公开实施例提供的匿名页面管理装置的第二种方框示意图;
图9为本公开实施例提供的匿名页面管理装置的第三种方框示意图。
图标:10-终端设备;11-存储器;12-处理器;13-通信单元;100-匿名页面管理装置;110-进程监测模块;120-进程确定模块;130-页面检测模块;140-页面预读取模块;150-页面回收模块。
具体实施方式
本公开为使本公开实施例的目的、技术方案和优点更加清楚,下面将结合本公开实施例中的附图,对本公开实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本公开一部分实施例,而不是全部的实施例。通常在此处附图中描述和示出的本公开实施例的组件可以以各种不同的配置来布置和设计。
因此,以下对在附图中提供的本公开的实施例的详细描述并非旨在限制要求保护的本公开的范围,而是仅仅表示本公开的选定实施例。基于本公开中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本公开保护的范围。
应注意到:相似的标号和字母在下面的附图中表示类似项,因此,一旦某一项在一个附图中被定义,则在随后的附图中不需要对其进行进一步定义和解释。下面结合附图,对本公开的一些实施方式作详细说明。在不冲突的情况下,下述的实施例及实施例中的特征可以相互组合。
请参照图1,是本公开实施例提供的终端设备10的一种方框示意图。在本公开实施例中,所述终端设备10可用于执行不同应用程序各自对应的进程,以实现每个应用程序各自对应的功能,其中每个应用程序所对应的进程数目为至少一个,所述应用程序可以是,但不限于,视频程序、音频程序及浏览器程序等。其中,所述终端设备10可以是,但不限于,智能手机、个人电脑(personal computer,PC)、平板电脑、个人数字助理(personal digital assistant,PDA)、移动上网设备(mobile Internet device,MID)等。 在本实施例的一种实施方式中,所述终端设备10为智能手机。
在本实施例中,所述终端设备10包括匿名页面管理装置100、存储器11、处理器12及通信单元13。所述匿名页面管理装置100、所述存储器11、所述处理器12及所述通信单元13各个元件相互之间直接或间接地电性连接,以实现数据的传输或交互。例如,所述存储器11、所述处理器12及所述通信单元13这些元件相互之间可通过一条或多条通讯总线或信号线实现电性连接。
在本实施例中,所述存储器11为非易失性存储器,所述存储器11可用于存储多个应用程序各自包括的进程,同一应用程序下的每个进程对应多个匿名页面,同一个匿名页面可由多个进程切换式地占用。其中,所述存储器11可划分为多个存储空间,所述存储器11以多个存储空间中的一个存储空间作为该终端设备10的内存空间,以多个存储空间中的一个存储空间作为该终端设备10的交换空间。当所述终端设备10需要执行某个进程时,该进程所对应的所有匿名页面需均写入到该内存空间中,以使所述终端设备10基于该进程所对应的所有匿名页面执行该进程所对应的程序代码。而当所述终端设备10不需对某个进程进行执行时,所述终端设备10可将该进程所对应的一部分匿名页面或所有匿名页面回收到所述交换空间内,以释放被回收的所述一部分匿名页面或所有匿名页面在所述内存空间中对应的存储资源,从而确保所述内存空间能够给其他进程提供足够的存储资源。在本公开实施例的一种实施方式中,所述终端设备10可如现有技术那般采用LRU机制及Kswapd进程将不常使用的与应用程序的进程对应的匿名页面从内存空间回收到交换空间,其中现有技术中的页面回收方式因只根据各匿名页面的使用频率而进行回收处理,易出现将当前需要马上执行或正在执行的进程所对应的属于不常使用的匿名页面进行回收处理的现象,影响各进程的执行效率。
在本实施例中,所述存储器11还用于存储每个进程在所述终端设备10处的优先级,所述优先级用于表示对应进程在所述终端设备10处被执行的优先程度,同一进程的优先级在不同时刻可随用户操作发生变化。当某个进程的优先级达到一定阈值时,所述终端设备10将对应执行该进程。其中,优先级越高的进程越有可能被所述终端设备10执行。在本实施例的一种实施方式中,所述终端设备10的操作系统为安卓(Android)系统,则所述终端设备10可采用安卓系统对优先级(adj)定义(adj0所对应的优先级最大,adj1000所对应的优先级最小)来对每个进程当前的优先级进行表示。
在本实施例中,所述存储器11还用于存储第一预设优先级及第二预设优先级,所述第二预设优先级不高于所述第一预设优先级,所述第一预设优先级及所述第二预设优 先级用于对每个进程当前的优先级进行数值分类。其中,所述第一预设优先级与所述第二预设优先级在操作系统为安卓系统的所述终端设备10中对应表示出的adj数值中,所述第一预设优先级所表示出的adj数值不大于所述第二预设优先级所表示出的adj数值,以确保所述第二预设优先级不高于所述第一预设优先级。在本实施例中,所述存储器11还用于存储计算机指令或计算机程序,所述处理器12在接收到执行指令后,可相应地执行所述计算机指令或所述计算机程序。
在本实施例中,所述处理器12可以是一种具有信号的处理能力的集成电路芯片。所述处理器12可以是通用处理器,包括中央处理器(Central Processing Unit,CPU)、图形处理器(Graphics Processing Unit,GPU)、网络处理器(Network Processor,NP)等。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等,可以实现或者执行本公开实施例中的公开的各方法、步骤及逻辑框图。
在本实施例中,所述通信单元13用于通过网络建立所述终端设备10与其他外部设备之间的通信连接,并通过所述网络收发数据。例如,所述终端设备10通过所述通信单元13从应用服务器处下载对应的应用程序。
在本实施例中,所述匿名页面管理装置100包括至少一个能够以软件或固件的形式存储于所述存储器11中或固化在所述终端设备10的操作系统中的软件功能模块。所述处理器12可用于执行所述存储器11存储的可执行模块,例如所述匿名页面管理装置100所包括的软件功能模块及计算机程序等。
可以理解的是,图1所示的框图仅为终端设备10的一种结构组成示意图,所述终端设备10还可包括比图1中所示更多或者更少的组件,或者具有与图1所示不同的配置。图1中所示的各组件可以采用硬件、软件或其组合实现。
本申请实施例提供一种方法,包括:
监测终端设备中是否存在优先级发生变化的进程;
根据监测到的每个进程的优先级变化情况确定目标待执行进程;
根据所述目标执行进程是否涉及匿名页面,确定匿名页面的当前存储空间;
将所述匿名页面存储到所述当前存储空间。
此处的当前存储空间包括:交换空间或缓存空间。例如,若目标执行进程不涉及匿名页面时,确定匿名页面的当前存储空间为缓存空间;和/或,例如,若目标执行进程涉及匿名页面时,确定匿名页面的当前存储空间为交换空间。
如此,若目标执行进程不涉及匿名页面且匿名页面存储在缓存空间,则将匿名页面 转存到交换空间,从而释放缓存空间;而若目标执行进程涉及匿名页面且匿名页面存储在交换空间,则将将匿名页面转存到缓存空间,加速目标执行进程的执行效率。
请参照图2,是本公开实施例提供的匿名页面管理方法的第一种流程示意图。在本公开实施例中,图2所示的匿名页面管理方法应用于上述终端设备10,用于对匿名页面保存在交换空间内的待执行进程进行匿名页面预读取,以在执行该待执行进程时直接使用被预读取出的匿名页面,从而降低该待执行进程出现随机卡顿的概率,确保该待执行进程的执行效能。下面对图2所示的匿名页面管理方法的具体流程和步骤进行详细阐述。
监测终端设备中是否存在优先级发生变化的进程,例如,如步骤S210所示,步骤S210,实时监测终端设备10中是否存在优先级发生变化的进程。
在本实施例中,所述终端设备10会实时地对每个应用程序所对应的进程进行优先级监测,以监测每个进程当前优先级是否发生变化。该终端设备中是否存在优先级发生变化的进程还可包括:周期性监测终端设备中是否存在优先级发生变化的进程。
步骤S220,根据监测到的每个进程的优先级变化情况确定目标待执行进程。
在本实施例中,所述终端设备10在获取到每个进程当前的优先级变化情况后,将从该终端设备10当前存储的所有进程中确定出目标待执行进程,其中所述待执行进程为当前可能需要被所述终端设备10执行的进程,此时所述待执行进程的优先级变化情况为优先级变高。
在一个实施例中,请参照图3,是图2中所示的步骤S220包括的子步骤的流程示意图。在本公开的一种实施例中,所述步骤S220基于所述第一预设优先级来确定所述目标待执行进程,此时所述步骤S220包括子步骤S221、子步骤S222及子步骤S223。
子步骤S221,根据监测到的每个进程的优先级变化情况,筛选出所有的当前优先级变高的待执行进程。
在本实施例中,所述终端设备10在检测到每个进程的优先级变化情况后,将从存储的所有进程中筛选出当前优先级变高的待执行进程。其中,当某个待执行进程当前优先级变高时,表明该待执行进程当前被所述终端设备10执行的概率有所提高。
子步骤S222,针对每个筛选出的待执行进程,检测该待执行进程变高后的优先级是否不低于第一预设优先级。
在本实施例中,针对每个筛选出的待执行进程,所述终端设备10均会检测该待执行进程当前变高后的优先级是否不低于第一预设优先级,以判断该待执行进程当前是否需要进行匿名页面预读取。其中,当所述第一预设优先级在操作系统为安卓系统的所述 终端设备10中所表示出的adj数值,不大于某个待执行进程当前的优先级所表示的adj数值时,表明该待执行进程当前的优先级不低于所述第一预设优先级。
子步骤S223,若检测到该待执行进程变高后的优先级不低于所述第一预设优先级,则选定该待执行进程作为一个目标待执行进程。
在本实施例中,当所述终端设备10检测到某个待执行进程当前变高后的优先级不低于所述第一预设优先级时,所述终端设备10将选定该待执行进程作为一个目标待执行进程。其中,所述目标待执行进程,可以是变高前的优先级低于所述第一预设优先级而变高后的优先级不低于所述第一预设优先级的待执行进程,也可以是变高前后的优先级均不低于所述第一预设优先级的待执行进程。
在本公开的另一种实施例中,所述步骤S220无须基于所述第一预设优先级来确定所述目标待执行进程,此时所述终端设备10可在根据监测到的优先级变化情况筛选出所有的当前优先级变高的待执行进程后,直接将筛选出的所述待执行进程作为对应的所述目标待执行进程,此时所述目标待执行进程变化前后的优先级与所述第一预设优先级无关联关系。
步骤S230,检测所述目标待执行进程对应的目标匿名页面是否保存在交换空间中,其中所述交换空间用于回收匿名页面。
在本实施例中,所述交换空间用于回收匿名页面。所述终端设备10在确定了某个目标待执行进程后,将检测该目标待执行进程所对应的目标匿名页面(该目标待执行进程的部分匿名页面或全部匿名页面)是否保存在所述交换空间内。
步骤S240,若检测到所述目标匿名页面保存在所述交换空间中,则从所述交换空间中预读取所述目标匿名页面,以在所述目标待执行进程被执行时,直接使用所述目标匿名页面。
在本实施例中,当所述终端设备10检测到某个目标待执行进程对应的目标匿名页面保存在所述交换空间中时,所述终端设备10将从所述交换空间中预读取出该目标待执行进程所对应的目标匿名页面,以在该目标待执行进程被执行时,使所述终端设备10在阻塞该目标待执行进程的情况下,无须如现有技术那般需要当即对该目标待执行进程的被回收到所述交换空间内的匿名页面进行提取,可直接基于页面错误机制将被预读取的所述目标匿名页面写入到所述内存空间中,以直接使用所述目标匿名页面来执行所述目标待执行进程,从而降低该目标待执行进程被执行时出现随机卡顿的概率,确保该待执行进程的执行效能。
其中,图2所示的匿名页面管理方法可如现有技术那般采用LRU机制及Kswapd进程将不常使用的与应用程序的进程对应的匿名页面从内存空间回收到交换空间,以实现页面回收处理。
请参照图4,是本公开实施例提供的匿名页面管理方法的第二种流程示意图。在本公开实施例中,与图2所示的匿名页面管理方法相比,图4所示的匿名页面管理方法还包括步骤S250、步骤S260及步骤S270,所述匿名页面管理方法可通过执行所述步骤S250、所述步骤S260及所述步骤S270的方式,来对某个待回收进程的匿名页面进行回收处理。其中,所述步骤S250、所述步骤S260及所述步骤S270可使所述终端设备10根据每个进程的优先级变化情况来回收匿名页面,而非如现有技术那般直接回收不常使用的匿名页面,以避免出现如现有技术那般直接将当前需要马上执行或正在执行的进程所对应的属于不常使用的匿名页面进行回收处理的现象,从而确保图4所示的匿名页面管理方法能够灵活地对各匿名页面进行回收处理,降低所述终端设备10的内存压力。
步骤S250,根据监测到的每个进程的优先级变化情况确定目标待回收进程。
在本实施例中,所述待回收进程为需要回收匿名页面的进程,该待回收进程当前优先级变化情况为优先级变低。所述终端设备10在得到每个进程当前的优先级变化情况后,将从该终端设备10当前存储的所有进程中筛选出优先级变低的需要回收匿名页面的待回收进程,并相应确定出目标待回收进程。
在一个实施例中,请参照图5,是图4中所示的步骤S250包括的子步骤的流程示意图。在本公开的一种实施例中,所述步骤S250需基于第二预设优先级及第一预设优先级来确定所述目标待回收进程,此时所述步骤S250包括子步骤S251、子步骤S252、子步骤S253及子步骤S254,其中所述第二预设优先级不高于所述第一预设优先级。
子步骤S251,根据监测到的每个进程的优先级变化情况,筛选出所有的当前优先级变低的需要回收匿名页面的待回收进程。
在本实施例中,所述终端设备10在检测到每个进程的优先级变化情况后,将从存储的所有进程中筛选出当前优先级变低的待回收进程。其中,当某个待回收进程当前优先级变低时,表明该待回收进程当前被所述终端设备10执行的概率有所降低,所述终端设备10可优选地对该待回收进程的匿名页面进行回收处理,以降低所述终端设备10的内存压力。
子步骤S252,针对每个筛选出的待回收进程,将该待回收进程变低后的优先级与第二预设优先级进行比较。
在本实施例中,针对每个筛选出的待回收进程,所述终端设备10均会将该待回收进程当前变低后的优先级与第二预设优先级进行比较,以根据比较结果判断该待回收进程当前是否需要进行匿名页面回收。其中,当所述第二预设优先级在操作系统为安卓系统的所述终端设备10中所表示出的adj数值,大于某个待回收进程当前的优先级所表示的adj数值时,表明该待回收进程当前的优先级低于所述第二预设优先级。
子步骤S253,若该待回收进程变低后的优先级低于所述第二预设优先级,则选定该待回收进程作为一个目标待回收进程。
在本实施例中,当所述终端设备10检测到某个待回收进程当前变低后的优先级低于所述第二预设优先级时,所述终端设备10将选定该待回收进程作为一个目标待回收进程。其中,所述目标待回收进程,可以是变低前后的优先级均低于所述第二预设优先级的待回收进程,也可以是变低前的优先级不低于所述第二预设优先级且变低后的优先级低于所述第二预设优先级的待回收进程。所述变低前的优先级不低于所述第二预设优先级的情况,包括变低前的优先级不低于所述第一预设优先级,以及变低前的优先级处于所述第二预设优先级与所述第一预设优先级之间的优先级范围。
子步骤S254,若该待回收进程变低后的优先级不低于第二预设优先级,则将该待回收进程变低前后的优先级与第一预设优先级进行比较,并在该待回收进程变低前的优先级不低于所述第一预设优先级且变低后的优先级低于所述第一预设优先级时,选定该待回收进程作为一个目标待回收进程。
在本实施例中,当所述终端设备10检测到某个待回收进程当前变低后的优先级不低于所述第二预设优先级时,所述终端设备10将会将该待回收进程变低前后的优先级与第一预设优先级进行比较,以根据比较结果来判断该待回收进程当前是否需要进行匿名页面回收。在一个实施例中,当该待回收进程变低前的优先级不低于所述第一预设优先级,且该待回收进程变低后的优先级低于所述第一预设优先级时,表明该待回收进程当前优先级是从不低于所述第一预设优先级变低为低于所述第一预设优先级的,且该待回收进程变低后的优先级低于所述第一预设优先级而不低于所述第二预设优先级,则所述终端设备10也会将该待回收进程作为一个目标待回收进程。
在本公开的另一种实施例中,所述步骤S250无须基于所述第一预设优先级及所述第二预设优先级来确定所述目标待回收进程,此时所述终端设备10可在根据监测到的优先级变化情况筛选出所有的当前优先级变低的待回收进程后,直接将筛选出的所述待回收进程作为对应的所述目标待回收进程,此时所述目标待回收进程变化前后的优先级 与所述第一预设优先级及所述第二预设优先级均无关联关系。
步骤S260,检测所述目标待回收进程对应的目标匿名页面是否保存在内存空间中。
在本实施例中,所述终端设备10在确定了某个目标待回收进程后,将检测该目标待回收进程所对应的目标匿名页面(该目标待回收进程的部分匿名页面或全部匿名页面)是否在所述内存空间中有所保存。
步骤S270,若检测到所述目标匿名页面保存在所述内存空间中,则从所述内存空间中将至少一个所述目标匿名页面回收到所述交换空间中。
在本实施例中,当所述终端设备10检测到某个目标待回收进程对应的目标匿名页面保存在所述内存空间中时,所述终端设备10将从所述内存空间中将与该目标待回收进程对应的至少一个目标匿名页面回收到所述交换空间中,以释放所述内存空间中被所述目标匿名页面占用的存储资源,从而降低所述终端设备10的内存压力。
在一个实施例中,在本实施例的一种实施方式中,所述从所述内存空间中将至少一个所述目标匿名页面回收到所述交换空间中的步骤包括:
检测该目标待回收进程当前保存在所述内存空间中的每个目标匿名页面是否被所述目标待执行进程占用;
根据检测结果从该目标待回收进程当前保存在所述内存空间中的所有目标匿名页面中,选取出至少一个未被所述目标待执行进程占用的目标匿名页面,并将选取出的所述目标匿名页面回收到所述交换空间中。
其中,所述目标待执行进程为当前优先级不低于第一预设优先级的优先级变高的待执行进程。当该目标待回收进程当前保存在所述内存空间中的所有目标匿名页面均未被其他目标待执行进程占用时,所述终端设备10会将所述所有目标匿名页面回收到所述交换空间中;当该目标待回收进程当前保存在所述内存空间中的部分目标匿名页面未被其他目标待执行进程占用时,所述终端设备10会将未被其他目标待执行进程占用的所有目标匿名页面回收到所述交换空间中。
在一个实施例中,在本实施例的另一种实施方式中,所述从所述内存空间中将至少一个所述目标匿名页面回收到所述交换空间中的步骤包括:
直接将该目标待回收进程当前保存在所述内存空间中的所有目标匿名页面回收到所述交换空间中。
其中,所述终端设备10可无须在意该目标待回收进程与其他进程(包括其他待回收进程及其他待回收进程)之间的匿名页面占用关系,并在检测到该目标待回收进程对 应的目标匿名页面保存在所述内存空间中时,所述终端设备10将直接将该目标待回收进程当前保存在所述内存空间中的所有目标匿名页面回收到所述交换空间中,以释放所述内存空间中被所述目标匿名页面占用的存储资源,从而降低所述终端设备10的内存压力。
请参照图6,是本公开实施例提供的匿名页面管理方法的第三种流程示意图。在本公开实施例中,与图4所示的匿名页面管理方法相比,图6所示的匿名页面管理方法不包括有图2所示的匿名页面管理方法的相关步骤,而仅包括用于对所述终端设备10中各匿名页面进行灵活的回收处理的步骤S310、步骤S320、步骤S330及步骤S340。图6所示的匿名页面管理方法可使所述终端设备10根据每个进程的优先级变化情况来回收匿名页面,而非如现有技术那般直接回收不常使用的匿名页面,以避免出现如现有技术那般直接将当前需要马上执行或正在执行的进程所对应的属于不常使用的匿名页面进行回收处理的现象,从而灵活地对各匿名页面进行回收处理,降低所述终端设备10的内存压力。其中,所述步骤S310、所述步骤S320、所述步骤S330及所述步骤S340各自对应的执行过程,可依次参照上文中步骤S210、步骤S250、步骤S260及步骤S270的详细描述。
步骤S310,监测终端设备10中是否存在优先级发生变化的进程,例如但不限于:实时监测终端设备10中是否存在优先级发生变化的进程。
步骤S320,根据监测到的每个进程的优先级变化情况确定目标待回收进程。
步骤S330,检测所述目标待回收进程对应的目标匿名页面是否保存在内存空间中。
步骤S340,若检测到所述目标匿名页面保存在所述内存空间中,则从所述内存空间中将至少一个所述目标匿名页面回收到交换空间中,其中所述交换空间用于回收匿名页面。
其中,针对步骤S320,所述步骤S320可基于第二预设优先级及第一预设优先级来确定所述目标待回收进程,也可无须基于所述第一预设优先级及所述第二预设优先级来确定所述目标待回收进程。其中所述第二预设优先级不高于所述第一预设优先级。
在一个实施例中,在本公开的一种实施例中,当所述步骤S320需基于第二预设优先级及第一预设优先级来确定所述目标待回收进程,此时所述步骤S320包括:
根据监测到的每个进程的优先级变化情况,筛选出所有的当前优先级变低的需要回收匿名页面的待回收进程;
针对每个筛选出的待回收进程,将该待回收进程变低后的优先级与第二预设优先级 进行比较;
若该待回收进程变低后的优先级低于所述第二预设优先级,则选定该待回收进程作为一个目标待回收进程;
若该待回收进程变低后的优先级不低于第二预设优先级,则将该待回收进程变低前后的优先级与第一预设优先级进行比较,并在该待回收进程变低前的优先级不低于所述第一预设优先级且变低后的优先级低于所述第一预设优先级时,选定该待回收进程作为一个目标待回收进程。
其中,所述步骤S320包括的各子步骤的执行过程,可依次参照上文中对子步骤S251、子步骤S252、子步骤S253及子步骤S254的详细描述,在此就不再赘述。
在一个实施例中,在本公开的另一种实施例中,当所述步骤S320无须基于所述第一预设优先级及所述第二预设优先级来确定所述目标待回收进程时,所述终端设备10可在根据监测到的优先级变化情况筛选出所有的当前优先级变低的待回收进程后,直接将筛选出的所述待回收进程作为对应的所述目标待回收进程,此时所述目标待回收进程变化前后的优先级与所述第一预设优先级及所述第二预设优先级均无关联关系。
其中,针对所述步骤S340,所述步骤S340可对应两种实施方式,其中一种实施方式需考虑其他当前优先级变高且变高后的优先级不低于第一预设优先级的待执行进程(即目标待执行进程)的影响,另一种实施方式则无需考虑目标待执行进程的影响。
在一个实施例中,在本实施例的一种实施方式中,所述从所述内存空间中将至少一个所述目标匿名页面回收到交换空间中的步骤包括:
检测该目标待回收进程当前保存在所述内存空间中的每个目标匿名页面是否被所述目标待执行进程占用;
根据检测结果从该目标待回收进程当前保存在所述内存空间中的所有目标匿名页面中,选取出至少一个未被所述目标待执行进程占用的目标匿名页面,并将选取出的所述目标匿名页面回收到所述交换空间中。
在一个实施例中,在本实施例的另一种实施方式中,所述从所述内存空间中将至少一个所述目标匿名页面回收到交换空间中的步骤包括:
直接将该目标待回收进程当前保存在所述内存空间中的所有目标匿名页面回收到所述交换空间中。
其中,所述步骤S340所对应的两种实施方式的执行过程,可依次参照上文中对步骤S270所包括的两种实施方式的详细描述,在此就不再赘述。
请参照图7,是本公开实施例提供的匿名页面管理装置100的第一种方框示意图。在本公开实施例中,图7所示的匿名页面管理装置100可以执行图2所示的匿名页面管理方法,所述匿名页面管理装置100包括进程监测模块110、进程确定模块120、页面检测模块130及页面预读取模块140。
所述进程监测模块110,配置为实时监测终端设备10中是否存在优先级发生变化的进程。
在本实施例中,所述进程监测模块110可以执行图2中的步骤S210,具体的描述可参照上文中对步骤S210的详细描述。
所述进程确定模块120,配置为根据监测到的每个进程的优先级变化情况确定目标待执行进程。
在本实施例中,所述进程确定模块120可配置为
根据监测到的每个进程的优先级变化情况,筛选出所有的当前优先级变高的待执行进程;
针对每个筛选出的待执行进程,检测该待执行进程变高后的优先级是否不低于第一预设优先级;
若检测到该待执行进程变高后的优先级不低于所述第一预设优先级,则选定该待执行进程作为一个目标待执行进程。
其中,所述进程确定模块120可以执行图2中的步骤S220及图3中的子步骤S221、子步骤S222及子步骤S223,具体的描述可参照上文中对步骤S220、子步骤S221、子步骤S222及子步骤S223的详细描述。
所述页面检测模块130,配置为检测所述目标待执行进程对应的目标匿名页面是否保存在交换空间中,其中所述交换空间用于回收匿名页面。
在本实施例中,所述页面检测模块130可以执行图2中的步骤S230,具体的描述可参照上文中对步骤S230的详细描述。
所述页面预读取模块140,配置为若检测到所述目标匿名页面保存在所述交换空间中,则从所述交换空间中预读取所述目标匿名页面,以在所述目标待执行进程被执行时,直接使用所述目标匿名页面。
在本实施例中,所述页面预读取模块140可以执行图2中的步骤S240,具体的描述可参照上文中对步骤S240的详细描述。
请参照图8,是本公开实施例提供的匿名页面管理装置100的第二种方框示意图。 在本公开实施例中,图8所示的匿名页面管理装置100可以执行图2及图4所示的匿名页面管理方法,与图7所示的匿名页面管理装置100相比,图8所示的匿名页面管理装置100还包括页面回收模块150。
所述进程确定模块120,还配置为根据监测到的每个进程的优先级变化情况确定目标待回收进程。
在本实施例中,所述进程确定模块120,还配置为根据监测到的每个进程的优先级变化情况,筛选出所有的当前优先级变低的需要回收匿名页面的待回收进程;
针对每个筛选出的待回收进程,将该待回收进程变低后的优先级与第二预设优先级进行比较,其中所述第二预设优先级不高于第一预设优先级;
若该待回收进程变低后的优先级低于所述第二预设优先级,则选定该待回收进程作为一个目标待回收进程;
若该待回收进程变低后的优先级不低于第二预设优先级,则将该待回收进程变低前后的优先级与第一预设优先级进行比较,并在该待回收进程变低前的优先级不低于所述第一预设优先级且变低后的优先级低于所述第一预设优先级时,选定该待回收进程作为一个目标待回收进程。
其中,所述进程确定模块120还可以执行图4中的步骤S250及图5中的子步骤S251、子步骤S252、子步骤S253及子步骤S254,具体的描述可参照上文中对步骤S250、子步骤S251、子步骤S252、子步骤S253及子步骤S254的详细描述。
所述页面检测模块130,还配置为检测所述目标待回收进程对应的目标匿名页面是否保存在内存空间中。
在本实施例中,所述页面检测模块130还可以执行图4中的步骤S260,具体的描述可参照上文中对步骤S260的详细描述。
所述页面回收模块150,配置为若检测到所述目标匿名页面保存在所述内存空间中,则从所述内存空间中将至少一个所述目标匿名页面回收到所述交换空间中。
在本实施例的一种实施方式中,所述页面回收模块150,配置为检测该目标待回收进程当前保存在所述内存空间中的每个目标匿名页面是否被所述目标待执行进程占用;
根据检测结果从该目标待回收进程当前保存在所述内存空间中的所有目标匿名页面中,选取出至少一个未被所述目标待执行进程占用的目标匿名页面,并将选取出的所述目标匿名页面回收到所述交换空间中。
在本实施例的另一种实施方式中,所述页面回收模块150,配置为
直接将该目标待回收进程当前保存在所述内存空间中的所有目标匿名页面回收到所述交换空间中。
其中,所述页面回收模块150可以执行图4中的步骤S270,具体的描述可参照上文中对步骤S270的详细描述。
请参照图9,是本公开实施例提供的匿名页面管理装置100的第三种方框示意图。在本公开实施例中,图9所示的匿名页面管理装置100可以执行图6所示的匿名页面管理方法,所述匿名页面管理装置100包括进程监测模块110、进程确定模块120、页面检测模块130及页面回收模块150。
所述进程监测模块110,配置为实时监测终端设备10中是否存在优先级发生变化的进程。
在本实施例中,所述进程监测模块110可以执行图6中的步骤S310,具体的描述可参照上文中对步骤S310的详细描述。
所述进程确定模块120,配置为根据监测到的每个进程的优先级变化情况确定目标待回收进程。
在本实施例中,所述进程确定模块120可以执行图6中的步骤S320,具体的描述可参照上文中对步骤S320的详细描述。在本实施例的一种实施方式中,所述进程确定模块120根据监测到的每个进程的优先级变化情况确定目标待回收进程的方式,包括:
根据监测到的每个进程的优先级变化情况,筛选出所有的当前优先级变低的需要回收匿名页面的待回收进程;
针对每个筛选出的待回收进程,将该待回收进程变低后的优先级与第二预设优先级进行比较,其中所述第二预设优先级不高于第一预设优先级;
若该待回收进程变低后的优先级低于所述第二预设优先级,则选定该待回收进程作为一个目标待回收进程;
若该待回收进程变低后的优先级不低于第二预设优先级,则将该待回收进程变低前后的优先级与第一预设优先级进行比较,并在该待回收进程变低前的优先级不低于所述第一预设优先级且变低后的优先级低于所述第一预设优先级时,选定该待回收进程作为一个目标待回收进程。
所述页面检测模块130,配置为检测所述目标待回收进程对应的目标匿名页面是否保存在内存空间中。
在本实施例中,所述页面检测模块130可以执行图6中的步骤S330,具体的描述 可参照上文中对步骤S330的详细描述。
所述页面回收模块150,配置为若检测到所述目标匿名页面保存在所述内存空间中,则从所述内存空间中将至少一个所述目标匿名页面回收到交换空间中,其中所述交换空间用于回收匿名页面。
在本实施例中,所述页面回收模块150可以执行图6中的步骤S340,具体的描述可参照上文中对步骤S340的详细描述。
在一个实施例中,在本实施例的一种实施方式中,所述页面回收模块150从所述内存空间中将至少一个所述目标匿名页面回收到交换空间中的方式,包括:
检测该目标待回收进程当前保存在所述内存空间中的每个目标匿名页面是否被所述目标待执行进程占用;
根据检测结果从该目标待回收进程当前保存在所述内存空间中的所有目标匿名页面中,选取出至少一个未被所述目标待执行进程占用的目标匿名页面,并将选取出的所述目标匿名页面回收到所述交换空间中。
在一个实施例中,在本实施例的另一种实施方式中,所述页面回收模块150从所述内存空间中将至少一个所述目标匿名页面回收到交换空间中的方式,包括:
直接将该目标待回收进程当前保存在所述内存空间中的所有目标匿名页面回收到所述交换空间中。
本公开实施例还提供一种可读存储介质,所述可读存储介质存储有计算机程序,所述计算机程序运行时控制所述可读存储介质所在终端设备10执行上述的匿名页面管理方法。其中,所述可读存储介质可以是终端设备10(比如,个人计算机、服务器等)能够存取的任何可用介质或者是包含一个或多个可用介质集成的服务器、数据中心等数据存储设备。所述可用介质可以是磁性介质,(例如,软盘、硬盘、磁带)、光介质(例如,DVD)、或者半导体介质(例如固态硬盘Solid State Disk(SSD))等各种可以存储程序代码的介质。
综上所述,在本公开实施例提供的匿名页面管理方法、装置、终端设备及可读存储介质中,所述匿名页面管理方法可在对匿名页面保存在交换空间内的待执行进程进行执行时,降低该待执行进程出现随机卡顿的概率,确保该待执行进程的执行效能。首先,所述方法监测所述终端设备中是否存在优先级发生变化的进程,并根据监测到的每个进程的优先级变化情况确定目标待执行进程;然后,所述方法检测该目标待执行进程对应的目标匿名页面是否保存在交换空间中;最后,所述方法在检测到所述目标匿名页面保 存在所述交换空间中时,从所述交换空间中预读取所述目标匿名页面,以在该目标待执行进程被执行时,直接使用被预读取出的所述目标匿名页面,从而降低该待执行进程出现随机卡顿的概率,确保该待执行进程的执行效能。
本公开实施例提供的任意一种匿名页面管理装置可包括:处理器和存储器;存储器存储有可执行代码,处理器与存储器连接,配置为执行存储器上的可执行代码,实现本公开任意实施例提供的匿名页面管理方法。
该可执行代码包括但不限于:源代码和/或目标代码。
以上所述仅为本公开的优选实施例而已,并不用于限制本公开,对于本领域的技术人员来说,本公开可以有各种更改和变化。凡在本公开的精神和原则之内,所作的任何修改、等同替换、改进等,均应包含在本公开的保护范围之内。

Claims (16)

  1. 一种匿名页面管理方法,其中,应用于终端设备,所述方法包括:
    监测所述终端设备中是否存在优先级发生变化的进程;
    根据监测到的每个进程的优先级变化情况确定目标待执行进程;
    检测所述目标待执行进程对应的目标匿名页面是否保存在交换空间中,其中所述交换空间用于回收匿名页面;
    若检测到所述目标匿名页面保存在所述交换空间中,则从所述交换空间中预读取所述目标匿名页面。
  2. 根据权利要求1所述的方法,其中,所述根据监测到的每个进程的优先级变化情况确定目标待执行进程,包括:
    根据监测到的每个进程的优先级变化情况,筛选出所有的当前优先级变高的待执行进程;
    针对每个筛选出的待执行进程,检测该待执行进程变高后的优先级是否不低于第一预设优先级;
    若检测到该待执行进程变高后的优先级不低于所述第一预设优先级,则选定该待执行进程作为一个目标待执行进程。
  3. 根据权利要求1或2所述的方法,其中,所述方法还包括:
    根据监测到的每个进程的优先级变化情况确定目标待回收进程;
    检测所述目标待回收进程对应的目标匿名页面是否保存在内存空间中;
    若检测到所述目标匿名页面保存在所述内存空间中,则从所述内存空间中将至少一个所述目标匿名页面回收到所述交换空间中。
  4. 根据权利要求3所述的方法,其中,所述根据监测到的每个进程的优先级变化情况确定目标待回收进程,包括:
    根据监测到的每个进程的优先级变化情况,筛选出所有的当前优先级变低的需要回收匿名页面的待回收进程;
    针对每个筛选出的待回收进程,将该待回收进程变低后的优先级与第二预设优先级进行比较,其中所述第二预设优先级不高于第一预设优先级;
    若该待回收进程变低后的优先级低于所述第二预设优先级,则选定该待回收进程作为一个目标待回收进程;
    若该待回收进程变低后的优先级不低于第二预设优先级,则将该待回收进程变低前后的优先级与第一预设优先级进行比较,并在该待回收进程变低前的优先级不低于所述第一预设优先级且变低后的优先级低于所述第一预设优先级时,选定该待回收进程作为一个目标待回收进程。
  5. 根据权利要求4所述的方法,其中,所述从所述内存空间中将至少一个所述目标匿名页面回收到所述交换空间中,包括:
    检测该目标待回收进程当前保存在所述内存空间中的每个目标匿名页面是否被所述目标待执行进程占用;
    根据检测结果从该目标待回收进程当前保存在所述内存空间中的所有目标匿名页面中,选取出至少一个未被所述目标待执行进程占用的目标匿名页面,并将选取出的所述目标匿名页面回收到所述交换空间中。
  6. 根据权利要求4所述的方法,其中,所述从所述内存空间中将至少一个所述目标匿名页面回收到所述交换空间中,包括:
    直接将该目标待回收进程当前保存在所述内存空间中的所有目标匿名页面回收到所述交换空间中。
  7. 一种匿名页面管理方法,其中,应用于终端设备,所述方法包括:
    监测所述终端设备中是否存在优先级发生变化的进程;
    根据监测到的每个进程的优先级变化情况确定目标待回收进程;
    检测所述目标待回收进程对应的目标匿名页面是否保存在内存空间中;
    若检测到所述目标匿名页面保存在所述内存空间中,则从所述内存空间中将至少一个所述目标匿名页面回收到交换空间中,其中所述交换空间用于回收匿名页面。
  8. 一种匿名页面管理装置,其中,应用于终端设备,所述装置包括:
    进程监测模块,配置为监测所述终端设备中是否存在优先级发生变化的进程;
    进程确定模块,配置为根据监测到的每个进程的优先级变化情况确定目标待执行进程;
    页面检测模块,配置为检测所述目标待执行进程对应的目标匿名页面是否保存在交换空间中,其中所述交换空间用于回收匿名页面;
    页面预读取模块,配置为若检测到所述目标匿名页面保存在所述交换空间中,则从所述交换空间中预读取所述目标匿名页面,以在所述目标待执行进程被执行时,直接使用所述目标匿名页面。
  9. 根据权利要求8所述的装置,其中,所述进程确定模块,配置为根据监测到的每个进程的优先级变化情况,筛选出所有的当前优先级变高的待执行进程;
    针对每个筛选出的待执行进程,检测该待执行进程变高后的优先级是否不低于第一预设优先级;
    若检测到该待执行进程变高后的优先级不低于所述第一预设优先级,则选定该待执行进程作为一个目标待执行进程。
  10. 根据权利要求8或9所述的装置,其中,所述装置还包括页面回收模块;
    所述进程确定模块,还配置为根据监测到的每个进程的优先级变化情况确定目标待回收进程;
    所述页面检测模块,还配置为检测所述目标待回收进程对应的目标匿名页面是否保存在内存空间中;
    所述页面回收模块,配置为若检测到所述目标匿名页面保存在所述内存空间中,则从所述内存空间中将至少一个所述目标匿名页面回收到所述交换空间中。
  11. 根据权利要求10所述的装置,其中,所述进程确定模块,还配置为根据监测到的每个进程的优先级变化情况,筛选出所有的当前优先级变低的需要回收匿名页面的待回收进程;
    针对每个筛选出的待回收进程,将该待回收进程变低后的优先级与第二预设优先级进行比较,其中所述第二预设优先级不高于第一预设优先级;
    若该待回收进程变低后的优先级低于所述第二预设优先级,则选定该待回收进程作为一个目标待回收进程;
    若该待回收进程变低后的优先级不低于第二预设优先级,则将该待回收进程变低前后的优先级与第一预设优先级进行比较,并在该待回收进程变低前的优先级不低于所述第一预设优先级且变低后的优先级低于所述第一预设优先级时,选定该待回收进程作为一个目标待回收进程。
  12. 根据权利要求11所述的装置,其中,所述页面回收模块,配置为检测该目标待回收进程当前保存在所述内存空间中的每个目标匿名页面是否被所述目标待执行进程占用;
    根据检测结果从该目标待回收进程当前保存在所述内存空间中的所有目标匿名页面中,选取出至少一个未被所述目标待执行进程占用的目标匿名页面,并将选取出的所述目标匿名页面回收到所述交换空间中。
  13. 根据权利要求11所述的装置,其中,所述页面回收模块具体用于:
    直接将该目标待回收进程当前保存在所述内存空间中的所有目标匿名页面回收到所述交换空间中。
  14. 一种匿名页面管理装置,其中,应用于终端设备,所述装置包括:
    进程监测模块,配置为监测所述终端设备中是否存在优先级发生变化的进程;
    进程确定模块,配置为根据监测到的每个进程的优先级变化情况确定目标待回收进程;
    页面检测模块,配置为检测所述目标待回收进程对应的目标匿名页面是否保存在内存空间中;
    页面回收模块,配置为若检测到所述目标匿名页面保存在所述内存空间中,则从所述内存空间中将至少一个所述目标匿名页面回收到交换空间中,其中所述交换空间用于回收匿名页面。
  15. 一种终端设备,其中,所述终端设备包括处理器及存储有计算机指令的非易失性存储器,所述计算机指令被所述处理器执行时,所述终端设备执行权利要求1-7中任意一项所述的匿名页面管理方法。
  16. 一种可读存储介质,其中,所述可读存储介质包括计算机程序,所述计算机程序运行时控制所述可读存储介质所在终端设备执行权利要求1-7中任意一项所述的匿名页面管理方法。
PCT/CN2020/084989 2019-04-15 2020-04-15 匿名页面管理方法、装置、终端设备及可读存储介质 WO2020211791A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
EP20792131.3A EP3958120A4 (en) 2019-04-15 2020-04-15 METHOD AND DEVICE FOR MANAGING ANONYMOUS PAGES, TERMINAL DEVICE, AND READABLE STORAGE MEDIA
US17/501,994 US20220035655A1 (en) 2019-04-15 2021-10-14 Method and Device for Anonymous Page Management, Terminal Device, and Readable Storage Medium

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910300812.0 2019-04-15
CN201910300812.0A CN110008016B (zh) 2019-04-15 2019-04-15 匿名页面管理方法、装置、终端设备及可读存储介质

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US17/501,994 Continuation US20220035655A1 (en) 2019-04-15 2021-10-14 Method and Device for Anonymous Page Management, Terminal Device, and Readable Storage Medium

Publications (1)

Publication Number Publication Date
WO2020211791A1 true WO2020211791A1 (zh) 2020-10-22

Family

ID=67171942

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/084989 WO2020211791A1 (zh) 2019-04-15 2020-04-15 匿名页面管理方法、装置、终端设备及可读存储介质

Country Status (4)

Country Link
US (1) US20220035655A1 (zh)
EP (1) EP3958120A4 (zh)
CN (1) CN110008016B (zh)
WO (1) WO2020211791A1 (zh)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110008016B (zh) * 2019-04-15 2021-06-22 深圳市万普拉斯科技有限公司 匿名页面管理方法、装置、终端设备及可读存储介质
CN110532197B (zh) * 2019-08-30 2022-03-01 Oppo(重庆)智能科技有限公司 内存回收方法及装置、电子设备、存储介质
CN111078586B (zh) * 2019-12-10 2022-03-01 Oppo(重庆)智能科技有限公司 内存回收方法、装置、存储介质及电子设备
CN111352861B (zh) * 2020-02-19 2023-09-29 Oppo广东移动通信有限公司 内存压缩方法、装置及电子设备
CN114185494B (zh) * 2022-02-16 2022-07-19 荣耀终端有限公司 内存匿名页的处理方法、电子设备及可读存储介质

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103713882A (zh) * 2013-12-20 2014-04-09 华为技术有限公司 一种数据换入内存的方法和装置
CN108205475A (zh) * 2017-08-25 2018-06-26 珠海市魅族科技有限公司 内存管理方法、终端设备、计算机装置以及可读存储介质
CN108228344A (zh) * 2017-08-22 2018-06-29 珠海市魅族科技有限公司 多进程内存处理方法及装置、计算机装置及可读存储介质
CN110008016A (zh) * 2019-04-15 2019-07-12 深圳市万普拉斯科技有限公司 匿名页面管理方法、装置、终端设备及可读存储介质

Family Cites Families (24)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101814038B (zh) * 2010-03-23 2012-10-03 杭州顺网科技股份有限公司 一种加快计算机启动速度的方法
CN101859282B (zh) * 2010-05-26 2011-09-21 浙江大学 基于双重跟踪的虚拟化平台的磁盘页面换入的方法
US8356141B2 (en) * 2010-06-28 2013-01-15 Hewlett-Packard Development Company, L.P. Identifying replacement memory pages from three page record lists
US9201810B2 (en) * 2012-01-26 2015-12-01 Microsoft Technology Licensing, Llc Memory page eviction priority in mobile computing devices
CN102662713B (zh) * 2012-04-12 2014-04-16 腾讯科技(深圳)有限公司 提高应用程序运行速度的方法、装置及终端
CN103425502B (zh) * 2012-05-15 2015-09-16 腾讯科技(深圳)有限公司 一种操作系统的预取启动方法和装置
CN102904923B (zh) * 2012-06-21 2016-01-06 华数传媒网络有限公司 一种缓解磁盘读取瓶颈的数据读取的方法及系统
CN104123241B (zh) * 2013-04-24 2017-08-29 华为技术有限公司 内存匿名页初始化方法、装置及系统
CN103309740B (zh) * 2013-06-05 2016-12-28 腾讯科技(深圳)有限公司 程序启动方法、装置和设备
CN103677900B (zh) * 2013-11-15 2017-05-31 北京奇虎科技有限公司 一种计算机设备系统启动加速的方法和装置
CN103810009B (zh) * 2014-02-20 2017-06-16 北京奇虎科技有限公司 一种计算机操作系统启动加速的方法和装置
CN103916465A (zh) * 2014-03-21 2014-07-09 中国科学院计算技术研究所 一种基于分布式文件系统的数据预读装置及其方法
CN103885776A (zh) * 2014-03-24 2014-06-25 广州华多网络科技有限公司 程序加速方法及其装置
CN105094689B (zh) * 2014-05-16 2018-06-15 华为技术有限公司 非易失性存储器nvm页框初始化方法、装置和系统
CN104794182B (zh) * 2015-04-10 2018-10-09 中国科学院计算技术研究所 一种并行网络文件系统小文件异步预读装置及方法
CN105072489B (zh) * 2015-07-17 2018-08-03 成都视达科信息技术有限公司 一种快速文件读取的方法和系统
CN105159777B (zh) * 2015-08-03 2018-07-27 中科创达软件股份有限公司 进程的内存回收方法及装置
US10884950B2 (en) * 2016-05-16 2021-01-05 International Business Machines Corporation Importance based page replacement
CN107480150B (zh) * 2016-06-07 2020-12-08 阿里巴巴集团控股有限公司 一种文件加载方法和装置
US10372606B2 (en) * 2016-07-29 2019-08-06 Samsung Electronics Co., Ltd. System and method for integrating overprovisioned memory devices
CN108205498B (zh) * 2017-08-01 2021-04-27 珠海市魅族科技有限公司 内存回收方法及装置、计算机装置及计算机可读存储介质
CN108205471B (zh) * 2017-08-01 2021-04-27 珠海市魅族科技有限公司 内存回收方法及装置、计算机装置及计算机可读存储介质
CN108228343B (zh) * 2017-08-21 2020-11-17 珠海市魅族科技有限公司 内存回收方法及装置、计算机装置及计算机可读存储介质
CN107704321A (zh) * 2017-09-30 2018-02-16 北京元心科技有限公司 内存分配的方法、装置及终端设备

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103713882A (zh) * 2013-12-20 2014-04-09 华为技术有限公司 一种数据换入内存的方法和装置
CN108228344A (zh) * 2017-08-22 2018-06-29 珠海市魅族科技有限公司 多进程内存处理方法及装置、计算机装置及可读存储介质
CN108205475A (zh) * 2017-08-25 2018-06-26 珠海市魅族科技有限公司 内存管理方法、终端设备、计算机装置以及可读存储介质
CN110008016A (zh) * 2019-04-15 2019-07-12 深圳市万普拉斯科技有限公司 匿名页面管理方法、装置、终端设备及可读存储介质

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
See also references of EP3958120A4

Also Published As

Publication number Publication date
CN110008016B (zh) 2021-06-22
EP3958120A4 (en) 2022-06-08
CN110008016A (zh) 2019-07-12
US20220035655A1 (en) 2022-02-03
EP3958120A1 (en) 2022-02-23

Similar Documents

Publication Publication Date Title
WO2020211791A1 (zh) 匿名页面管理方法、装置、终端设备及可读存储介质
CN107463627B (zh) 一种图片加载方法及终端
CN110764906B (zh) 内存回收处理方法、装置、电子设备以及存储介质
CN111258921B (zh) 垃圾内存回收方法及装置、电子设备、存储介质
CN111158910A (zh) 内存管理方法、装置、存储介质及电子设备
WO2021057665A1 (zh) 数据存储方法、装置、移动终端及存储介质
CN114996173B (zh) 一种管理存储设备写操作的方法和装置
CN114168490A (zh) 确定内存回收阈值的方法及相关设备
WO2020006860A1 (zh) 一种图片缓存清理方法、装置、终端设备及介质
WO2020006859A1 (zh) 一种图片缓存清理方法、装置、终端设备及介质
WO2016145804A1 (zh) 一种数据处理和装置
JP2015095219A (ja) 情報処理装置、情報処理方法および記憶媒体
WO2021243531A1 (zh) 数据压缩方法、装置、电子设备及存储介质
CN103677893A (zh) 开机的映像文件的大小缩减方法及运算装置
CN113412480B (zh) 挂载处理方法、装置、电子设备及计算机可读取存储介质
US9146876B2 (en) Caching method and caching system using dual disks
CN111177028B (zh) 一种动态多级缓存的方法和设备
CN115587049A (zh) 内存回收方法、装置、电子设备及存储介质
CN112579198A (zh) 一种启动应用程序的方法及装置
CN113032290A (zh) 闪存配置方法、装置、电子设备和存储介质
CN113934692A (zh) 文件清理方法、装置、存储介质及设备
US20200081741A1 (en) Information processing apparatus and memory management method
CN112925643B (zh) 数据处理方法、装置以及存储引擎装置
CN116016844A (zh) 一种终端设备的异常检测方法和装置、电子设备
CN107480004B (zh) 故障恢复方法、装置和计算机设备

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 20792131

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

ENP Entry into the national phase

Ref document number: 2020792131

Country of ref document: EP

Effective date: 20211115