CN108205471B - 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 PDFInfo
- Publication number
- CN108205471B CN108205471B CN201710647577.5A CN201710647577A CN108205471B CN 108205471 B CN108205471 B CN 108205471B CN 201710647577 A CN201710647577 A CN 201710647577A CN 108205471 B CN108205471 B CN 108205471B
- Authority
- CN
- China
- Prior art keywords
- physical page
- target
- activity
- target application
- recovery
- 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
Links
- 238000011084 recovery Methods 0.000 title claims abstract description 207
- 230000015654 memory Effects 0.000 title claims abstract description 173
- 238000000034 method Methods 0.000 title claims abstract description 170
- 230000000694 effects Effects 0.000 claims abstract description 256
- 238000004064 recycling Methods 0.000 claims abstract description 125
- 230000000875 corresponding effect Effects 0.000 claims abstract description 73
- 230000002596 correlated effect Effects 0.000 claims abstract description 14
- 238000006073 displacement reaction Methods 0.000 claims description 24
- 238000004590 computer program Methods 0.000 claims description 18
- 230000008859 change Effects 0.000 claims description 11
- 230000003247 decreasing effect Effects 0.000 claims description 6
- 230000008569 process Effects 0.000 abstract description 94
- 230000002829 reductive effect Effects 0.000 description 21
- 235000010627 Phaseolus vulgaris Nutrition 0.000 description 17
- 244000046052 Phaseolus vulgaris Species 0.000 description 17
- 238000010586 diagram Methods 0.000 description 15
- 238000012360 testing method Methods 0.000 description 13
- JHIVVAPYMSGYDF-UHFFFAOYSA-N cyclohexanone Chemical compound O=C1CCCCC1 JHIVVAPYMSGYDF-UHFFFAOYSA-N 0.000 description 9
- 230000006870 function Effects 0.000 description 8
- 230000002147 killing effect Effects 0.000 description 5
- 230000008878 coupling Effects 0.000 description 3
- 238000010168 coupling process Methods 0.000 description 3
- 238000005859 coupling reaction Methods 0.000 description 3
- 238000013507 mapping Methods 0.000 description 3
- 230000007246 mechanism Effects 0.000 description 3
- 230000009467 reduction Effects 0.000 description 3
- 230000009286 beneficial effect Effects 0.000 description 2
- 238000004891 communication Methods 0.000 description 2
- 230000001186 cumulative effect Effects 0.000 description 2
- 230000000670 limiting effect Effects 0.000 description 2
- 230000003287 optical effect Effects 0.000 description 2
- 238000012545 processing Methods 0.000 description 2
- 230000001413 cellular effect Effects 0.000 description 1
- 238000013500 data storage Methods 0.000 description 1
- 238000011156 evaluation Methods 0.000 description 1
- 230000002349 favourable effect Effects 0.000 description 1
- 230000010365 information processing Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000036961 partial effect Effects 0.000 description 1
- 238000005192 partition Methods 0.000 description 1
- 238000003672 processing method Methods 0.000 description 1
- 230000002035 prolonged effect Effects 0.000 description 1
- 239000007787 solid Substances 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
- 230000001360 synchronised effect Effects 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements 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/46—Multiprogramming arrangements
- G06F9/50—Allocation of resources, e.g. of the central processing unit [CPU]
- G06F9/5005—Allocation of resources, e.g. of the central processing unit [CPU] to service a request
- G06F9/5011—Allocation 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/5022—Mechanisms to release resources
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements 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/46—Multiprogramming arrangements
- G06F9/50—Allocation of resources, e.g. of the central processing unit [CPU]
- G06F9/5005—Allocation of resources, e.g. of the central processing unit [CPU] to service a request
- G06F9/5011—Allocation 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/5016—Allocation 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
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Memory System Of A Hierarchy Structure (AREA)
- Electrically Operated Instructional Devices (AREA)
- Management, Administration, Business Operations System, And Electronic Commerce (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 is used for reducing the waiting time of a user in the process of transferring an application running in a background to a foreground. The method provided by the embodiment of the invention comprises the following steps: acquiring a target physical page corresponding to a target application; performing a target number of eviction attempts on a target physical page, wherein performing one eviction attempt on the target physical page comprises: judging whether the activity of the target physical page is higher than a recovery standard or not, 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 so, reducing the activity of the target physical page; and if not, recycling the target physical page.
Description
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 program 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 often frequently switches different application programs to the foreground, for example, in the process of watching a video by using video playing software, the chat application may need to be frequently switched to the foreground, and in order to reduce the waiting time of the user, the operating system usually reserves the memory occupied by the application program that is transferred 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 applications running in the background to reclaim the memory it occupies.
However, when the user needs to use the application programs in the foreground, the application programs need to be completely reloaded, the waiting time of the user is long, and the user experience is reduced.
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 that in the prior art, after the application running in a background is recovered and switched to the operation in a foreground, the application needs to be completely reloaded, so that the waiting time of a user is too long.
An aspect of the embodiments of the present invention provides a memory recovery method, including:
acquiring a target physical page corresponding to a target application;
performing a target number of eviction attempts on the target physical page, one of the eviction attempts on the target physical page comprising:
judging whether the activity of the target physical page is higher than a recovery standard or not, wherein the activity of the target physical page is used for marking the activity degree of the target physical page, and the activity degree value of the target physical page is positively correlated with the activity degree of the target physical page;
if so, reducing the activity of the target physical page;
and if not, recycling the target physical page.
With reference to the first aspect, in a first possible implementation manner of the first aspect, before the target application is an application running in a background and performing the target number of recovery attempts on the target physical page, the method further includes:
judging whether the target application is a heavy recycling object or not according to the working state of the target application;
if yes, setting the target times as a first integer;
if not, setting the target times as a second integer, wherein the first integer is larger than the second integer, and the second integer is larger than or equal to zero.
With reference to the first possible implementation manner of the first aspect, in a second possible implementation manner of the first aspect, the determining, according to the working state of the target application, whether the target application is a heavy recycling object includes:
judging whether the target application calls an audio playing component or not;
if not, the target application is judged not to be a heavy recycling object.
With reference to the second possible implementation manner of the first aspect, in a third possible implementation manner of the first aspect, if it is determined that the target application is invoking an audio playing component, the method further includes:
judging whether the calling time of the target application to the audio playing component exceeds a time threshold;
and if so, judging that the target application is a heavy recycling object.
With reference to the first possible implementation manner of the first aspect, in a fourth possible implementation manner of the first aspect, the determining, according to the working state of the target application, whether the target application is a heavy recycling object includes:
judging whether the target application is calling a navigation positioning component;
if not, the target application is judged not to be a heavy recycling object.
With reference to the fourth possible implementation manner of the first aspect, in a fifth possible implementation manner of the first aspect, if it is determined that the target application is invoking a navigation positioning component, the method further includes:
judging whether the displacement corresponding to the position change recorded by the navigation positioning component exceeds a displacement threshold value or not during the calling period of the navigation positioning component by the target application;
and if so, judging that the target application is a heavy recycling object.
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 application;
the recovery module is used for performing recovery attempt on the target physical page for the target times;
the eviction module includes an eviction unit to perform the eviction attempt on the target physical page once.
The recovery unit includes:
a judging subunit, configured to judge whether the activity level of the target physical page is higher than a recycling standard, where the activity level of the target physical page is used to mark an activity level of the target physical page, and a value of the activity level of the target physical page is positively correlated to the activity level of the target physical page;
a decreasing subunit operable to decrease the activity level of the target physical page when the judging subunit judges that the activity level of the target physical page is higher than the reclamation standard;
a recovery subunit operable to recover the target physical page when the judgment subunit judges that the liveness of the target physical page is not higher than a recovery standard.
With reference to the second aspect, in a first possible implementation manner of the second aspect, the target application is an application running in a background, and the memory recovery apparatus further includes:
the judging module is used for judging whether the target application is a heavy recycling object or not according to the working state of the target application;
the first setting module is used for setting the target times as a first integer when the judging module judges that the target application is a heavy recycling object;
and the second setting module is used for setting the target times as a second integer when the judging module judges that the target application is not a heavy recycling object, wherein the first integer is greater than the second integer, and the second integer is greater than or equal to zero.
With reference to the first possible implementation manner of the second aspect, in a second possible implementation manner of the second aspect, the determining module includes:
the first judgment unit is used for judging whether the target application calls an audio playing component or not;
a first determination unit configured to determine that the target application is not a heavy recycling object when the first determination unit determines that the target application is not calling the audio playing component.
With reference to the second possible implementation manner of the second aspect, in a third possible implementation manner of the second aspect, the determining module further includes:
the second judging unit is used for judging whether the calling time length of the target application to the audio playing component exceeds a time length threshold value or not when the first judging unit judges that the target application is calling the audio playing component;
and the second judging unit is used for judging that the target application is a heavy recycling object when the second judging unit judges that the calling duration of the target application to the audio playing component exceeds a duration threshold.
With reference to the first possible implementation manner of the second aspect, in a fourth possible implementation manner of the second aspect, the determining module includes:
the third judging unit is used for judging whether the target application calls a navigation positioning component or not;
a third determination unit, configured to determine that the target application is not a heavy recycling object when the third determination unit determines that the target application is not calling a navigation positioning component.
With reference to the fourth possible implementation manner of the second aspect, in a fifth possible implementation manner of the second aspect, the determining module further includes:
the fourth judging unit is used for judging whether the displacement corresponding to the position change recorded by the navigation positioning component exceeds a displacement threshold value or not during the calling period of the target application to the navigation positioning component;
and the fourth judging unit is used for judging that the target application is a heavy recycling object when the fourth judging unit judges that the displacement corresponding to the position change recorded by the navigation positioning component exceeds a displacement threshold value during the calling period of the target application to the navigation positioning component.
A third aspect of embodiments of the present invention provides a computer apparatus, including a processor, configured to implement the first aspect or 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 the first aspect or any one of the possible implementations of the first aspect.
According to the technical scheme, the embodiment of the invention has the following advantages:
the method can acquire the target physical page corresponding to the target application and perform recovery attempt of the target times on the target physical page, wherein the recovery attempt of the target physical page for one time comprises the following steps: compared with the prior art, the method and the device only recover the physical page with lower liveness of the target application, and maintain the running state of the target application in the background while releasing part of the memory of the target application, so that when the user needs to use the target application in the foreground, the target application does not need to be completely reloaded, the waiting time of the user is reduced, and the user experience is improved.
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 illustrating an embodiment of a method for performing a eviction attempt on a target physical page according to the 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 diagram illustrating another embodiment of a memory reclamation method according to the present invention;
FIG. 6 is a schematic diagram of an embodiment of a memory recycling device according to the present invention;
FIG. 7 is a schematic diagram of another embodiment of a memory recycling device according to the present invention;
FIG. 8 is a schematic diagram of another embodiment of a memory recycling device according to the present invention;
FIG. 9 is a diagram illustrating another embodiment of a memory reclamation method of the present invention;
FIG. 10 is a diagram illustrating another embodiment of a memory reclamation method of the present invention;
FIG. 11 is a diagram illustrating another embodiment of a memory reclamation method of the present invention;
FIG. 12 is a diagram illustrating another embodiment of a memory reclamation method of the present invention;
FIG. 13 is a schematic diagram of another embodiment of a memory recovery apparatus according to the present invention;
FIG. 14 is a schematic diagram of another embodiment of a memory recovery apparatus according to the present invention;
FIG. 15 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 reducing the waiting time of a user in the process of transferring an application running in a background to a foreground.
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. In the prior art, the memory occupied by the application is released by killing part of the application running in the background, but when the user needs to use the application killed by the system in the foreground, the application needs to be completely reloaded, so that the waiting time of the user is prolonged, and the user experience is reduced. In order to solve the above problem, the present invention provides a memory recycling method, referring to fig. 1, an embodiment of the memory recycling method of the present invention includes:
101. acquiring a target physical page corresponding to a target application;
first, the object of memory reclamation, i.e., the application, needs to be selected. For example, for some important system applications, such as an intelligent center, a contact, a location, a battery, a network, and the like, in order to ensure the basic functions of the terminal, the invention may not select the important system applications as objects for memory recovery, and preferably, may select a third-party application as an object for memory recovery. For convenience of description, an application selected as a memory reclamation object is referred to as a target application.
Since the physical memory is usually divided into several parts, each part is recorded as one physical page, and one application program usually occupies a plurality of physical pages, in order to recycle the memory occupied by the application on the premise of not killing the application, the embodiment of the present invention recycles part of the physical pages occupied by the application. For this reason, after the target application is selected, the physical page occupied by the target application may be acquired, and for convenience of description, the physical page occupied by the target application is referred to as a target physical page.
102. A target number of eviction attempts is made to the target physical page.
After the target physical page is acquired, the target physical page may be subjected to a certain number of recovery attempts, and for convenience of description, the number of recovery attempts performed on the target physical page is referred to as a target number. The recovery attempt is different from forced recovery, and the recovery attempt refers to preferentially recovering a physical page with a lower value and releasing a corresponding memory so as to reduce the influence of memory recovery on a target application. Referring to fig. 2, in an embodiment of the present invention, a method for performing a recycle attempt on a target physical page may include:
201. judging whether the activity of the target physical page is higher than a recovery standard, if so, executing a step 202, otherwise, executing a step 203;
the high or low value of a physical page is usually evaluated by the high or low activity level of the physical page, and the higher the activity level of the physical page is, the higher the value of the physical page for storing data is, or the higher the value of the physical page is, the system generally considers that the physical page is. In order to compare the activity levels of the physical pages, the activity level of the target physical page can be marked by adopting the activity level of the target physical page, and the value of the activity level of the target physical page is positively correlated with the activity level of the target physical page. The optional value of the activity of the physical page used herein is usually not less than two, and the value of the activity may be a numerical value, and the value of the activity may be determined according to the magnitude of the numerical value, but the value of the activity is not limited to the numerical value, as long as the level of the different value can be determined according to a preset comparison standard, for example, a flag bit used for indicating the condition that the physical page is accessed, and the activity represented by the flag bit is increased when the physical page is accessed.
After the target physical page is acquired, the activity of the target physical page may be read, and whether the activity of the target physical page is higher than the recycling standard is determined, if so, step 202 is executed, and if not, step 203 is executed. It is understood that the liveness of a physical page includes at least one optional value that is above the reclamation criteria, and also includes at least one optional value that is not above the reclamation criteria.
Preferably, the reclamation criterion may be 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, that is, the physical page with the activity higher than the reclamation criterion is in the active state.
202. Reducing the activity of the target physical page;
if the liveness of the target physical page is judged to be higher than the recycling standard, the liveness of the target physical page can be reduced.
203. And recycling the target physical page.
And if the liveness of the target physical page is judged not to be higher than the recovery standard, the target physical page can be recovered.
Through steps 201 to 203, the physical page with a lower activity corresponding to the target application may be preferentially recycled, and the physical page with a higher activity corresponding to the target application is reserved, so as to reduce the influence of memory recycling on the target application.
With more and more applications installed on the terminal, a large number of applications are generally operated on the background of the terminal after the terminal is started, and a large amount of memory is occupied. In practical use, the memory recovery method provided by the embodiment of the present invention may be enabled to perform memory recovery when the available system memory is too low, or the memory recovery method provided by the embodiment of the present invention may be enabled to perform memory recovery every fixed time, or other memory recovery starting strategies are adopted, which is not specifically limited herein.
The embodiment of the invention can acquire the target physical page corresponding to the target application and carry out the recovery attempt of the target times on the target physical page, wherein the recovery attempt of the target physical page for one time comprises the following steps: compared with the prior art, the method and the device only recover the physical page with lower liveness of the target application, and maintain the running state of the target application while releasing part of the memory of the target application, so that even if the target application is an application running in a background, the target application does not need to be completely reloaded when a user needs to use the target application in the foreground, the waiting time of the user is reduced, and the user experience is improved. Moreover, by using the memory recovery method provided by the invention, the physical page of the application running in the foreground can be recovered and tried on the premise of not killing the application running in the foreground, partial memory occupied by the application running in the foreground is released, and the range of memory recovery objects is widened.
With more and more applications installed on the terminal, more and more applications are reserved for the user in the background by the system of the terminal, and a large amount of memory is occupied, so that a strategy for recovering the applications running in the background needs to be provided urgently. Although there may be many applications running in the background, different applications have different recycling values, for example, for an application with less memory, even if the application is subjected to multiple recycling attempts, the amount of released memory is still less, the effect on relieving the system memory pressure is not great, the operation burden of the system is increased, and the recycling value of the application is lower. The application with different recycling values can adopt different recycling strengths, and in the embodiment of the invention, the application with higher recycling value is mainly reflected in different recycling attempt times, the larger the recycling attempt times is, the lower the recycling value is, and the smaller the recycling attempt times is.
The recovery value of the evaluation application can adopt various dimensions, for example, because a large number of pages can be loaded during foreground operation of news information applications (such as newwave news), shopping applications (such as treasure making), life service applications (such as American takeaway) and the like, and a large amount of memory occupied by page data is usually not released during background operation of the pages, the recovery value of the applications during background operation can be judged to be high; or, in the background operation process of the application, data is continuously generated to occupy more memory, so that the recycling value of the application can be determined according to the background operation duration of the application, and the longer the background operation duration of the application is, the larger the memory occupied by the application may be, and the higher the recycling value of the application can be determined. However, in the background operation process, the expansion speed of the memory occupation is usually related to the working state of the application, and the expansion speed of the memory occupation in most working states of the application running in the background is low, so that even if the application runs in the background for a long time, the newly occupied memory does not increase a considerable amount, and the recovery value of the application is low. To this end, an embodiment of the present invention provides a method for recovering a memory, referring to fig. 3, another embodiment of the method for recovering a memory of the present invention includes:
301. acquiring a target physical page corresponding to a target application running in a background;
first, the object of memory reclamation, i.e., the application running in the background, needs to be selected. For example, some important system applications, such as an intelligent center, a contact, a location, a battery, a network, and the like, may also run in the background, so in order to ensure the basic functions of the terminal, the present invention may not select the important system applications as the objects of memory recovery, and preferably, a third party application running in the background may select the important system applications as the objects of memory recovery. For convenience of description, an application selected as a memory reclamation object is referred to as a target application.
Since the physical memory is usually divided into several parts, each part is recorded as one physical page, and one application program usually occupies a plurality of physical pages, in order to recycle the memory occupied by the application on the premise of not killing the application, the embodiment of the present invention recycles part of the physical pages occupied by the application. For this reason, after the target application is selected, the physical page occupied by the target application may be acquired, and for convenience of description, the physical page occupied by the target application is referred to as a target physical page.
302. Judging whether the target application is a heavy recycling object or not according to the working state of the target application;
after selecting the target application as the memory recycling object, the operating state of the target application may be detected, and whether the target application is a heavy recycling object is determined according to the operating state of the target application, if yes, step 303 is executed, and if no, step 304 is executed.
303. Setting the target times as a first integer;
if the target application is determined to be the heavy recycling object, the recycling attempt times of the target application are set to be a first integer, namely the target times are set to be the first integer.
304. Setting the target times as a second integer;
and if the target application is not the heavy recycling object, setting the recycling attempt times of the target application to a second integer, namely setting the target times to the second integer, wherein the first integer is larger than the second integer, and the second integer is larger than or equal to zero.
Steps 302 to 304 are processes for setting the target times, and in actual use, the process for setting the target times may be performed before step 301, or may be performed simultaneously with step 301, and the timing sequence between the two is not specifically limited.
305. A target number of eviction attempts is made to the target physical page.
After the target physical page is acquired and the target number of times is determined, the target physical page may be subjected to the target number of recovery attempts. Please refer to the embodiment shown in fig. 2, which is not described herein again.
It should be noted that, when the second integer is equal to zero, it means that no eviction attempt is performed on the target physical page. When the target number is greater than 1, for the physical page with the failure of the first recovery attempt, namely the physical page with the activity higher than the recovery standard, because the activity is reduced in the process of the first recovery attempt, if the physical page is not accessed before the second recovery attempt, the activity does not rise back, and if the selectable value of the activity only comprises two, the physical page is recovered in the second recovery attempt; if the selectable values of the activity level include three or more, and the activity level of the physical page is still higher than the recovery standard after the second recovery attempt, then the recovery attempt is likely to be performed more times. It can be seen that the more active a physical page, the lower the record of the physical page being evicted, the more times an eviction attempt is made, the greater the chance that the physical page is evicted.
Generally, when the application running in the background is in the following two working states, the expansion speed of the memory occupation is higher, and the recovery value of the application is higher: audio playing working state and navigation positioning working state.
First, heavily recovering background application in audio playing working state
Referring to fig. 4, another embodiment of the memory recycling method of the present invention includes:
401. acquiring a target physical page corresponding to a target application running in a background;
step 401 is the same as step 301 in the embodiment corresponding to fig. 3, and is not repeated here.
402. Judging whether the target application is calling an audio playing component, if not, executing a step 403, and if so, executing a step 404;
after selecting the target application as the memory recycling object, the operating state of the target application may be detected, and it is determined whether the target application is calling the audio playing component, if not, step 403 is executed, and if yes, step 404 is executed.
403. Judging that the target application is not a heavy recycling object, and setting the target times as a second integer;
if the target application is not calling the audio playing component, it may be determined that the target application is not a heavy recycling object, and the target number of times is set to a second integer, where the second integer is greater than or equal to zero.
404. Judging whether the calling time of the target application to the audio playing component exceeds a time threshold, if not, executing a step 403, and if so, executing a step 405;
if the target application is calling the audio playing component, it may be determined that the target application is a heavy recycling object, and the target number of times is set to a first integer, where the first integer is greater than a second integer. In the process of calling the audio playing component to play audio in the background by the application, a large number of audio files are loaded into the memory, a large amount of memory is occupied, and the recovery value is high, so that the background application calling the audio playing component can be selected as a heavy recovery object to perform multiple recovery attempts.
Because the size of the memory occupied by the audio file loaded into the memory is generally related to the audio playing time length, and the longer the playing time length is, the higher the recycling value is, preferably, if the target application is calling the audio playing component, it may be further determined whether the calling time length of the audio playing component by the target application exceeds the time length threshold, if so, step 405 is executed, and if not, step 403 is executed.
405. Judging that the target application is a heavy recycling object, and setting the target times as a first integer;
if the target application is determined to be the heavy recycling object, the recycling attempt times of the target application are set to be a first integer, namely the target times are set to be the first integer, wherein the first integer is larger than the second integer.
406. A target number of eviction attempts is made to the target physical page.
After the target physical page is acquired and the target number of times is determined, the target physical page may be subjected to the target number of recovery attempts. Please refer to the embodiment shown in fig. 2, which is not described herein again.
It should be noted that, when the second integer is equal to zero, it means that no eviction attempt is performed on the target physical page. When the target number is greater than 1, for the physical page with the failure of the first recovery attempt, namely the physical page with the activity higher than the recovery standard, because the activity is reduced in the process of the first recovery attempt, if the physical page is not accessed before the second recovery attempt, the activity does not rise back, and if the selectable value of the activity only comprises two, the physical page is recovered in the second recovery attempt; if the selectable values of the activity level include three or more, and the activity level of the physical page is still higher than the recovery standard after the second recovery attempt, then the recovery attempt is likely to be performed more times. It can be seen that the more active a physical page, the lower the record of the physical page being evicted, the more times an eviction attempt is made, the greater the chance that the physical page is evicted.
Secondly, carrying out heavy recovery on background application in a navigation and positioning working state
Referring to fig. 5, another embodiment of the memory recycling method of the present invention includes:
501. acquiring a target physical page corresponding to a target application running in a background;
step 501 is the same as step 301 in the embodiment corresponding to fig. 3, and is not described herein again.
502. Judging whether the target application is calling a navigation positioning component, if not, executing a step 503, and if so, executing a step 504;
after selecting the target application as the memory recycling object, the working state of the target application may be detected, and it is determined whether the target application is calling the navigation positioning component, if not, step 503 is executed, and if yes, step 504 is executed.
503. Judging that the target application is not a heavy recycling object, and setting the target times as a second integer;
if the target application is not calling the navigation positioning component, it can be determined that the target application is not a heavy recycling object, and the target number is set to a second integer, where the second integer is greater than or equal to zero.
504. Judging whether the displacement corresponding to the position change recorded by the navigation positioning component exceeds a displacement threshold value, if not, executing a step 503, and if so, executing a step 505;
because a large amount of image files are loaded into the memory in the process of calling the navigation positioning component to perform navigation positioning at the background, a large amount of memory is occupied, and the recovery value is high, the background application calling the navigation positioning component can be selected as a heavy recovery object to perform multiple recovery attempts. If the target application is calling the navigation positioning component, the target application can be judged to be a heavy recycling object, and the target times is set to be a first integer, wherein the first integer is larger than a second integer.
Because the size of the memory occupied by the map file loaded into the memory is generally related to the displacement of the terminal at which the position changes, and the larger the displacement is, the larger the loaded map file is, and the higher the recycling value is, therefore, preferably, if the target application is calling the navigation positioning component, it can be further determined whether the displacement corresponding to the position change recorded by the navigation positioning component during the calling period of the navigation positioning component by the target application exceeds the displacement threshold, if not, step 503 is executed, and if so, step 505 is executed.
505. Judging that the target application is a heavy recycling object, and setting the target times as a first integer;
if the target application is determined to be the heavy recycling object, the recycling attempt times of the target application are set to be a first integer, namely the target times are set to be the first integer, wherein the first integer is larger than the second integer.
506. A target number of eviction attempts is made to the target physical page.
After the target physical page is acquired and the target number of times is determined, the target physical page may be subjected to the target number of recovery attempts. Please refer to the embodiment shown in fig. 2, which is not described herein again.
It should be noted that, when the second integer is equal to zero, it means that no eviction attempt is performed on the target physical page. When the target number is greater than 1, for the physical page with the failure of the first recovery attempt, namely the physical page with the activity higher than the recovery standard, because the activity is reduced in the process of the first recovery attempt, if the physical page is not accessed before the second recovery attempt, the activity does not rise back, and if the selectable value of the activity only comprises two, the physical page is recovered in the second recovery attempt; if the selectable values of the activity level include three or more, and the activity level of the physical page is still higher than the recovery standard after the second recovery attempt, then the recovery attempt is likely to be performed more times. It can be seen that the more active a physical page, the lower the record of the physical page being evicted, the more times an eviction attempt is made, the greater the chance that the physical page is evicted.
In practical use, the target application in the audio playing operating state or the navigation positioning operating state may also be determined as a heavy recycling object, that is, the target application set belonging to the heavy recycling object may be a union of the target application set in the audio playing operating state and the target application set in the navigation positioning operating state.
In summary, the present invention provides a method for recovering a memory, and the embodiments corresponding to fig. 1 and fig. 2 can properly recover the memory occupied by the target application on the premise of not killing the target application, thereby reducing the waiting time required when the user switches the target application to the foreground operation, and improving the user experience. The embodiments corresponding to fig. 3 to fig. 5 can perform differentiated recovery attempts on target applications running in the background, perform more recovery attempts on target applications with high recovery value, and perform no or fewer recovery attempts on target applications with low recovery value, which is beneficial to improving recovery efficiency.
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. 6, an embodiment of the memory recycling device 6 according to the embodiment of the present invention includes:
an obtaining module 61, configured to obtain a target physical page corresponding to a target application;
a recycle module 62 for performing a target number of recycle attempts on the target physical page;
the recycle module 62 includes a recycle unit 621 for performing a recycle attempt on the target physical page.
The recovery unit 621 includes:
a judging subunit 6211, configured to judge whether the activity level of the target physical page is higher than the recovery standard, where the activity level of the target physical page is used to mark the activity level of the target physical page, and a value of the activity level of the target physical page is positively correlated with the activity level of the target physical page;
a reducing subunit 6212 configured to reduce the activity of the target physical page when the judging subunit 6211 judges that the activity of the target physical page is higher than the recycle standard;
a recycle sub-unit 6213 for recycling the target physical page when the judging sub-unit 6211 judges that the liveness of the target physical page is not higher than the recycle standard.
Referring to fig. 7, another embodiment of the memory recycling device 7 according to the embodiment of the present invention includes:
an obtaining module 71, configured to obtain a target physical page corresponding to a target application running in a background;
a recovery module 72, configured to perform recovery attempts on the target physical page for the target times, where a specific structure of the recovery module refers to the embodiment corresponding to fig. 6, which is not described herein again;
the judging module 73 is configured to judge whether the target application is a heavy recycling object according to the working state of the target application;
a first setting module 74 configured to set the target number of times as a first integer when the determination module 73 determines that the target application is the heavy recycling object;
a second setting module 75, configured to set the target number of times as a second integer when the determining module 73 determines that the target application is not the heavy recycling object, where the first integer is greater than the second integer, and the second integer is greater than or equal to zero.
Wherein the judging module 73 includes:
a first judging unit 731 for judging whether the target application is calling the audio playing component;
a first determination unit 732 configured to determine that the target application is not a heavy recycling object when the first determination unit 731 determines that the target application is not calling the audio playing component;
a second determination unit 733, configured to determine whether a call duration of the audio playing component by the target application exceeds a duration threshold when the first determination unit 731 determines that the target application is calling the audio playing component;
the second determination unit 734 is configured to determine that the target application is a heavy recycling object when the second determination unit 733 determines that the call duration of the target application to the audio playing component exceeds the duration threshold.
Referring to fig. 8, another embodiment of the memory recycling device 8 according to the embodiment of the present invention includes:
an obtaining module 81, configured to obtain a target physical page corresponding to a target application running in a background;
a recovery module 82, configured to perform recovery attempts on the target physical page for the target times, where a specific structure of the recovery module refers to the embodiment corresponding to fig. 6, which is not described herein again;
the judging module 83 is configured to judge whether the target application is a heavy recycling object according to the working state of the target application;
a first setting module 84 for setting the target number of times as a first integer when the determination module 83 determines that the target application is the heavy recycling object;
and a second setting module 85, configured to set the target number of times as a second integer when the determining module 83 determines that the target application is not a heavy recycling object, where the first integer is greater than the second integer, and the second integer is greater than or equal to zero.
Wherein the judging module 83 includes:
a third determining unit 831, configured to determine whether the target application is invoking the navigation positioning component;
a third determination unit 832 for determining that the target application is not a heavy recycling object when the third determination unit 831 determines that the target application is not calling the navigation positioning component;
a fourth judging unit 833, configured to, when the third judging unit 831 judges that the target application is calling the navigation positioning component, judge whether a displacement corresponding to a position change recorded by the navigation positioning component during calling of the navigation positioning component by the target application exceeds a displacement threshold;
a fourth judging unit 834, configured to judge that the target application is a heavy recycling object when the fourth judging unit 833 judges that the displacement corresponding to the position change recorded by the navigation positioning component during the invocation of the navigation positioning component by the target application exceeds the displacement threshold.
It should be noted that, in the foregoing embodiment, the case that the target application is an application running in a background is mainly illustrated, and in actual use, the target application may also be an application running in a foreground, and the method and the apparatus for recovering the target application running in the foreground are not described herein again, please refer to the foregoing embodiment.
It is obvious from the above embodiments that the method for reclaiming target application according to the present invention is based on the attempt of reclaiming target physical page of the target application, which is hereinafter referred to as simply reclaiming physical page, and several possible methods and apparatuses for reclaiming physical page are described in detail below.
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.
There are many angles for judging the value of the data stored in the physical page, and in the prior art, the value of the data stored in the physical page is generally evaluated according to the activity level (or activity level) of the physical page, and the higher the activity level of the physical page is, the higher the value of the data stored in the physical page is generally considered by the system to be. In order to compare the activity of physical pages, the prior art introduces a least recently used linked list LRU which is arranged according to the recent usage, and the least used linked list exists at the end. Physical pages in the 4 linked lists of INACTIVE _ ANON, ACTIVE _ ANON, INACTIVE _ FILE and ACTIVE _ FILE can be recycled, ANON represents anonymous mapping, FILE represents FILE mapping, INACTIVE represents INACTIVE state, ACTIVE represents ACTIVE state, and physical pages in the ACTIVE linked list have higher activity than physical pages in the INACTIVE state, that is, physical pages in the ACTIVE state have higher activity than physical pages in the INACTIVE state. When the memory is insufficient, the system preferentially recycles the physical pages in the INACTIVE _ ANON and INACTIVE _ FILE linked lists in the LRU, and when the process needs to use the contents on the recycled physical pages, the corresponding contents need to be loaded from the disk.
However, physical pages occupied by the foreground-running application process or the background-running application process with a high priority may also be in INACTIVE _ ANON and INACTIVE _ FILE, and the physical pages corresponding to the foreground-running process and the background-running process with a high priority in the two linked lists are recycled, so that the number of times of reading and writing of the 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 the actual scene test, all physical pages occupied by a process which falls back to the background for one minute are recycled, wherein the physical pages of the process in the INACTIVE _ ANON and INACTIVE _ FILE linked list 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 _ FILE linked list. Therefore, the existing method for recovering the memory of the process has low recovery efficiency.
In order to improve the recycling efficiency, the physical pages in the ACTIVE _ ANON and ACTIVE _ FILE linked lists need to be selectively recycled, and preferably, the physical pages with lower value or lower activity are recycled. Therefore, the present invention provides a memory recycling method, referring to fig. 9, an embodiment of the memory recycling method of the present invention includes:
901. acquiring a target physical page corresponding to a target process;
the target process of the target application can be obtained, and the target physical page corresponding to the target application is obtained through the target process. 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.
902. 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.
903. 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.
904. Reading the value of the activity of the target physical page;
after step 903, the value of the liveness of the target physical page may be read. If the target physical page was accessed prior to step 904, the value of the target physical page's liveness is increased.
905. 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 903 and step 904 is extremely short, and under the limit, it can be understood that after the activity of the target physical page is reduced in step 903, step 904 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 recycled, 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 regret mechanism in the embodiment corresponding to fig. 9, for example, a suitable time interval is set between step 903 and step 904, as a regret 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 idea, referring to fig. 10, another embodiment of the memory recovery method of the present invention includes:
1001. acquiring a target physical page corresponding to a target process;
1002. 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.
1003. 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;
1004. Judging whether the value of the activity of the target physical page is higher than a recovery standard, if so, executing step 1005, and if not, executing step 1007;
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 1005 is executed, and if not, step 1007 is executed.
1005. 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.
1006. 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 1003 to 1004. If the value of the activity level of the target physical page is still determined to be higher than the eviction criterion when step 1004 is repeatedly executed for the first time, step 1005 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 1003 to 1004 may be repeatedly performed 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 1002 in the embodiment of the present invention is not limited to the above, and since the preset time length is used for step 1006, the specific timing sequence is not limited as long as the step 1006 is executed before.
1007. And recycling the target physical page.
If step 1004 determines that the value of the liveness of the target physical page is not greater than the reclamation criteria, then the target physical page is reclaimed.
To add the repentance mechanism in the embodiment corresponding to fig. 9, in addition to the embodiment corresponding to fig. 10, by setting an appropriate time interval between step 903 and step 904 as a repentance duration to prevent the physical page with higher liveness from being recycled as much as possible, two or more optional values may be set for the liveness higher than the recycling standard, so that the physical page with higher liveness is less easily recycled in the recycling attempt, and with reference to fig. 11, based on this idea, another embodiment of the memory recycling method of the present invention includes:
1101. 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.
1102. Acquiring a target physical page corresponding to a target process;
1103. reading the value of the activity of the target physical page;
1104. Judging whether the value of the activity of the target physical page is higher than the recovery standard, if so, executing step 1105, otherwise, executing step 1107;
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 1105 is executed, and if not, step 1107 is executed.
1105. 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.
1106. Starting a timer;
a preset duration may be set as the repentance duration, and please refer to the embodiment corresponding to fig. 10 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 1103 to 1104. If the activity value of the target physical page is still determined to be higher than the eviction criterion when the step 1104 is repeatedly executed for the first time, step 1105 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 recycling efficiency and release more memory, it is preferable to perform two or more recycling attempts on the active physical page, that is, the steps 1103 to 1104 may be repeated twice or more.
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.
1107. 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. 11 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 1103 to 1104 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 as the fourth value, after step 1105 is executed, the value of the activity of the target physical page is set to the third value, then steps 1103 to 1104 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 the second value, then steps 1103 to 1104 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 the first value, then steps 1103 to 1104 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 1103 to 1104 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 1105 is executed, the value of the activity of the target physical page is set to be the second value, then steps 1103 to 1104 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 level to be set to be the first value, then steps 1103 to 1104 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 1103 to 1104 at least twice.
If the value of the activity of the target physical page is read for the first time as the second value, after step 1105 is executed, the value of the activity of the target physical page is set as the first value, and then steps 1103 to 1104 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 1103 to 1104 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 the steps 1103 to 1104.
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.
Further, the ACTIVE physical pages for which the target process needs to perform a reclamation attempt include a physical page of the target process in the ACTIVE _ ANON linked list (i.e., an anonymous page in the ACTIVE state) and a corresponding physical page of the ACTIVE _ FILE linked list (i.e., a FILE page in the ACTIVE state). The recovery mode of the anonymous page is page exchange, the recovery consumes long time and the efficiency is low; the recovery mode of the file page is page discarding or page writing back, the recovery time is short, and the efficiency is high. Therefore, compared with the anonymous page in the active state, the method can reduce the difficulty of recovering the file page in the active state, improve the recovery probability of the file page, and recover more file pages so as to improve the overall recovery efficiency of the active physical page.
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. 11 is used for recovering anonymous pages, please refer to fig. 12, which provides a method for recovering file pages, including:
1201. 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.
1202. Acquiring a target physical page corresponding to a target process;
1203. reading the value of the activity of the target physical page;
1204. Judging whether the value of the activity of the target physical page is higher than a recovery standard, if so, executing a step 1205, and if not, executing a step 1207;
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, and a physical page with a value of the activity higher than the reclamation criterion is in an active state, if so, step 1205 is performed, and if not, step 1207 is performed.
1205. 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. 11, 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.
1206. Starting a timer;
a preset duration may be set as the repentance duration, and please refer to the embodiment corresponding to fig. 10 for setting the preset duration, which is not described in detail in the embodiment of the present invention.
And when the duration recorded by the timer reaches the preset duration, repeatedly executing the steps 1203 to 1204. 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 1204 is repeatedly executed for the first time, step 1205 is not executed again, but 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 recycling efficiency and release more memory, it is preferable to perform two or more recycling attempts on the active physical page, that is, the steps 1203 to 1204 may be performed repeatedly 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.
1207. 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. 12 is exemplified by different cases of the first read value of the activity, assuming that the maximum number of times of repeated execution of steps 1203 to 1204 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 1205 is executed, the value of the activity of the target physical page is set to be the second value, then steps 1203 to 1204 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 levels, because the lowest level is the first value, the value is set to be the first value, then steps 1203 to 1204 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 1203 to 1204 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 1205 is executed, the value of the activity of the target physical page is set to be the first value, and then steps 1203 to 1204 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 1203 to 1204 at least once.
If the value of the activity of the target physical page is read for the first time as the second value, after step 1205 is executed, the value of the activity of the target physical page is set as the first value, and then steps 1203 to 1204 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 1203 to 1204 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 target physical page is read for the first time as the first value, the physical page can be recycled without repeatedly performing steps 1203 to 1204.
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. 11, the embodiment of the present invention is favorable to reduce the number of times of repeatedly executing steps 1203 to 1204 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. 11 and the embodiment method corresponding to fig. 12, as shown in table 1 below, for performing an actual scenario test of page recovery according to the embodiment method corresponding to fig. 11 and the embodiment method corresponding to fig. 12. 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
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, performing one step 1103 to 1104 on an anonymous page of a target process of the bean cotyledon, or performing one step 1203 to 1204 on a file page of the bean cotyledon, which is referred to as first recycling of the bean cotyledon for short, and according to the memory size occupied by the bean cotyledon before the recycling test and the memory size occupied by the bean cotyledon after the first recycling, calculating to obtain a first recycling rate of the bean cotyledon, which is 2.64%; then, performing step 1103 to step 1104 on the anonymous page of the target process of the bean cotyledon for the second time, or performing step 1203 to step 1204 on the file page of the bean cotyledon for the second time, which is referred to as performing the second recovery on the bean cotyledon for short, and according to the size of the memory occupied by the bean cotyledon after the first recovery and the size of the memory occupied by the bean cotyledon after the second recovery, calculating to obtain a second recovery rate of the bean cotyledon, which is 8.27%; 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. 13, an embodiment of the memory recycling device 13 according to the embodiment of the present invention includes:
an obtaining module 1301, configured to obtain a target physical page corresponding to a target process;
a first reading module 1302, 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 1303, 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 a value of the activity higher than the reclamation criterion is in an active state;
a second reading module 1304, 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 eviction module 1305, configured to evict the target physical page when the value of the liveness of the target physical page is not higher than the eviction criterion.
Referring to fig. 14, another embodiment of the memory recycling device 14 according to the embodiment of the present invention includes:
an obtaining module 1401, configured to obtain a target physical page corresponding to a target process;
a first reading module 1402, 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 1403, 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 a value of the activity higher than the reclamation criterion is in an active state;
a second setting module 1404, configured to set a preset duration according to the priority of the target process before the timer module 1405 starts the timer, where the preset duration is positively correlated with the priority of the target process;
a timing module 1405, configured to start a timer before reading the value of the activity of the target physical page after reducing the activity of the target physical page;
a second reading module 1406 for reading the value of the activity of the target physical page after the reducing module reduces the activity of the target physical page;
a reclamation module 1407 for reclaiming the target physical page when the value of the liveness of the target physical page is not higher than the reclamation criterion.
Preferably, the reducing module 1403 includes:
a setting unit 14031, 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 1403 further includes:
a reducing unit 14032, configured to reduce the activity of the target physical page by a first amplitude when the target physical page is an anonymous page; 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. 15 shows only a portion related to the embodiment of the present invention, and for convenience of description, 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 15 may be any terminal device including a mobile phone, a tablet computer, a Personal Digital Assistant (PDA).
Referring to fig. 15, the computer device 15 includes: a power supply 1510, a memory 1520, a processor 1530, and computer programs stored in the memory 1520 and executable on the processor 1530. The processor 1530 executes the computer program to implement the steps in each of the above-described embodiments of the information processing method, such as the steps 101 to 102 shown in fig. 1. Alternatively, the processor 1530 executes the computer program to realize the functions of the modules or units in the above-mentioned device embodiments.
Illustratively, the computer programs may be partitioned into one or more modules/units that are stored in the memory 1520 and executed by the processor 1530 in order to implement the present 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. 15 does not constitute a limitation of the computer apparatus 15, 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 1530 may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-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, and the processor 1530 is the control center of the computer device and connects the various parts of the whole computer device by various interfaces and lines.
The memory 1520 may be used to store the computer programs and/or modules, and the processor 1530 may implement various functions of the computer device by running or executing the computer programs and/or modules stored in the memory 1520 and calling data stored in the memory 1520. The memory 1520 may mainly include a program storage area and a data storage area, wherein the program storage 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. Further, the memory 1520 may include high-speed random access memory 1520, and may also include non-volatile memory 1520 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 (10)
1. A memory reclamation method, comprising:
acquiring a target physical page corresponding to a target application;
performing a target number of eviction attempts on the target physical page, one of the eviction attempts on the target physical page comprising:
judging whether the activity degree of the target physical page is higher than a recovery standard or not, wherein the activity degree of the target physical page is used for marking the activity degree of the target physical page, the activity degree value of the target physical page is positively correlated with the activity degree of the target physical page, and the physical page with the activity degree higher than the recovery standard is in an active state;
if so, reducing the activity of the target physical page;
and if not, recycling the target physical page.
2. The method of claim 1, wherein the target application is a background running application, and before performing the target number of recovery attempts on the target physical page, the method further comprises:
judging whether the target application is a heavy recycling object or not according to the working state of the target application;
if yes, setting the target times as a first integer;
if not, setting the target times as a second integer, wherein the first integer is larger than the second integer, and the second integer is larger than or equal to zero.
3. The method according to claim 2, wherein determining whether the target application is a heavily recycled object according to the operating status of the target application comprises:
judging whether the target application calls an audio playing component or not;
if not, judging that the target application is not a heavy recycling object;
if so, judging whether the calling time of the target application to the audio playing component exceeds a time threshold;
and if the calling duration is judged to exceed the duration threshold, judging that the target application is a heavy recycling object.
4. The method according to claim 2, wherein determining whether the target application is a heavily recycled object according to the operating status of the target application comprises:
judging whether the target application is calling a navigation positioning component;
if not, judging that the target application is not a heavy recycling object;
if so, judging whether the displacement corresponding to the position change recorded by the navigation positioning component exceeds a displacement threshold value during the calling period of the navigation positioning component by the target application;
and if the displacement corresponding to the position change recorded by the navigation positioning assembly is judged to exceed a displacement threshold value, judging that the target application is a heavy recycling object.
5. A memory recycling device, comprising:
the acquisition module is used for acquiring a target physical page corresponding to a target application;
the recovery module is used for performing recovery attempt on the target physical page for the target times;
the recycle module comprises a recycle unit for performing the recycle attempt on the target physical page once;
the recovery unit includes:
the judging subunit is used for judging whether the activity of the target physical page is higher than a recovery standard or not, the activity of the target physical page is used for marking the activity degree of the target physical page, the value of the activity degree of the target physical page is positively correlated with the activity degree of the target physical page, and the physical page with the activity degree higher than the recovery standard is in an active state;
a decreasing subunit operable to decrease the activity level of the target physical page when the judging subunit judges that the activity level of the target physical page is higher than the reclamation standard;
a recovery subunit operable to recover the target physical page when the judgment subunit judges that the liveness of the target physical page is not higher than a recovery standard.
6. The memory reclamation apparatus as recited in claim 5, wherein the target application is an application running in the background, the memory reclamation apparatus further comprising:
the judging module is used for judging whether the target application is a heavy recycling object or not according to the working state of the target application;
the first setting module is used for setting the target times as a first integer when the judging module judges that the target application is a heavy recycling object;
and the second setting module is used for setting the target times as a second integer when the judging module judges that the target application is not a heavy recycling object, wherein the first integer is greater than the second integer, and the second integer is greater than or equal to zero.
7. The apparatus according to claim 6, wherein the determining module comprises:
the first judgment unit is used for judging whether the target application calls an audio playing component or not;
a first determination unit configured to determine that the target application is not a heavy recycling object when the first determination unit determines that the target application is not calling the audio playback component;
the second judging unit is used for judging whether the calling time length of the target application to the audio playing component exceeds a time length threshold value or not when the first judging unit judges that the target application is calling the audio playing component;
and the second judging unit is used for judging that the target application is a heavy recycling object when the second judging unit judges that the calling duration of the target application to the audio playing component exceeds a duration threshold.
8. The apparatus according to claim 6, wherein the determining module comprises:
the third judging unit is used for judging whether the target application calls a navigation positioning component or not;
a third judging unit, configured to judge that the target application is not a heavy recycling object when the third judging unit judges that the target application is not calling a navigation positioning component;
a fourth judging unit, configured to, when the third judging unit judges that the target application is calling a navigation positioning component, judge whether a displacement corresponding to a position change recorded by the navigation positioning component exceeds a displacement threshold value during the calling of the navigation positioning component by the target application;
and the fourth judging unit is used for judging that the target application is a heavy recycling object when the fourth judging unit judges that the displacement corresponding to the position change recorded by the navigation positioning component exceeds a displacement threshold value during the calling period of the target application to the navigation positioning component.
9. 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-4 when executing a computer program stored in a memory.
10. 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-4 when executed by a processor.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710647577.5A CN108205471B (en) | 2017-08-01 | 2017-08-01 | Memory recovery method and device, computer device and computer readable storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710647577.5A CN108205471B (en) | 2017-08-01 | 2017-08-01 | Memory recovery method and device, computer device and computer readable storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN108205471A CN108205471A (en) | 2018-06-26 |
CN108205471B true CN108205471B (en) | 2021-04-27 |
Family
ID=62604348
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201710647577.5A Active CN108205471B (en) | 2017-08-01 | 2017-08-01 | Memory recovery method and device, computer device and computer readable storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN108205471B (en) |
Families Citing this family (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109522122B (en) * | 2018-11-14 | 2021-12-17 | 郑州云海信息技术有限公司 | Memory management method, system, device and computer readable storage medium |
CN110008016B (en) * | 2019-04-15 | 2021-06-22 | 深圳市万普拉斯科技有限公司 | Anonymous page management method, device, terminal device and readable storage medium |
CN111581119B (en) * | 2020-05-07 | 2022-11-18 | Oppo(重庆)智能科技有限公司 | Page recovery method and device |
CN111880991B (en) * | 2020-07-23 | 2022-09-13 | Oppo广东移动通信有限公司 | Memory optimization method and device, electronic equipment and computer readable storage medium |
CN112783661B (en) * | 2021-02-08 | 2022-08-12 | 上海交通大学 | A memory deduplication method and device suitable for container environment |
CN118409937B (en) * | 2024-07-04 | 2024-09-24 | 浪潮通用软件有限公司 | Application deployment planning method, device and medium based on disk scanning |
Citations (4)
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 (1)
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 |
-
2017
- 2017-08-01 CN CN201710647577.5A patent/CN108205471B/en active Active
Patent Citations (4)
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 |
---|---|
CN108205471A (en) | 2018-06-26 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN108205471B (en) | Memory recovery method and device, computer device and computer readable storage medium | |
CN108228341B (en) | Memory recovery method and device, terminal equipment and computer readable storage medium | |
CN108205473B (en) | Memory processing method and device, computer device and computer-readable storage medium | |
CN108205498B (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 | |
CN108205501B (en) | Memory recovery method and device, computer device and computer readable storage medium | |
CN108228339B (en) | Memory recovery method and device, terminal equipment and computer readable storage medium | |
CN111176560B (en) | Cache management method and device, computer equipment and storage medium | |
CN106406753B (en) | A kind of date storage method and data storage device | |
US10437519B2 (en) | Method and mobile terminal for processing write request | |
CN110727607B (en) | Memory recovery method and device and electronic equipment | |
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 | |
CN111274039B (en) | Memory recycling method and device, storage medium and electronic equipment | |
CN110727605B (en) | Memory recovery method and device and electronic equipment | |
CN117492662B (en) | Pre-reading determination method and device, storage medium and electronic equipment | |
CN111984413A (en) | Memory recovery method and device, electronic equipment and storage medium | |
CN108228340B (en) | Terminal control method and device, terminal equipment and computer readable storage medium | |
CN108228342B (en) | Terminal device control method and device, terminal device and computer readable storage medium | |
CN111245732A (en) | Flow control method, device and equipment | |
CN116166573B (en) | Methods, electronic devices and storage media for controlling memory recycling | |
CN113138941A (en) | Memory exchange method and device | |
CN108287761B (en) | Memory recovery method and device, terminal equipment and computer readable storage medium | |
CN107291627B (en) | Data processing method and electronic equipment | |
CN112199042B (en) | Storage space management method, device, chip, equipment and storage medium |
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 |