[go: up one dir, main page]

CN108205501B - Memory recovery method and device, computer device and computer readable storage medium - Google Patents

Memory recovery method and device, computer device and computer readable storage medium Download PDF

Info

Publication number
CN108205501B
CN108205501B CN201710494549.4A CN201710494549A CN108205501B CN 108205501 B CN108205501 B CN 108205501B CN 201710494549 A CN201710494549 A CN 201710494549A CN 108205501 B CN108205501 B CN 108205501B
Authority
CN
China
Prior art keywords
physical page
value
activity
target physical
target
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
CN201710494549.4A
Other languages
Chinese (zh)
Other versions
CN108205501A (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.)
Wuhan Xingji Meizu Technology Co ltd
Original Assignee
Meizu Technology Co 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 Meizu Technology Co Ltd filed Critical Meizu Technology Co Ltd
Priority to CN201710494549.4A priority Critical patent/CN108205501B/en
Priority to PCT/CN2017/101009 priority patent/WO2019000644A1/en
Publication of CN108205501A publication Critical patent/CN108205501A/en
Application granted granted Critical
Publication of CN108205501B publication Critical patent/CN108205501B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • 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/06Addressing a physical block of locations, e.g. base addressing, module addressing, memory dedication
    • G06F12/0615Address space extension
    • G06F12/0623Address space extension for memory modules

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Memory System Of A Hierarchy Structure (AREA)
  • Machine Translation (AREA)
  • Feedback Control In General (AREA)
  • Electrically Operated Instructional Devices (AREA)
  • Memory System (AREA)

Abstract

The embodiment of the invention discloses a memory recovery method and device, a computer device and a computer readable storage medium, relates to the technical field of computers, and aims to solve the problem of low memory recovery efficiency in the prior art. The method provided by the embodiment of the invention comprises the following steps: acquiring a target physical page corresponding to a target process; reading the value of the activity of the target physical page, wherein the activity of the target physical page is used for marking the activity degree of the target physical page, and the value of the activity degree of the target physical page is positively correlated with the activity degree of the target physical page; if the value of the activity degree of the target physical page is higher than the recovery standard, reducing the activity degree of the target physical page, wherein the physical page with the activity degree value higher than the recovery standard is in an active state; reading the value of the activity of the target physical page; and if the value of the activity of the target physical page is not higher than the recovery standard, recovering the target physical page.

Description

Memory recovery method and device, computer device and computer readable storage medium
Technical Field
The invention relates to the technical field of computers, in particular to a memory recovery method and device, a computer device and a computer readable storage medium.
Background
In an operating system, in order to increase the speed of reading and writing a disk, a large amount of data is cached in a memory. Before using the memory, the application process needs to make an application and start to occupy the memory, and the memory is released in time after the memory is used. Because a user frequently changes an application during the process of using a terminal application, for example, a chat application may need to be frequently switched to the foreground during the process of watching a video by using video playing software, in order to reduce the waiting time of the user, an operating system usually reserves a memory occupied by the application process for transferring to the background. However, when the background applications are excessive and the memory is occupied in a large amount and cannot be released, the operating system may be abnormally operated due to insufficient memory allocation.
In order to avoid system exception caused by insufficient memory allocation, the operating system introduces a recovery mechanism for the memory. For example, when the memory is insufficient, the system may kill some background processes to reclaim the memory occupied by the background processes. However, when the user needs to use the applications corresponding to the processes, the processes need to be completely reloaded, which takes a long time and reduces user experience.
The method comprises the following steps that a linked list L RU is used at least recently, physical pages are arranged according to recent use conditions, when the memory is insufficient, a system can preferentially recycle the physical pages in the INACTIVE one-way and INACTIVE one-way FI L E, ANON represents anonymous mapping and does not have a backup memory, FI 83E represents file mapping, and INACTIVE represents an INACTIVE state.
In order to ensure normal operation of foreground application process and background application process with high priority, the prior art proposes a method for recovering memory of a process.
However, in the existing method for performing memory reclamation on a process, a reclaimed target physical page only aims at a target physical page that is not used by the target process, and the target physical page is mainly a physical page of the target process in two linked lists, namely INACTIVE _ ANON and INACTIVE _ FI L E, that is, a physical page in an INACTIVE state.
Disclosure of Invention
The invention provides a memory recovery method and device, a computer device and a computer readable storage medium, which are used for solving the problem of low memory recovery efficiency in the prior art.
An aspect of the embodiments of the present invention provides a memory recovery method, including:
acquiring a target physical page corresponding to a target process;
reading the value of the activity of the target physical page, wherein the activity of the target physical page is used for marking the activity degree of the target physical page, and the value of the activity of the target physical page is positively correlated with the activity degree of the target physical page;
if the value of the activity degree of the target physical page is higher than the recovery standard, reducing the activity degree of the target physical page, wherein the physical page with the activity degree value higher than the recovery standard is in an active state;
reading the value of the activity of the target physical page;
and if the value of the activity of the target physical page is not higher than the recovery standard, recovering the target physical page.
With reference to the first aspect, in a first possible implementation manner of the first aspect, after reducing the liveness of the target physical page, before reading the value of the liveness of the target physical page, the method further includes:
starting a timer;
and triggering the step of reading the value of the activity degree of the target physical page when the time length recorded by the timer reaches a preset time length.
With reference to the first possible implementation manner of the first aspect, in a second possible implementation manner of the first aspect, before starting the timer, the method further includes:
setting a preset time length according to the memory occupancy rate, wherein the preset time length is negatively related to the memory occupancy rate;
or,
and setting a preset time length according to the priority of the target process, wherein the preset time length is positively correlated with the priority of the target process.
With reference to the first aspect, the first possible implementation manner of the first aspect, and any one of the second possible implementation manner of the first aspect, in a third possible implementation manner of the first aspect, the selectable values of the activity degree at least include a first value, a second value, and a third value, where the first value is not higher than the recovery criterion, and the second value is lower than the third value and higher than the recovery criterion.
With reference to the third possible implementation manner of the first aspect, in a fourth possible implementation manner of the first aspect, the reducing the activity of the target physical page includes:
when the activity of the target physical page is a third value, setting the activity of the target physical page to be a second value;
and when the activity of the target physical page is a second value, setting the activity of the target physical page to be a first value.
With reference to the fourth possible implementation manner of the first aspect, in a fifth possible implementation manner of the first aspect, the reducing the activity of the target physical page includes:
when the target physical page is an anonymous page, reducing the activity of the target physical page according to a first amplitude;
when the target physical page is a file page, reducing the activity of the target physical page according to a second amplitude;
the first amplitude is lower than the second amplitude.
A second aspect of the embodiments of the present invention provides a memory recovery apparatus, including:
the acquisition module is used for acquiring a target physical page corresponding to a target process;
a first reading module, configured to read a value of activity of the target physical page, where the activity of the target physical page is used to mark an activity level of the target physical page, and the value of activity of the target physical page is positively correlated to the activity level of the target physical page;
the reducing module is used for reducing the activity of the target physical page when the value of the activity of the target physical page is higher than the recycling standard, and the physical page with the activity value higher than the recycling standard is in an active state;
a second reading module, configured to read a value of the activity of the target physical page after the reducing module reduces the activity of the target physical page;
a recycle module for recycling the target physical page when the value of the liveness of the target physical page is not higher than the recycle standard.
With reference to the second aspect, in a first possible implementation manner of the second aspect, the memory recovery apparatus further includes:
the timing module is used for starting a timer after reducing the activity of the target physical page and before reading the value of the activity of the target physical page;
and the triggering module is used for triggering the step of reading the value of the activity degree of the target physical page when the time length recorded by the timer reaches a preset time length.
With reference to the first possible implementation manner of the second aspect, in a second possible implementation manner of the second aspect, the memory recovery apparatus further includes:
the first setting module is used for setting preset time according to the memory occupancy rate before the timing module starts the timer, and the preset time is negatively related to the memory occupancy rate;
or,
and the second setting module is used for setting preset time according to the priority of the target process before the timing module starts the timer, and the preset time is positively correlated with the priority of the target process.
With reference to the second aspect, any one of the first possible implementation manner of the second aspect, and the second possible implementation manner of the second aspect, in a third possible implementation manner of the second aspect, the selectable values of the activity include at least a first value, a second value, and a third value, where the first value is not higher than the recycling criterion, and the second value is lower than the third value and higher than the recycling criterion.
With reference to the third possible implementation manner of the second aspect, in a fourth possible implementation manner of the second aspect, the reducing module includes:
the setting unit is used for setting the activity of the target physical page to be a second value when the activity of the target physical page is a third value; and when the activity of the target physical page is a second value, setting the activity of the target physical page to be a first value.
With reference to the fourth possible implementation manner of the second aspect, in a fifth possible implementation manner of the second aspect, the reducing module includes:
a reducing unit, configured to reduce, when the target physical page is an anonymous page, an activity of the target physical page by a first amplitude; when the target physical page is a file page, reducing the activity of the target physical page according to a second amplitude; the first amplitude is lower than the second amplitude.
A third aspect of an embodiment of the present invention provides a computer apparatus, including a processor, configured to implement any one of the possible implementation manners of the first aspect when the processor executes a computer program stored in a memory.
A fourth aspect of embodiments of the present invention provides a computer-readable storage medium, on which a computer program is stored, which, when executed by a processor, implements any one of the possible implementations of the first aspect.
According to the technical scheme, the embodiment of the invention has the following advantages:
after the target physical page corresponding to the target process is obtained, if the value of the activity of the target physical page is higher than the recovery standard, the activity of the target physical page can be reduced, and the target physical page is recovered when the activity of the target physical page is not higher than the recovery standard. Therefore, even if the target physical page is the physical page in the active state, the target physical page can be recycled, compared with the prior art, the method and the device expand the objects of memory recycling, and improve the memory recycling efficiency.
Drawings
FIG. 1 is a schematic diagram of a memory reclamation method according to an embodiment of the present invention;
FIG. 2 is a diagram of another embodiment of a memory reclamation method of the present invention;
FIG. 3 is a diagram illustrating another embodiment of a memory reclamation method according to the present invention;
FIG. 4 is a diagram illustrating another embodiment of a memory reclamation method according to the present invention;
FIG. 5 is a schematic diagram of an embodiment of a memory reclamation apparatus of the present invention;
FIG. 6 is a schematic diagram of another embodiment of a memory recycling device according to the present invention;
FIG. 7 is a schematic diagram of a computer device according to an embodiment of the present invention.
Detailed Description
The embodiment of the invention provides a memory recovery method and device, a computer device and a computer readable storage medium, which are used for expanding a memory recovery object and improving memory recovery efficiency.
In order to make the technical solutions of the present invention better understood, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The terms "first," "second," "third," "fourth," and the like in the description and in the claims, as well as in the drawings, if any, are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It will be appreciated that the data so used may be interchanged under appropriate circumstances such that the embodiments described herein may be practiced otherwise than as specifically illustrated or described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
Because a user frequently changes an application during the process of using a terminal application, for example, a chat application may need to be frequently switched to the foreground during the process of watching a video by using video playing software, in order to reduce the waiting time of the user, an operating system usually reserves a memory occupied by the application process for transferring to the background. However, when the background applications are excessive and the memory is occupied in a large amount and cannot be released, the operating system may be abnormally operated due to insufficient memory allocation.
Physical memory is typically divided into several shares, each of which is recorded as a physical page. One application process usually occupies a plurality of physical pages, and the operating system recovers the memory occupied by the application process, which is actually to recover the plurality of physical pages occupied by the application process. Regarding memory reclamation, the operating system needs to perform reclamation operations on the premise of ensuring that the data of the application is not lost. The page recovery mode generally includes three modes of page write-back, page exchange and page discard: 1) page write back, if the backing store of a physical page is a block device (e.g., a file map), the memory can be directly synchronized to the block device, and the freed page can be reused; 2) page swapping, in which if a physical page has no backing store (e.g., anonymous mapping), stored data can be swapped to a specific swap partition (a system typically creates a block of storage space on a disk for caching memory, and this part of storage space is generally referred to as a swap area), and then swapped back to memory when being accessed again; 3) page discard, which may be done directly if the backing store for a physical page is a file, but the contents of the file cannot be modified in memory (e.g., an executable file), is not currently needed.
With the above page reclamation mode, it seems that all memories can be released, thereby avoiding the situation of insufficient memory allocation. However, this will increase the number of times of reading and writing the system disk, and reloading will increase the waiting time of the user, and reduce the user experience. Therefore, the operating system will usually preferentially recycle the physical page storage data with lower value, and release the corresponding memory, so as to reduce the number of times of reading and writing the system disk and the waiting time of the user as much as possible under the condition of ensuring memory supply.
In order to compare the activity of a physical page, the prior art introduces a least recently used link L RU, which is arranged according to the usage situation, and the least used link exists at the end of INACTIVE links, INACTIVE _ ANON, INACTIVE _ 539fi 2E and ACTIVE _ FI L E, which are all 4 links that can be recycled, ANON represents an anonymous map, FI L E represents a file map, INACTIVE represents an INACTIVE state, ACTIVE represents an ACTIVE state, and the activity of the physical page in the ACTIVE link is higher than that of the physical page in the INACTIVE state, that is, the physical page in the ACTIVE link is in an ACTIVE state, which is higher than that of the physical page in the INACTIVE state, which is to be recycled from the INACTIVE link L, which is to say, when the physical page in the ACTIVE state has a higher activity than that of the physical page in the INACTIVE state, the system needs to recycle the corresponding contents of the INACTIVE link 36ru and the ACTIVE page L.
However, physical pages occupied by foreground-running application processes or background-running application processes with high priority may also be in INACTIVE _ ANON and INACTIVE _ FI L E, and physical pages corresponding to foreground-running processes and background-running processes with high priority in the two linked lists are recycled, so that the number of times of reading and writing of a system disk can be increased to a greater extent, the waiting time of a user is increased, and the user experience is reduced.
It can be seen that the application process should also be used as a weight for evaluating the value of the physical page. Therefore, the prior art proposes a method for performing memory recovery on a process, which includes first selecting a target process as a memory recovery object, acquiring a physical page of the target process, then searching a target physical page that is not used by the target process and recovering the target physical page, where the target physical page that is not used by the target process mainly refers to a physical page in an inactive state.
In an actual scene test, all physical pages occupied by a process falling back to the background for one minute are recycled, wherein the physical pages of the process in the INACTIVE _ ANON and INACTIVE _ FI L E linked lists only occupy 5% of the proportion of all the physical pages, and most of the physical pages are the physical pages of the process in the ACTIVE _ ANON and ACTIVE _ FI L E linked lists.
In order to improve the recycling efficiency, it is necessary to selectively recycle the physical pages in the ACTIVE _ ANON and ACTIVE _ FI L E linked lists, and preferably, the physical pages with lower value or lower activity are recycled, for this reason, the present invention provides a memory recycling method, please refer to fig. 1, where an embodiment of the memory recycling method of the present invention includes:
101. acquiring a target physical page corresponding to a target process;
in the process of performing memory recovery on a process, if the selected process is called a target process, a target physical page corresponding to the target process may be acquired. The method for acquiring the physical page corresponding to the process generally includes finding a virtual memory space VMA of the process according to the process identification number pid, traversing the VMA to find the physical page corresponding to the process, and also finding the physical page corresponding to the process in other manners, which is not limited specifically here.
The target physical page may be all physical pages corresponding to the target process, or may be a part of physical pages corresponding to the target process. The recovery of the target process may be performed in a serial manner, that is, only one physical page is selected as the target physical page for each recovery, and the recovery process of the present invention is executed, or may be performed in a parallel manner, that is, a plurality of physical pages are simultaneously selected as the target physical pages, and the recovery process of the present invention is executed simultaneously on the plurality of physical pages.
102. Reading the value of the activity of the target physical page;
after a target physical page corresponding to a target process is obtained, a value of activity of the target physical page can be read, the activity of the target physical page is used for marking the activity degree of the target physical page, and the value of activity of the target physical page is positively correlated with the activity degree of the target physical page, that is, the higher the activity degree of the physical page is, the larger the value of activity is. It will be appreciated that the selectable value of activity for a physical page should be no less than two.
It should be noted that the value of the activity may be a numerical value, and in this case, the value of the activity may be determined according to the numerical value, but the value of the activity should not be limited to the numerical value, as long as the level of the different value can be determined according to a preset comparison standard.
103. If the value of the activity degree of the target physical page is higher than the recovery standard, reducing the activity degree of the target physical page, wherein the physical page with the activity degree value higher than the recovery standard is in an active state;
after reading the value of the activity of the target physical page, it may be determined whether the value of the activity of the target physical page is higher than a reclamation criterion, where the physical page with the value of the activity higher than the reclamation criterion is in an active state, and the reclamation criterion may be regarded as a boundary value between the activity of the physical page in the active state and the activity of the physical page in the inactive state. If the value of the activity of the target physical page is determined to be higher than the recycle criterion, the activity of the target physical page may be reduced, and if the value of the activity of the target physical page is determined to be not higher than the recycle criterion, other operations, such as recycling the target physical page, may be performed.
104. Reading the value of the activity of the target physical page;
after step 103, the value of the liveness of the target physical page may be read. If the target physical page was accessed prior to step 104, the value of the target physical page's liveness is increased.
105. And if the value of the activity of the target physical page is not higher than the recovery standard, recovering the target physical page.
After reading the value of the activity of the target physical page again, whether the value of the activity of the target physical page is higher than the recovery standard or not can be judged, and if the value of the activity of the target physical page is not higher than the recovery standard, the target physical page is recovered. If the value of the activity of the target physical page is not higher than the recovery standard, it indicates that the target physical page is in the inactive state, and there are many methods for recovering the physical page in the inactive state in the prior art, so the embodiments of the present invention do not repeat the method for recovering the physical page in the inactive state any more.
After the target physical page corresponding to the target process is obtained, if the value of the activity of the target physical page is higher than the recovery standard, the activity of the target physical page can be reduced, and the target physical page is recovered when the activity of the target physical page is not higher than the recovery standard. Therefore, even if the target physical page is the physical page in the active state, the target physical page can be recycled, compared with the prior art, the method and the device expand the objects of memory recycling, and improve the memory recycling efficiency.
In addition, in the process of carrying out recovery attempt on the physical page in the active state, after the value of the activity degree is reduced, before next reading, the physical page which is not accessed shows that the physical page is not active enough in the recent time, and the value of the activity degree is still lower; after the value of the activity degree is reduced, the accessed physical page before the next reading shows that the physical page is more active in the recent time, and the value of the activity degree is higher. Compared with the accessed physical page, the physical page which is not accessed is more likely to be recycled due to the activity value of the physical page being not accessed being not higher than the recycling standard, so that the recycling of the physical page with lower value or lower activity value in the physical page in the active state is realized.
If the time interval between step 103 and step 104 is extremely short, and under the limit, it can be understood that after the activity of the target physical page is reduced in step 103, step 104 is directly executed to read the value of the activity of the target physical page, and if there are only two selectable values of the activity, in this way, almost all physical pages in an active state corresponding to the target process are recovered, which is equivalent to that the system automatically kills the target process, and the waiting time of the user is increased. Therefore, it is necessary to add a repentance mechanism in the embodiment corresponding to fig. 1, for example, setting an appropriate time interval between step 103 and step 104 as a repentance duration, and if a target physical page is accessed within the set time interval, the value of its liveness rises, so as to reduce the possibility of being reclaimed, which is beneficial to preventing the physical page with higher liveness from being reclaimed. Based on the above concept, referring to fig. 2, another embodiment of the memory recycling method of the present invention includes:
201. acquiring a target physical page corresponding to a target process;
202. setting a preset time length according to the priority of the target process, wherein the preset time length is positively correlated with the priority of the target process;
the repentance duration, in the embodiment of the present invention, referred to as a preset duration, may be a fixed duration default by the system, but preferably, after determining to recover the target process, the priority of the target process may be read, and the preset duration may be set according to the priority of the target process, so that the preset duration is positively correlated with the priority of the target process, that is, the higher the priority is, the longer the preset duration is set for the process.
Or, a preset time length may be set according to the memory occupancy rate, where the preset time length is negatively related to the memory occupancy rate, that is, the higher the memory occupancy rate is, the shorter the preset time length is, the higher the recovery efficiency is, so as to release more memories as soon as possible.
203. Reading the value of the activity of the target physical page, wherein the activity of the target physical page is used for marking the activity degree of the target physical page, and the value of the activity degree of the target physical page is positively correlated with the activity degree of the target physical page;
step 201 and step 203 are the same as step 101 and step 102 in the embodiment corresponding to fig. 1, respectively, and are not described again here.
204. Judging whether the value of the activity of the target physical page is higher than a recovery standard, if so, executing a step 205, and if not, executing a step 207;
after reading the value of the activity of the target physical page, it may be determined whether the value of the activity of the target physical page is higher than the reclamation criterion, and the physical page with the activity value higher than the reclamation criterion is in an active state, if so, step 205 is executed, and if not, step 207 is executed.
205. Reducing the activity of the target physical page;
if the value of the activity of the target physical page is judged to be higher than the recycling standard, the activity of the target physical page can be reduced.
206. Starting a timer;
after the activity of the target physical page is reduced, a timer can be started and the duration can be recorded. And when the time length recorded by the timer reaches the preset time length, repeatedly executing the steps 203 to 204. If the activity value of the target physical page is still determined to be higher than the eviction criterion when step 204 is repeatedly executed for the first time, step 205 is not executed again, and the eviction process for the target physical page is directly exited, that is, only one eviction attempt is performed on the physical page in the active state. In order to improve the reclamation efficiency and release more memory, it is preferable that two or more reclamation attempts are performed on the physical page in the active state, that is, the steps 203 to 204 may be repeated twice or more.
The number of repetitions may be preset to a certain limited value, and the actual scenario test result shows that the recovery efficiency of the first three recovery attempts is higher, and the recovery efficiency of the fourth and subsequent recovery attempts is very low, so the number of repetitions may be set to three. In addition, the repetition times can also be set according to the memory occupancy rate, and the higher the memory occupancy rate is, the more the recovery times are. Alternatively, in practical use, the number of repetitions may be set according to other considerations, and is not limited herein.
It should be noted that the timing sequence of step 202 in the embodiment of the present invention is not limited to the above, and since a preset time length is used for step 206, the specific timing sequence is not limited as long as it is executed before step 206.
207. And recycling the target physical page.
If step 204 determines that the value of the activity level of the target physical page is not higher than the recycle criterion, the target physical page is recycled.
To add the repentance mechanism to the embodiment corresponding to fig. 1, in addition to the embodiment corresponding to fig. 2, by setting an appropriate time interval between step 103 and step 104 as a repentance duration to prevent the physical page with higher liveness from being reclaimed as much as possible, two or more optional values may be set for the liveness higher than the reclamation standard, so that the physical page with higher liveness is less easily reclaimed in the reclamation attempt, and on the basis of this idea, please refer to fig. 3, another embodiment of the memory reclamation method of the present invention includes:
301. setting selectable values of the physical page liveness, wherein the selectable values comprise a first value, a second value, a third value and a fourth value;
optional values for setting physical page liveness may include, for example, a first value, a second value, a third value, and a fourth value, where the first value is not higher than the reclamation criteria, the second value is lower than the third value and higher than the reclamation criteria, and the third value is lower than the fourth value. Alternatively, it can be said that each selectable value represents the number of levels of activity of a physical page, and the higher the value, the higher the number of levels of activity.
By way of example, the activity level of a physical page may be evaluated by setting a flag bit, assuming that two flag bits are set, and the selectable values of each flag bit are 0 and 1, and the value of the activity may be represented by (a first flag bit value, a second flag bit value), then the selectable values of the activity include (0, 0), (0, 1), (1, 0) and (1, 1), and the comparison criterion (0, 0) is preset such that (0, 0) is lower than (1, 0) is lower than (0, 1) is lower than (1, 1), that is, (0, 0), (1, 0), (0, 1) is raised stepwise.
In actual use, a range of optional values may also be set without specifically setting individual values.
302. Acquiring a target physical page corresponding to a target process;
303. reading the value of the activity of the target physical page;
step 302 and step 303 are the same as step 101 and step 102 in the embodiment corresponding to fig. 1, respectively, and are not described again here.
304. Judging whether the value of the activity of the target physical page is higher than the recovery standard, if so, executing a step 305, otherwise, executing a step 307;
after reading the value of the activity of the target physical page, it may be determined whether the value of the activity of the target physical page is higher than the reclamation criterion, and the physical page with the activity value higher than the reclamation criterion is in an active state, if so, step 305 is executed, and if not, step 307 is executed.
305. Reducing the activity of the target physical page according to the first amplitude;
if it is determined that the value of the activity of the target physical page is higher than the reclamation criterion, the activity of the target physical page may be decreased by a first magnitude, which may be one step per time in the embodiment of the present invention.
306. Starting a timer;
a preset duration may be set as the repentance duration, and please refer to the embodiment corresponding to fig. 2 for setting the preset duration, which is not described in detail in the embodiment of the present invention.
And when the time length recorded by the timer reaches the preset time length, repeatedly executing the step 303 to the step 304. If the activity value of the target physical page is still determined to be higher than the eviction criterion when step 304 is repeatedly executed for the first time, step 305 is not executed again, and the eviction process for the target physical page is directly exited, that is, only one eviction attempt is performed on the physical page in the active state. In order to improve the reclamation efficiency and release more memory, it is preferable that two or more reclamation attempts are performed on the physical page in the active state, that is, steps 303 to 304 may be repeatedly performed two or more times.
The number of times of repetition can be preset, and the actual scene test result shows that the recovery efficiency of the previous recovery attempt is higher, and the recovery efficiency of the fourth and later recovery attempts is very low, so the number of times of repetition can be set to three. In addition, the repetition times can also be set according to the memory occupancy rate, and the higher the memory occupancy rate is, the more the recovery times are. Alternatively, in practical use, the number of repetitions may be set according to other considerations, and is not limited herein.
307. And recycling the target physical page.
And if the value of the activity of the target physical page is not higher than the recovery standard, recovering the target physical page.
The following method provided according to the embodiment corresponding to fig. 3 is exemplified by different cases of the value of the first read activity, assuming that the maximum number of times of repeated execution of steps 303 to 304 is set to 3:
if during a reclamation attempt, the target physical page is not accessed and the value of its liveness is not increased, then:
if the value of the activity of the target physical page is read for the first time to be the fourth value, after step 305 is executed, the value of the activity of the target physical page is set to be the third value, then step 303 to step 304 are repeatedly executed for the first time, since the value of the activity is still higher than the recovery standard, the value of the activity is continuously decreased by one step and set to be the second value, then step 303 to step 304 are repeatedly executed for the second time, since the value of the activity is still higher than the recovery standard, the value of the activity is continuously decreased by one step and set to be the first value, then step 303 to step 304 are repeatedly executed for the third time, and since the value of the activity is not higher than the recovery standard, the target physical page is recovered. If the value of the activity of the first read target physical page is the fourth value, the physical page needs to be recycled by repeating the steps 303 to 304 at least three times.
If the value of the activity of the target physical page is read for the first time to be the third value, after step 305 is executed, the value of the activity of the target physical page is set to be the second value, then step 303 to step 304 are repeatedly executed for the first time, since the value of the activity is still higher than the recovery standard, the value of the activity is continuously decreased by one step to be set to be the first value, then step 303 to step 304 are repeatedly executed for the second time, and since the value of the activity is not higher than the recovery standard, the target physical page is recovered. If the value of the activity of the first read target physical page is the third value, the physical page needs to be recycled by repeating the steps 303 to 304 at least twice.
If the value of the activity of the target physical page is read for the first time to be the second value, after step 305 is executed, the value of the activity of the target physical page is set to be the first value, and then steps 303 to 304 are repeatedly executed for the first time, and the target physical page is recycled because the value of the activity is not higher than the recycling standard. If the value of the activity of the first read target physical page is the second value, the physical page needs to be recycled by repeating the steps 303 to 304 at least once.
If the value of the activity of the target physical page is read for the first time and is the first value, the target physical page is recycled because the value of the activity is not higher than the recycling standard. If the value of the activity of the first read target physical page is the first value, the physical page can be recycled without repeatedly performing steps 303 to 304.
Therefore, before the recovery step of the present invention is executed, the physical page with higher activity value is less likely to be recovered, that is, the present invention can preferentially recover the physical page with lower activity, and realize the fine classification and recovery of the physical page in the active state.
Second, assuming that the target physical page is accessed during the eviction attempt, the value of its activity increases, and the system needs more eviction attempts to evict the target physical page than in the first case. In practical application, a system usually performs a limited number of recovery attempts on a physical page, and if the value of the activity of a target physical page is still higher than a recovery standard after the limited number of recovery attempts, it indicates that the activity of the target physical page is very high, and the target process is a higher-value physical page, and the system does not recover the target physical page, so that a more reasonable balance is obtained between a process running effect and sufficient memory resources.
Furthermore, the ACTIVE physical pages of the target process which need to perform recovery attempt include the physical pages (namely, the anonymous pages in the ACTIVE state) of the target process in the ACTIVE _ ANON linked list and the corresponding physical pages (namely, the file pages in the ACTIVE state) in the ACTIVE _ FI L E linked list.
The difficulty of recovering the anonymous page in the active state is increased by adopting various methods, for example, the repentance duration of the anonymous page can be increased, for example, the optional value of the liveness can be reduced, or the reduction range of the liveness can also be increased. Here, we illustrate a third way, if the embodiment corresponding to fig. 3 is used for recovering anonymous pages, please refer to fig. 4, which provides a method for recovering file pages, including:
401. setting selectable values of the physical page liveness, wherein the selectable values comprise a first value, a second value, a third value and a fourth value;
optional values for setting physical page liveness may include, for example, a first value, a second value, a third value, and a fourth value, where the first value is not higher than the reclamation criteria, the second value is lower than the third value and higher than the reclamation criteria, and the third value is lower than the fourth value. Alternatively, it can be said that each selectable value represents the number of levels of activity of a physical page, and the higher the value, the higher the number of levels of activity.
By way of example, the activity level of a physical page may be evaluated by setting a flag bit, assuming that two flag bits are set, and the selectable values of each flag bit are 0 and 1, and the value of the activity may be represented by (a first flag bit value, a second flag bit value), then the selectable values of the activity include (0, 0), (0, 1), (1, 0) and (1, 1), and the comparison criterion (0, 0) is preset such that (0, 0) is lower than (1, 0) is lower than (0, 1) is lower than (1, 1), that is, (0, 0), (1, 0), (0, 1) is raised stepwise.
402. Acquiring a target physical page corresponding to a target process;
403. reading the value of the activity of the target physical page;
step 402 and step 403 are the same as step 101 and step 102 in the embodiment corresponding to fig. 1, respectively, and are not described again here.
404. Judging whether the value of the activity of the target physical page is higher than a recovery standard, if so, executing a step 405, and if not, executing a step 407;
after reading the value of the activity of the target physical page, it may be determined whether the value of the activity of the target physical page is higher than a recycling criterion, and a physical page with the activity higher than the recycling criterion is in an active state, if so, step 405 is executed, and if not, step 407 is executed.
405. If the type of the target physical page is a file page, reducing the activity of the target physical page according to a second amplitude;
after the target physical page corresponding to the target process is obtained, before the activity of the target physical page is reduced, the reduction amplitude of the activity can be set according to the type of the target physical page. When the target physical page is an anonymous page, reducing the activity of the target physical page according to a first amplitude; when the target physical page is a file page, the liveness of the target physical page is reduced by a second amplitude, and the first amplitude is lower than the second amplitude. In the embodiment corresponding to fig. 3, the first amplitude is reduced by one step, and may be used as a recovery process when the target physical page is an anonymous page, which is not described herein again. Since the first amplitude is lower than the second amplitude, the second amplitude can be lowered two steps at a time in the present invention.
406. Starting a timer;
a preset duration may be set as the repentance duration, and please refer to the embodiment corresponding to fig. 2 for setting the preset duration, which is not described in detail in the embodiment of the present invention.
And when the time length recorded by the timer reaches the preset time length, repeatedly executing the steps 403 to 404. The process may be repeated only once, that is, if the value of the activity level of the target physical page is still determined to be higher than the eviction criterion when step 404 is repeatedly executed for the first time, step 405 is not executed again, and the eviction process for the target physical page is directly exited, that is, only one eviction attempt is performed on the physical page in the active state. In order to improve the reclamation efficiency and release more memory, it is preferable that two or more reclamation attempts are performed on the physical page in the active state, that is, the steps 403 to 404 may be repeatedly performed two or more times.
The number of times of repetition can be preset, and the actual scene test result shows that the recovery efficiency of the previous recovery attempt is higher, and the recovery efficiency of the fourth and later recovery attempts is very low, so the number of times of repetition can be set to three. In addition, the repetition times can also be set according to the memory occupancy rate, and the higher the memory occupancy rate is, the more the recovery times are. Alternatively, in practical use, the number of repetitions may be set according to other considerations, and is not limited herein.
407. And recycling the target physical page.
And if the value of the activity of the target physical page is not higher than the recovery standard, recovering the target physical page.
The following method provided according to the embodiment corresponding to fig. 4 is exemplified by different cases of the value of the first read activity, assuming that the maximum number of repeated executions of steps 403 to 404 is set to 3:
if during a reclamation attempt, the target physical page is not accessed and the value of its liveness is not increased, then:
if the value of the activity of the target physical page is read for the first time to be the fourth value, after the step 405 is executed, the value of the activity of the target physical page is set to be the second value, then the steps 403 to 404 are repeatedly executed for the first time, because the value of the activity is still higher than the recovery standard, the value of the activity is continuously reduced by two steps, because the lowest step is the first value, the value is set to be the first value, then the steps 403 to 404 are repeatedly executed for the second time, and because the value of the activity is not higher than the recovery standard, the target physical page is recovered. If the value of the activity of the first read target physical page is the fourth value, the physical page needs to be recycled by repeating the steps 403 to 404 at least twice.
If the value of the activity of the target physical page is read for the first time to be the third value, after step 405 is executed, the value of the activity of the target physical page is set to be the first value, and then steps 403 to 404 are repeatedly executed for the first time, and the target physical page is recycled because the value of the activity is not higher than the recycling standard. If the value of the activity of the first read target physical page is the third value, the physical page needs to be recycled by repeating the steps 403 to 404 at least once.
If the value of the activity of the target physical page is read for the first time to be the second value, after step 405 is executed, the value of the activity of the target physical page is set to be the first value, and then steps 403 to 404 are repeatedly executed for the first time, and the target physical page is recycled because the value of the activity is not higher than the recycling standard. If the value of the activity of the first read target physical page is the second value, the physical page needs to be recycled by repeating the steps 303 to 304 at least once.
If the value of the activity of the target physical page is read for the first time and is the first value, the target physical page is recycled because the value of the activity is not higher than the recycling standard. If the value of the activity of the first read target physical page is the first value, the physical page can be recycled without repeatedly performing steps 403 to 404.
Therefore, before the recovery step of the present invention is executed, the physical page with higher activity value is less likely to be recovered, that is, the present invention can preferentially recover the physical page with lower activity, and realize the fine classification and recovery of the physical page in the active state.
Compared with the embodiment corresponding to fig. 3, the embodiment of the present invention is favorable for reducing the number of times of repeatedly executing steps 403 to 404 by increasing the reduction range of the value of the activity, and improves the recovery efficiency of the active file page.
Second, assuming that the target physical page is accessed during the eviction attempt, the value of its activity increases, and the system needs more eviction attempts to evict the target physical page than in the first case. In practical application, a system usually performs a limited number of recovery attempts on a physical page, and if the value of the activity of a target physical page is still higher than a recovery standard after the limited number of recovery attempts, it indicates that the activity of the target physical page is very high, and the target process is a higher-value physical page, and the system does not recover the target physical page, so that a more reasonable balance is obtained between a process running effect and sufficient memory resources.
The recovery of the anonymous page and the file page of the target process in the active state can be respectively realized by the embodiment method corresponding to fig. 3 and the embodiment method corresponding to fig. 4, as shown in table 1 below, for performing an actual scenario test of page recovery according to the embodiment method corresponding to fig. 3 and the embodiment method corresponding to fig. 4. It can be understood that the test data in table 1 is only the result of one test, and when the test is performed again, the test data changes due to different terminals used, different use conditions of the application programs, and the like, so the data in table 1 is only used for qualitatively explaining the recovery effect of the present invention on each application, and is not used for quantitatively limiting the recovery efficiency of the present invention on each application.
TABLE 1
Figure BDA0001332283370000181
The method comprises the steps of taking bean, QQ, WeChat, today's headline, a QQ browser, a mobile phone manager, an application center, a Xinlang microblog and other applications as target applications, namely test objects, taking a process in the target applications as a target process, and performing page recovery on the target process to achieve memory recovery of the target applications. Taking bean cotyledon as an example, in the testing process, firstly, the step 303 to the step 304 are executed once on an anonymous page of a target process of the bean cotyledon, or the step 403 to the step 404 are executed once on a document page of the bean cotyledon, which is referred to as first recovery of the bean cotyledon for short, and according to the memory size occupied by the bean cotyledon before recovery testing and the memory size occupied by the bean cotyledon after first recovery, the first recovery rate of the bean cotyledon can be calculated and obtained and is 2.64%; then, performing step 303 to step 304 for the anonymous page of the target process of the bean cotyledon for the second time, or performing step 403 to step 404 for the file page of the bean cotyledon for the second time, which is referred to as performing second recovery on the bean cotyledon for short, and calculating a second recovery rate of the bean cotyledon, which is 8.27%, according to the memory size occupied by the bean cotyledon after the first recovery and the memory size occupied by the bean cotyledon after the second recovery; by analogy, the third recovery rate for the bean was 26.73%, the fourth recovery rate for the bean was 0.46%, and the fifth recovery rate for the bean was 0.08%.
Observing the recovery rates of different times of recovery of the same application in table 1, it can be seen that the recovery rates of the previous three times of recovery of each application are far greater than the recovery rates of the fourth time and the fifth time, and the recovery rates of the cumulative three times of recovery (calculated according to the size of the memory occupied by the application after the third time of recovery and the size of the memory occupied by the application before the recovery test) and the cumulative five times of recovery are not very different, which indicates that the recovery times are too many, the recovery efficiency is not high, and resources are wasted, so it is preferable to perform the limited number of page recovery on the application.
In addition, the existing process-specific recovery method only recovers the physical page in the inactive state, the recovery rate corresponds to the first recovery rate in table 1, and by comparing the first recovery rate of the same application with the recovery rate of three times of recovery performed cumulatively in table 1, it can be found that the latter is several times of the former, and the multiple is between 2 times and 17 times.
In summary, the present invention provides a method for performing memory recovery for a process, and can selectively recover a physical page in an active state, thereby greatly improving the efficiency of memory recovery.
The memory recovery method in the embodiment of the present invention is described above, and the memory recovery device in the embodiment of the present invention is described below.
Referring to fig. 5, an embodiment of the memory recycling device 5 according to the embodiment of the present invention includes:
an obtaining module 501, configured to obtain a target physical page corresponding to a target process;
a first reading module 502, configured to read a value of activity of the target physical page, where the activity of the target physical page is used to mark an activity level of the target physical page, and the value of activity of the target physical page is positively correlated to the activity level of the target physical page;
a reducing module 503, configured to reduce the activity of the target physical page when the value of the activity of the target physical page is higher than a reclamation criterion, where a physical page with an activity value higher than the reclamation criterion is in an active state;
a second reading module 504, configured to read a value of the activity level of the target physical page after the reducing module reduces the activity level of the target physical page;
a reclamation module 505 for reclaiming the target physical page when the value of the liveness of the target physical page is not higher than the reclamation criterion.
Referring to fig. 6, another embodiment of the memory recycling device 6 according to the embodiment of the present invention includes:
an obtaining module 601, configured to obtain a target physical page corresponding to a target process;
a first reading module 602, configured to read a value of activity of the target physical page, where the activity of the target physical page is used to mark an activity level of the target physical page, and the value of activity of the target physical page is positively correlated to the activity level of the target physical page;
a reducing module 603, configured to reduce the activity of the target physical page when the value of the activity of the target physical page is higher than a reclamation criterion, and a physical page with an activity value higher than the reclamation criterion is in an active state;
a second setting module 604, configured to set a preset duration according to the priority of the target process before the timing module 605 starts the timer, where the preset duration is positively correlated with the priority of the target process;
a timing module 605, configured to start a timer after reducing the activity of the target physical page and before reading the value of the activity of the target physical page;
a second reading module 606, configured to read a value of the activity of the target physical page after the reducing module reduces the activity of the target physical page;
a reclaiming module 607 for reclaiming the target physical page when the value of the activity of the target physical page is not higher than the reclaiming criterion.
Preferably, the reducing module 603 includes:
a setting unit 6031 configured to set the activity of the target physical page to a second value when the activity of the target physical page is a third value; and when the activity of the target physical page is a second value, setting the activity of the target physical page to be a first value.
Preferably, the reducing module 603 further includes:
a reducing unit 6032 configured to reduce, when the target physical page is an anonymous page, the activity of the target physical page by a first amplitude; when the target physical page is a file page, reducing the activity of the target physical page according to a second amplitude; the first amplitude is lower than the second amplitude.
In actual use, the second setting module may not be adopted, but a first setting module is adopted, and the first setting module is used for setting the preset duration according to the memory occupancy rate before the timing module starts the timer, wherein the preset duration is negatively related to the memory occupancy rate.
Fig. 7 shows only a portion related to the embodiment of the present invention for convenience of description, and please refer to the method portion of the embodiment of the present invention for reference, though specific technical details are not disclosed. The computer device 7 may be any terminal device including a mobile phone, a tablet computer, a Personal Digital Assistant (PDA).
Referring to fig. 7, the computer device 7 includes: a power supply 710, a memory 720, a processor 730, and a computer program stored in the memory and executable on the processor. The processor, when executing the computer program, implements the steps in the various information processing method embodiments described above, such as steps 101 to 105 shown in fig. 1. Alternatively, the processor implements the functions of the modules or units in the above device embodiments when executing the computer program.
Illustratively, the computer program may be partitioned into one or more modules/units that are stored in the memory and executed by the processor to implement the invention. The one or more modules/units may be a series of computer program instruction segments capable of performing specific functions, which are used to describe the execution of the computer program in the computer apparatus.
Those skilled in the art will appreciate that the architecture shown in fig. 7 does not constitute a limitation of the computer apparatus 7, and may include more or fewer components than those shown, or some components may be combined, or a different arrangement of components, e.g., the computer apparatus may also include input-output devices, network access devices, buses, etc.
The Processor may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), an off-the-shelf Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic, discrete hardware components, etc. The general purpose processor may be a microprocessor or the processor may be any conventional processor or the like which is the control center for the computer device and which connects the various parts of the overall computer device using various interfaces and lines.
The memory may be used to store the computer programs and/or modules, and the processor may implement various functions of the computer device by running or executing the computer programs and/or modules stored in the memory and invoking data stored in the memory. The memory may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required by at least one function (such as a sound playing function, an image playing function, etc.), and the like; the storage data area may store data (such as audio data, a phonebook, etc.) created according to the use of the cellular phone, and the like. In addition, the memory may include high speed random access memory, and may also include non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), at least one magnetic disk storage device, a Flash memory device, or other volatile solid state storage device.
The modules/units integrated by the computer device may be stored in a computer-readable storage medium if they are implemented in the form of software functional units and sold or used as separate products. Based on such understanding, all or part of the flow of the method according to the embodiments of the present invention may also be implemented by a computer program, which may be stored in a computer-readable storage medium, and when the computer program is executed by a processor, the steps of the method embodiments may be implemented. Wherein the computer program comprises computer program code, which may be in the form of source code, object code, an executable file or some intermediate form, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, usb disk, removable hard disk, magnetic disk, optical disk, computer Memory, Read-Only Memory (ROM), Random Access Memory (RAM), electrical carrier wave signals, telecommunications signals, software distribution medium, and the like. It should be noted that the computer readable medium may contain content that is subject to appropriate increase or decrease as required by legislation and patent practice in jurisdictions, for example, in some jurisdictions, computer readable media does not include electrical carrier signals and telecommunications signals as is required by legislation and patent practice.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described systems, apparatuses and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the several embodiments provided in the present application, it should be understood that the disclosed system, apparatus and method may be implemented in other manners. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the units is only one logical division, and other divisions may be realized in practice, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
The above-mentioned embodiments are only used for illustrating the technical solutions of the present invention, and not for limiting the same; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.

Claims (14)

1. A memory reclamation method, comprising:
acquiring a target physical page corresponding to a target process;
reading the value of the activity of the target physical page, wherein the activity of the target physical page is used for marking the activity degree of the target physical page, and the value of the activity of the target physical page is positively correlated with the activity degree of the target physical page;
if the value of the activity degree of the target physical page is higher than a recovery standard, and the physical page with the activity degree value higher than the recovery standard is in an active state, reducing the activity degree of the target physical page;
reading the value of the activity of the target physical page;
and if the value of the activity of the target physical page is not higher than the recovery standard, recovering the target physical page.
2. The method of claim 1, wherein after reducing the liveness of the target physical page, prior to reading the value of the liveness of the target physical page, the method further comprises:
starting a timer;
and triggering the step of reading the value of the activity degree of the target physical page when the time length recorded by the timer reaches a preset time length.
3. The method of claim 2, wherein before starting the timer, the method further comprises:
setting a preset time length according to the memory occupancy rate, wherein the preset time length is negatively related to the memory occupancy rate;
or,
and setting a preset time length according to the priority of the target process, wherein the preset time length is positively correlated with the priority of the target process.
4. The method according to any one of claims 1 to 3, wherein the selectable values of the activity comprise at least a first value, a second value and a third value, the first value being not higher than the reclamation criterion, the second value being lower than the third value and higher than the reclamation criterion.
5. The method of claim 4, wherein reducing the liveness of the target physical page comprises:
when the activity of the target physical page is a third value, setting the activity of the target physical page to be a second value;
and when the activity of the target physical page is a second value, setting the activity of the target physical page to be a first value.
6. The method of claim 5, wherein reducing the liveness of the target physical page comprises:
when the target physical page is an anonymous page, reducing the activity of the target physical page according to a first amplitude;
when the target physical page is a file page, reducing the activity of the target physical page according to a second amplitude;
the first amplitude is lower than the second amplitude.
7. A memory recycling device, comprising:
the acquisition module is used for acquiring a target physical page corresponding to a target process;
a first reading module, configured to read a value of activity of the target physical page, where the activity of the target physical page is used to mark an activity level of the target physical page, and the value of activity of the target physical page is positively correlated to the activity level of the target physical page;
the reducing module is used for reducing the activity of the target physical page when the value of the activity of the target physical page is higher than the recycling standard, and the physical page with the activity value higher than the recycling standard is in an active state;
a second reading module, configured to read a value of the activity of the target physical page after the reducing module reduces the activity of the target physical page;
a recycle module for recycling the target physical page when the value of the liveness of the target physical page is not higher than the recycle standard.
8. The memory reclamation apparatus as recited in claim 7, wherein the memory reclamation apparatus further comprises:
the timing module is used for starting a timer after reducing the activity of the target physical page and before reading the value of the activity of the target physical page;
and the triggering module is used for triggering the step of reading the value of the activity degree of the target physical page when the time length recorded by the timer reaches a preset time length.
9. The memory reclamation apparatus as recited in claim 8, wherein the memory reclamation apparatus further comprises:
the first setting module is used for setting preset time according to the memory occupancy rate before the timing module starts the timer, and the preset time is negatively related to the memory occupancy rate;
or,
and the second setting module is used for setting preset time according to the priority of the target process before the timing module starts the timer, and the preset time is positively correlated with the priority of the target process.
10. The memory reclamation apparatus as recited in any one of claims 7 to 9, wherein the selectable values of the activity comprise at least a first value, a second value and a third value, the first value being no higher than the reclamation criterion, the second value being lower than the third value and higher than the reclamation criterion.
11. The memory reclamation apparatus of claim 10, wherein the reduction module comprises:
the setting unit is used for setting the activity of the target physical page to be a second value when the activity of the target physical page is a third value; and when the activity of the target physical page is a second value, setting the activity of the target physical page to be a first value.
12. The memory reclamation apparatus of claim 11, wherein the reduction module comprises:
a reducing unit, configured to reduce, when the target physical page is an anonymous page, an activity of the target physical page by a first amplitude; when the target physical page is a file page, reducing the activity of the target physical page according to a second amplitude; the first amplitude is lower than the second amplitude.
13. A computer arrangement, characterized in that the computer arrangement comprises a processor for implementing the steps of the method according to any one of claims 1-6 when executing a computer program stored in a memory.
14. A computer-readable storage medium having stored thereon a computer program, characterized in that: the computer program realizing the steps of the method according to any one of claims 1-6 when executed by a processor.
CN201710494549.4A 2017-06-26 2017-06-26 Memory recovery method and device, computer device and computer readable storage medium Active CN108205501B (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN201710494549.4A CN108205501B (en) 2017-06-26 2017-06-26 Memory recovery method and device, computer device and computer readable storage medium
PCT/CN2017/101009 WO2019000644A1 (en) 2017-06-26 2017-09-08 Memory reclamation method and apparatus, computer apparatus and computer-readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710494549.4A CN108205501B (en) 2017-06-26 2017-06-26 Memory recovery method and device, computer device and computer readable storage medium

Publications (2)

Publication Number Publication Date
CN108205501A CN108205501A (en) 2018-06-26
CN108205501B true CN108205501B (en) 2020-08-07

Family

ID=62603222

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710494549.4A Active CN108205501B (en) 2017-06-26 2017-06-26 Memory recovery method and device, computer device and computer readable storage medium

Country Status (2)

Country Link
CN (1) CN108205501B (en)
WO (1) WO2019000644A1 (en)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US11879973B2 (en) 2018-12-18 2024-01-23 Insightec, Ltd. Echo-based focusing correction
CN115757193B (en) 2019-11-15 2023-11-03 荣耀终端有限公司 Memory management method and electronic equipment
CN112988610B (en) * 2019-12-16 2024-12-27 深圳市万普拉斯科技有限公司 Memory recycling processing method, device, computer equipment and storage medium
WO2021123905A2 (en) 2019-12-18 2021-06-24 Insightec, Ltd Systems and methods for providing tissue information in an anatomic target region using acoustic reflectors
CN114443277A (en) * 2020-10-31 2022-05-06 华为终端有限公司 Memory management method and device, electronic equipment and computer readable storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101833512A (en) * 2010-04-22 2010-09-15 中兴通讯股份有限公司 Method and device thereof for reclaiming memory
CN103593298A (en) * 2013-10-16 2014-02-19 北京航空航天大学 Memory recovery method and device
CN105159777A (en) * 2015-08-03 2015-12-16 中科创达软件股份有限公司 Process memory collection method and apparatus
CN105760228A (en) * 2016-01-29 2016-07-13 珠海汇迪科技有限公司 Method for improving game fluency under low-memory Android device

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7925925B2 (en) * 2008-12-30 2011-04-12 Intel Corporation Delta checkpoints for a non-volatile memory indirection table
CN102521162B (en) * 2011-11-30 2014-12-31 华为技术有限公司 Method and device for cache data processing
CN103092689A (en) * 2013-01-10 2013-05-08 深圳市金立通信设备有限公司 Method and terminal of process management
CN103150259B (en) * 2013-03-22 2016-03-30 华为技术有限公司 A kind of method for recovering internal storage and device
CN106339324B (en) * 2016-08-19 2019-05-10 浪潮(北京)电子信息产业有限公司 A method and apparatus for selecting garbage collection blocks

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101833512A (en) * 2010-04-22 2010-09-15 中兴通讯股份有限公司 Method and device thereof for reclaiming memory
CN103593298A (en) * 2013-10-16 2014-02-19 北京航空航天大学 Memory recovery method and device
CN105159777A (en) * 2015-08-03 2015-12-16 中科创达软件股份有限公司 Process memory collection method and apparatus
CN105760228A (en) * 2016-01-29 2016-07-13 珠海汇迪科技有限公司 Method for improving game fluency under low-memory Android device

Also Published As

Publication number Publication date
WO2019000644A1 (en) 2019-01-03
CN108205501A (en) 2018-06-26

Similar Documents

Publication Publication Date Title
CN108205473B (en) Memory processing method and device, computer device and computer-readable storage medium
CN108228341B (en) Memory recovery method and device, terminal equipment and computer readable storage medium
CN108205501B (en) Memory recovery method and device, computer device and computer readable storage medium
CN108205498B (en) Memory recovery method and device, computer device and computer readable storage medium
CN108205471B (en) Memory recovery method and device, computer device and computer readable storage medium
CN108228449B (en) Terminal device control method and device, terminal device and computer readable storage medium
US10810127B2 (en) Solid-state hard disk and data access method for use with solid-state hard disk
CN108228339B (en) Memory recovery method and device, terminal equipment and computer readable storage medium
CN109656486B (en) Configuration method of solid state disk, data storage method, solid state disk and storage controller
CN106406753B (en) A kind of date storage method and data storage device
US10437519B2 (en) Method and mobile terminal for processing write request
CN111324303B (en) SSD garbage recycling method, SSD garbage recycling device, computer equipment and storage medium
CN108287760B (en) Terminal device control method and device, terminal device and computer readable storage medium
CN107665098A (en) Information processing method, storage device and computer-readable storage medium
CN111930301A (en) Garbage recycling optimization method and device, storage medium and electronic equipment
CN110727605B (en) Memory recovery method and device and electronic equipment
CN110727607A (en) Memory recovery method and device and electronic equipment
CN108228340B (en) Terminal control method and device, terminal equipment and computer readable storage medium
CN108845770A (en) Reduce method, apparatus and computer equipment that SSD writes amplification
CN108228342B (en) Terminal device control method and device, terminal device and computer readable storage medium
CN108287761B (en) Memory recovery method and device, terminal equipment and computer readable storage medium
CN112199042B (en) Storage space management method, device, chip, equipment and storage medium
US20120191938A1 (en) Information processing apparatus and write control method
CN111782559A (en) Page management method and device and computer readable storage medium
CN111597127B (en) Method, device, computer equipment and storage medium for hybrid SLC cache

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
TR01 Transfer of patent right

Effective date of registration: 20240708

Address after: 430000, 14th floor, No. 181 Chunxiao Road, Wuhan Economic and Technological Development Zone, Hubei Province

Patentee after: Wuhan Xingji Meizu Technology Co.,Ltd.

Country or region after: China

Address before: 519000 technology innovation coastal Meizu science and technology building, Zhuhai, Guangdong

Patentee before: MEIZU TECHNOLOGY Co.,Ltd.

Country or region before: China

TR01 Transfer of patent right