WO2019136963A1 - Method and device for reclaiming memory - Google Patents
Method and device for reclaiming memory Download PDFInfo
- Publication number
- WO2019136963A1 WO2019136963A1 PCT/CN2018/099419 CN2018099419W WO2019136963A1 WO 2019136963 A1 WO2019136963 A1 WO 2019136963A1 CN 2018099419 W CN2018099419 W CN 2018099419W WO 2019136963 A1 WO2019136963 A1 WO 2019136963A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- application process
- application
- memory
- user preference
- active
- Prior art date
Links
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]
-
- 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
-
- 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
Definitions
- the present disclosure relates to the field of terminal technologies, and in particular, to a method and an apparatus for reclaiming memory.
- the terminal can run various processes, and the process can be the system process of the operating system and the application process of the application, wherein each process occupies a certain amount of memory during the running process, and stores itself in the memory.
- the data As the terminal runs, more and more processes are running, more and more memory is occupied, and free memory is less and less.
- the memory occupied by the process is required. Recycling is performed to ensure that the free memory of the terminal meets the memory requirements.
- the process of reclaiming memory is specifically as follows: the LMK process acquires the current oom_adj of each process, and acquires the memory occupied by each process, wherein oom_adj uses To indicate the priority of the process, the higher the om_adj value, the lower the priority of the process. Then, according to the oom_adj and occupied memory of each process, each process is scored to obtain the score of each process. After that, according to the score of each process, the process to be killed is determined. The greater the score of the process, the higher the priority is to kill the process.
- the oom_adj uses To indicate the priority of the process, the higher the om_adj value, the lower the priority of the process.
- each process is scored to obtain the score of each process. After that, according to the score of each process, the process to be killed is determined. The greater the score of the process, the higher the priority is to kill the process.
- oom_adj is fixed.
- oom_adj is 2.
- the process is a native process
- oom_adj is -17, the larger the oom_adj value, the higher the score of the process, and the memory occupied by the process. The larger the score, the higher the score of the process.
- the embodiments of the present disclosure provide a method and an apparatus for reclaiming memory, which can solve the problem of easy to kill the process in the related art.
- the technical solution is as follows:
- a method of reclaiming memory comprising:
- the method provided in this embodiment takes the user's usage habits into consideration when reclaiming the memory, determines the application process to be recycled according to the user preference of each application process, and then recovers the memory occupied by the application process to be recycled, and preferentially recycles the user preference.
- the memory occupied by the lower application process avoids reclaiming the memory occupied by the application process with high user preference, ensuring the accuracy and rationality of retrieving the memory of each application process, avoiding the killing process and the application process.
- the data is transferred to the preset storage space, so as to avoid affecting the normal operation of the application process, and ensuring that the overall impact of the process of reclaiming the memory on the operation of the terminal is as small as possible.
- the determining the user preference of each of the plurality of application processes in the time period to which the current application point belongs includes:
- the process of ensuring the memory recovery is time-sensitive: considering that the application process preferred by the user can change over time, for example, a user prefers to use the application process of the Weibo application in the past, and now prefers to use the instant messaging application.
- Application process etc.
- the user preference for each application process is not obtained in advance, but each application is calculated in real time according to the active duration of the historical running process of the application process when the terminal reclaims the memory occupied by the application process.
- the user preference of the process that is, the user preference of the self-learning application process, the calculated user preference can be dynamically changed with time, and the order of memory occupied by the application process is recycled each time.
- Dynamic changes for example, when the terminal calculates the user preference last month, the application process of the instant messaging application has the highest user preference, and the probability of reclaiming the memory of the application process of the instant messaging application is the smallest, and the music playing application is calculated when the user preference is calculated this month.
- the application process has the highest user preference, and the probability of reclaiming the memory of the application process of the music playing application is the smallest.
- determining, according to the active duration of the time period of each application process in the historical operation, the application time of each application process in the multiple application processes at the current time point User preference for the time period to which it belongs including:
- the active duration is taken as the user preference.
- the terminal can obtain user preference simply and efficiently.
- the terminal can ensure that the user's preference is within a reasonable range of values.
- the user's preference can be guaranteed to be within a reasonable numerical range, and the cold start time of the application process is taken into account, and the memory occupied by the application process is guaranteed to be recovered.
- the overall impact on the terminal is as small as possible.
- the determining, according to the user preference of each application process in the multiple application processes, the application process to be reclaimed in the multiple application processes including:
- the obtaining, according to the user preference of each application process in the multiple application processes, the reclaiming priority of each application process including:
- the most recent active weight of each application process is used to indicate a degree of recent activeness of each application process
- the determining the most recent active weight of each application process includes:
- the accuracy of the reclaimed memory can be further improved: for a plurality of application processes whose user preference is close, if an application process is the most recent If the active application process has a large active weight, the revocation priority will be lower, and the memory of the application process can be avoided, so as to avoid affecting the normal operation of the recently active application process. If an application process is an active application process that is active for a long time, if the recent active weight is small, the reclaim priority will be higher, and the memory of the application process will be reclaimed preferentially, and the memory occupied by the active application process long ago is preferentially reclaimed. On the basis of realizing the recovery of memory, the overall impact on the operation of the terminal is guaranteed to be as small as possible.
- the obtaining, according to the user preference of each application process in the multiple application processes, the reclaiming priority of each application process including:
- the function weight of each application process is used to indicate the importance degree of the function of each application process
- the accuracy of reclaiming memory can be further improved: for multiple application processes with similar user preferences, if the process function of an application process is less important It can be considered that the current running activity of the application process is of low importance to the terminal, and the impact of reclaiming the memory of the application process is small, and when the function weight is determined to determine the recycling priority, the recycling priority is higher, and the terminal takes precedence. Reclaim the memory of the application process to minimize the overall impact of the reclaimed memory on the terminal.
- the obtaining, according to the user preference of each application process in the multiple application processes, the reclaiming priority of each application process including:
- the power consumption weight of each application process is used to indicate a size of power consumption of each application process
- the following technical effects can be achieved: for a plurality of application processes with similar user preferences, if the power consumption of an application process is greater, The greater the power consumption weight, the higher the reclaim priority, and the terminal will preferentially reclaim the memory occupied by the application process. By preferentially reclaiming the memory occupied by the application process with high power consumption, the power consumption of the terminal can be saved on the basis of realizing the function of reclaiming memory.
- the obtaining, according to the user preference of each application process in the multiple application processes, the reclaiming priority of each application process including:
- the accuracy of the reclaimed memory can be further improved: for a plurality of application processes with similar user preferences, it is assumed that the memory of an application process accounts for If the memory size is larger, the memory weight will be larger, and the recycling priority will be higher. Therefore, the memory of the application process will be reclaimed preferentially, and the memory that is recovered will be guaranteed to ensure that the free memory satisfies the memory requirement as quickly as possible.
- the obtaining, according to the user preference of each application process in the multiple application processes, the reclaiming priority of each application process including:
- the calling frequency of each application process is used to indicate the total number of times the plurality of application processes invoke the each application process in the time period in the historical operation;
- the determining the calling frequency of each application process includes:
- the method before the determining that the plurality of application processes are running in the background, the method further includes:
- the process of ensuring the memory recovery is close to the user's personal usage habits: considering that the application process preferred by different users in daily life may be different, for example, user A prefers the application process using the instant messaging application, and user B prefers to use music to play.
- the application process of the application user C prefers to use the application process of the online shopping application, and the like.
- the user preference of the application process is not uniformly set, but the terminal calculates the user preference of each application process in real time by self-learning.
- the user preference of each application process can reflect the user's personal usage habits. Therefore, when the memory is recycled in combination with the user preference, the personalized requirement can be satisfied.
- the probability that the user A's terminal reclaims the application process of the instant messaging application has the smallest probability, and the user has the smallest probability.
- the terminal of B recycles the memory of the application process of the music playing application with the least probability of the memory and the like.
- the recovering the memory occupied by the application process to be recycled includes:
- an apparatus for reclaiming memory comprising a plurality of functional modules to implement the method of reclaiming memory in the first aspect and any of the possible designs of the first aspect.
- an apparatus for reclaiming memory includes:
- a processor configured to execute the program stored in the memory, when the program is executed, the processor is configured to perform the method of reclaiming memory in any of the possible aspects of the first aspect and the first aspect described above .
- a computer readable storage medium comprising instructions, when executed on a computer, causing the computer to perform the method of reclaiming memory in any of the possible aspects of the first aspect and the first aspect described above.
- FIG. 1 is a schematic structural diagram of an apparatus for recycling a memory according to an embodiment of the present disclosure
- FIG. 2 is a flowchart of a method for reclaiming memory provided by an embodiment of the present disclosure
- FIG. 3 is a schematic diagram of a design of a method for reclaiming memory provided by an embodiment of the present disclosure
- FIG. 4 is a schematic structural diagram of an apparatus for reclaiming memory provided by an embodiment of the present disclosure.
- Cold boot When the application is started, if there is no main process applied in the background, the terminal creates a process and assigns the process to the application, which is the main process of the application, and then starts the application. The way is called cold start. In the scenario where the application is started for the first time after the terminal is powered on, or in the scenario where the application is restarted after the main process of the application is killed, the application is started in a cold boot manner. When the application is cold-started, the terminal needs to read the application data from the disk, then write the application data into the memory, and then load the data from the memory to start the application based on the data, because the data is exchanged from the disk to the memory. The duration is usually longer, so the cold start is usually longer.
- Hot start When the application is started, if there is a main process associated with the application in the background, the terminal will directly start the application by using the main process. This method of starting the application is called hot start. After the terminal is powered on, the application is started, and then the application process is switched to run in the background. Then, the application is switched to the foreground running scenario, and the application is started in a warm boot mode. When the application is warm-started, the terminal can start the application by directly loading data from the memory without re-switching the application's data from disk to memory, so the warm boot time is usually shorter.
- LNK Low Memory Killer
- the LMK process detects the free memory of the terminal. When the free memory is less than the memory threshold, it acquires the current oom_adj of each process and obtains The memory occupied by each process, according to the oom_adj of each process and the occupied memory, score each process, get the score of each process (oom_score_adj), kill each process in turn according to the score of each process, Reclaim free memory occupied by the process until the free memory is not less than the memory threshold.
- Kswapd process mechanism A memory protection mechanism in the Linux operating system.
- the kswapd process also known as the page swapping daemon, also detects the free memory of the terminal. When the free memory is less than the memory threshold, the kswapd process scans the stored data in the memory. Each memory page, when the number of memory pages is accessed less or the storage time is earlier, the data in the memory page is transferred to the zram partition (a kind of storage space), thereby freeing the memory until the free memory is not Less than the memory threshold.
- Direct reclaim mechanism A memory protection mechanism in the Linux operating system. When a process requests memory from the operating system and the requested memory exceeds the current free memory, the process scans the stored data in the memory. Each memory page, when the number of memory pages is accessed less frequently or stored earlier, will transfer the data in the memory page to the zram partition, thereby freeing the memory until the free memory is not less than the requested memory.
- the application process can be called by the user or other application process. The higher the user preference, the greater the possibility that the application is called. The lower the user preference, the less likely the application is called.
- the user preference can represent the user.
- the degree of preference for the application process is determined according to the active duration of the time period of the application process in the historical operation, for example, assuming that the current time point is 9:10, belonging to The time period is from 9:00 to 10:00, and the user preference of the application process is determined according to the active duration of 9:00-10:00 in the historical operation, for example, according to the application process at yesterday's 9:00-10:00.
- the active duration is determined, based on the active duration of the application process from 9:00 to 10:00 last month.
- Recycling priority negatively related to user preference. It is used to represent the priority when reclaiming memory. The revocation priority of the application process is high. The higher the order of memory used by the reclaiming application process, the lower the revocation priority of the application process. The later the memory usage of the application process is recycled.
- the apparatus for reclaiming memory includes: a receiver 101, a transmitter 102, a memory 103, and a processor 104.
- the receiver 101, The transmitter 102 and the memory 103 are respectively connected to the processor 104.
- the memory 103 stores a program for executing a program stored in the memory 103.
- the processor 104 is configured to execute the following.
- the method of recycling memory includes: a receiver 101, a transmitter 102, a memory 103, and a processor 104.
- a computer readable storage medium comprising instructions, such as a memory including instructions, that when executed on a computer, cause the computer to execute as in the embodiments described below
- the method of recycling memory may be a read-only memory (ROM), a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, and an optical data storage device.
- the embodiment of the present disclosure introduces a user's personal usage habits, obtains the user preference of the application process in a dynamic self-learning manner, and combines the user preference to recover the memory strategy, and can embed the existing Linux operating system and Android. (Android) operating system, as a new memory protection mechanism in various operating systems.
- the embodiments of the present disclosure can be applied to various memory recovery scenarios, and can recover and control the memory occupied by the application process to ensure smoothness and responsiveness of the terminal operation. The following is an example of three exemplary scenarios:
- Scene 1 LMK mechanism.
- the terminal may determine the user preference of each application process running in the background by using the method provided by the embodiment of the present disclosure, and determine the application process to be recycled, which is to be recovered.
- the application process is provided to the LMK process, and the LMK process can kill the application process to be recycled, thereby reclaiming the memory occupied by the application process to be recycled.
- the LMK process preferentially kills application processes with low user preference, and stops the kill process when the free memory is not less than the memory threshold, thereby reducing the probability of killing the application process frequently used by the user, thereby avoiding the killing application.
- the process also avoids affecting the operation of the application process that the user frequently uses, and ensures the smoothness of the terminal operation.
- the terminal may determine the user preference of each application process running in the background by using the method provided by the embodiment of the present disclosure, and determine the application process to be recycled, which is to be recovered.
- the application process is provided to the kswapd process, and the kswapd process transfers the data in the in-memory application process to the preset storage space to recover the memory occupied by the application process.
- the kswapd process preferentially transfers the in-memory data of the application process with lower user preference to the preset storage space, and stops the process of transferring data when the free memory is not less than the memory threshold, thus reducing the kswapd process.
- the probability of transferring the data in the memory of the application process frequently used by the user to the preset storage space avoids affecting the operation of the application process frequently used by the user and ensuring the smoothness of the terminal operation.
- Scene 3 the direct memory recovery mechanism.
- the terminal may determine the user preference of each application process running in the background by using the method provided by the embodiment of the present disclosure, thereby determining the application to be recycled.
- the process provides the process to be reclaimed to the process of requesting the memory, and the process of requesting the memory transfers the data in the memory of the application process to be recycled to the preset storage space to recover the memory occupied by the application process.
- the process requesting memory preferentially transfers the data in the memory of the application process with lower user preference to the preset storage space, and stops the process of transferring data when the free memory exceeds the requested memory, thereby reducing the process.
- the probability of transferring the data in the memory of the application process frequently used by the user to the preset storage space avoids affecting the operation of the application process frequently used by the user and ensuring the smoothness of the terminal operation.
- the execution body of the method is a terminal, and the terminal may be a mobile phone, a tablet computer, or the like.
- the method includes the following steps:
- the terminal collects an active duration of each application process in each application process in a historical operation.
- Active duration refers to the length of time the application process is running in the foreground.
- the terminal can record the active duration: when the application process starts running in the foreground, the terminal can record the current time point as the start time of the active duration, when the application process ends in the foreground.
- the terminal can record the current time point as the end time point of the active duration, calculate the time difference between the end time point and the start time point, and obtain the active duration that the application process is currently running in the foreground. For example, when the application process starts running in the foreground at 9:00 and ends in the foreground at 9:10, the record active time is 10 minutes.
- the time period may be divided into a day, for example, the time period may include a time period corresponding to the morning, a time period corresponding to the noon, or a time period corresponding to the night, and the duration of each time period may be 8 hours.
- the time period may be determined according to a physiological condition of the user, and a time period in which a certain physiological behavior is generated may be used as a time period.
- a time period in which a certain physiological behavior is generated may be used as a time period.
- the lunch time period may be used as a time period
- the dinner time period may be used as a time period.
- the time period of the sleep period is taken as a time period and the like, and the timeliness of the user preference can be improved by the method of determining the time period.
- the following step 204 refer to the following step 204.
- the terminal can accumulate the active duration of each application process from zero every time when it starts to enter any time period, that is, the current time point is the starting point of the time period, when leaving the time period, that is, the current time
- the accumulated active time of each application process in the time period is ended, the active duration accumulated by each application process in the time period is stored, and the next statistical process is started, and the accumulation is started again from zero. ,And so on.
- each application process may be active one or more times in each time period, and may start from zero when the application process is active for the first time in each time period. Record the active duration of the application process until the application process is paused, and when the application process is active for the second time to the Nth active time, the active time of the application process may be added to the recorded time period. Active active time.
- the active time of the application process A is 5 minutes
- application process A is active for the third time and is active for 8 minutes, then application process A is active.
- each time the terminal acquires an active duration of the application process in the foreground the time period to which the current time point belongs is obtained, the current date is obtained as the record date, and the application process identifier of the application process is obtained, and the record is active.
- the terminal can record "00:00-08:00 (time period), December 7 (recording date), APP1 (application process identification), 50 minutes (active duration)".
- this step 201 can be performed by the activity management service (AMS) of the terminal.
- AMS is the core service of the Android operating system.
- the program code of the AMS can be improved, and the program code of the active time of each application process running in the foreground is added to the program code of the AMS, so that the AMS is loaded and When you run the program code, you can implement the function of counting active time.
- the terminal can detect whether the free memory meets the preset condition during the running process. When it detects that the free memory does not meet the preset condition, it determines the multiple application processes running in the background, so as to Determine the application process to be recycled, and then perform memory recycling.
- the preset condition and the process of detecting whether the free memory meets the preset condition may specifically include the following two designs:
- the default condition is that the free memory is less than the memory threshold, and the terminal can detect whether the current free memory is less than the memory threshold in real time or periodically.
- the memory threshold is used to indicate the minimum memory required for the terminal to operate normally. When the memory threshold is less than the memory threshold, the terminal determines that the free memory does not meet the preset condition.
- the terminal may start the LMK process or the kswapd process, and the LMK process or the kswapd process performs a process of detecting whether the free memory is less than a memory threshold.
- the LMK process When the LMK process detects that the free memory is less than the memory threshold, it can obtain the oom_adj of all the currently running processes, and generate a list of the to-be-killed processes according to the oom_adj of each process, and the list of the to-be-killed processes includes the LMK process that is determined to be able to be killed in the background.
- the running process, the terminal can determine the application process associated with each process in the to-be-killed process list, as an application process that subsequently acquires user preference and can reclaim memory.
- the second preset condition may be that the requested memory exceeds the free memory.
- the memory request may be sent to the terminal, where the memory request carries the memory requested by the application process, and the terminal may request the memory according to the memory request.
- the memory requested by the application process is obtained to determine whether the requested memory exceeds the free memory.
- the terminal may determine that the free memory does not meet the preset condition.
- the terminal determines a user preference of each application process in the multiple application processes at a time period to which the current time point belongs.
- the user preference of each application process in the multiple application processes is determined, so as to determine from multiple application processes based on the user preference of each application process.
- the specific process of determining the user preference may include the following steps 1 to 2:
- Step 1 Obtain an active duration of a time period to which the current time point of each application process belongs in the historical operation.
- the terminal may obtain an active duration of the time period to which the current time point of the application process belongs in the historical operation, and the active duration reflects the activity level of the application process in the historical operation. Since the time period is determined according to the current time point, it can be considered that the active duration matches the activity level of the application process before and after the current time point in the current running process, thereby ensuring that the user preference determined based on the active duration is highly time-sensitive. High accuracy.
- the process of obtaining the active duration of the time period of the application process in the historical running may specifically include the following steps (1)-(3):
- the terminal can acquire the current time point and determine the time period to which the current time period belongs.
- the terminal may determine the historical period according to the current date and the preset statistical period, where the current period is the time end point and the duration is the preset statistical period. Taking the current date as December 7, 2017 as an example, assuming that the preset statistical period is 1 day, the historical period is from December 6, 2017 to December 7, 2017, assuming that the preset statistical period is one month, then The historical period is from November 7, 2017 to December 7, 2017.
- the preset statistical period can be determined according to the actual requirement.
- the specific value of the preset statistical period is not limited in this embodiment.
- the terminal can query the correspondence between the active duration, the time period, the recording date, and the application process identifier according to the historical period, the time period, and the application process identifier of the application process, and obtain the active corresponding to the time period, the historical period, and the application process identifier.
- the duration, that is, the corresponding time period, the corresponding recording date is the historical period, and corresponds to the active duration of the application process identifier, as the active duration of the application process in the historical operation. For example, suppose the historical period is from November 7, 2017 to December 7, 2017, the time period is 17:00-19:00, the application process ID is service1, and the terminal can obtain service1 from November 7, 2017 to 2017. The active time of 17:00-19:00 on December 7th.
- Step 2 Determine user preference of each application process in multiple application processes according to the active duration of the time period of each application process in the plurality of application processes.
- the terminal may acquire the user preference of each application process based on the active duration, so as to be based on the user preference. Determine the application process to be recycled.
- the specific process of obtaining user preferences can include the following designs:
- the active time is taken as the user preference.
- the terminal can directly use the active duration of the application process in the historical running period as the user preference of the application process, thereby obtaining the user preference simply and effectively.
- Design 2 Calculate the ratio between the active duration and the active duration as the user preference.
- the sum of the active durations refers to the sum of the active durations of the multiple application processes currently running in the background during the historical running.
- the terminal can traverse each application process in multiple application processes.
- the active duration of each application process is determined by the method provided in the foregoing step 203, and the active duration of the multiple application processes is obtained, and the sum of the active durations is calculated to obtain the sum of the active durations.
- the ratio between the active duration of the application process and the sum of the active durations is calculated, and the ratio is used as the user preference, and the user preference may also be referred to as The proportion of active time, that is, the proportion of the active duration of the application process in the active duration of multiple application processes.
- the user's overall usage of the terminal on different dates may be different, and the active duration obtained when the user preference is counted on different dates will also be different.
- the holiday can use the peak period of the terminal for the user. During the holiday period, the active time of each application process in each time period is usually longer. If the user preference is counted at this time, the active time length of each application process obtained is obtained. Long, and by calculating the ratio between the active duration of the application process and the sum of the active durations, it is guaranteed that the user's preference is not too high.
- the test week and the workday may be the low tide period for the user to use the terminal.
- the active time of each application process in each time period will be short. If the user preference is collected at this time, the obtained time is obtained.
- the active duration obtained by each application process is short, and by calculating the ratio between the active duration and the active duration, the user preference is not too low. That is, the user preference of the calculated application process is relatively stable, and the situation is not too high or too low due to the influence of the current date, so that the subsequent application process to be recovered based on the user preference can be guaranteed. Recycle the accuracy of the memory process used by the application process.
- Design 3 Calculate the product between the active duration and the cold start duration of the application process as the user preference.
- the cold start duration of an application process refers to the length of time it takes for the application process to start the corresponding application in a cold boot manner.
- the relationship between the cold boot duration and the application process that starts the application may be recorded in advance when any application is started in a cold boot manner, and the application may be acquired when the cold boot duration is to be obtained.
- the cold-start duration of the most recent record of all cold-start durations that have been recorded by the process to calculate user preference based on the cold-start duration.
- the cold start duration of the application process is obtained, and the active duration is weighted by the cold start duration, that is, the product between the cold start duration and the active duration is calculated as the user preference, by combining
- the cold start time and active time to obtain user preference can achieve the following technical effects:
- the application process B is faster when it is cold-started. Even if the memory occupied by the application process B is recovered, the application process B is restarted again because of the faster speed, which has less impact on the terminal operation and is less likely to cause the terminal. Caton's user experience.
- the user preference of the application process B can be appropriately attenuated, and then the application process B is preferentially used as the application process to be recycled, and the memory occupied by the application process B is preferentially recycled. That is, on the basis of accurately recovering the memory occupied by the application process, taking into account the cold boot time of each application process, and minimizing the overall impact on the terminal.
- the application may start multiple application processes during the running process, and the main process in the multiple application processes starts the application in a cold start manner or a hot start manner, and each of the main processes
- the child processes are used to provide functions other than launching the application.
- the application process is the main process
- the cold boot time of the corresponding application started by the recorded main process can be directly obtained to calculate the user preference of the main process.
- the application process is a child process
- the cold boot time of the main process corresponding to the child process may be determined as the cold start duration of the child process to calculate the user preference of the child process.
- Design 4. Calculate the ratio between the active duration and the active duration and value, and calculate the product between the ratio and the cold start duration of the application process as the user preference.
- This design is the combination of design two and design three-phase.
- the acquisition method of active duration and value is detailed in Design 2.
- the acquisition method of cold start time is detailed in Design III, and will not be described here.
- the user preference can be guaranteed to be within a reasonable numerical range, and the cold start time of the application process is taken into consideration, and the memory occupied by the application process is guaranteed to be recycled to the terminal.
- the overall impact is as small as possible.
- the time period in the above step 201 is determined according to the physiological behavior of the user, in this step, the effect that the user preference matches the physiological habits of the user can be achieved: for example, considering that the user usually has a lunch time period and During the dinner time period, the application process of the take-out ordering application is preferred, and the lunch time period and the dinner time period are set as the time period in advance to calculate the active time length in real time, and if the current time point is the lunch time period and the dinner time period, the memory is to be recovered, and the calculation is performed.
- the user preference of the application process of the take-out ordering application is higher, and the memory occupied by the application process of the take-out ordering application can be avoided, and the application process of the user who prefers to use the music playing application during the sleeping time period is considered, for example.
- the sleep time period is set to the time period in advance to calculate the active duration in real time. If the memory is to be reclaimed during the current sleep time period, the calculated user preference of the application process of the music playing application is higher, then Avoid reclaiming memory used by the app process of the music player application.
- the terminal acquires a recycling priority of each application process based on user preference of each application process.
- the terminal can obtain the recycling priority of each application process, so as to determine the application process to be recycled based on the recycling priority of each application process.
- the reclaiming priority of each application process is negatively related to the user preference of each application process. If the user preference of the application process is higher, the revocation priority of the application process is lower, and the user preference of the application process is lower. , the higher the recycling priority of the application process.
- the embodiment further provides the memory ratio of the user preference and the application process, the function of the application process, the latest active duration of the application process, and the application.
- the power consumption of the process and other factors together determine the way to reclaim the priority. See Design 1 to Design 4 below for details.
- the value of the recycling priority in the following various designs is inversely proportional to the level of the recycling priority. That is, the smaller the value of the recycling priority, the higher the recycling priority, the larger the value of the recycling priority, and the recycling priority. The lower.
- Design 1 Determine the recycling priority by combining the user preference with the memory ratio of the application process.
- the design may specifically include the following steps 1 to 3:
- Step 1 The terminal determines the memory weight corresponding to the memory ratio of each application process, and the memory ratio of each application process is used to indicate the ratio between the memory occupied by each application process and the total memory overhead.
- the terminal can obtain the memory occupied by each application process and the current total memory cost, and calculate the memory occupied by each application process and the total memory overhead. Ratio, the ratio is taken as the memory ratio.
- the terminal can obtain the memory weight ratio corresponding to the memory ratio of the application process based on the correspondence between the memory ratio of the application process and the memory weight.
- the correspondence between the memory ratio and the memory weight ratio includes a plurality of memory ratios and corresponding memory weight ratios. The larger the memory ratio, the larger the corresponding memory weight.
- the correspondence between the memory ratio and the memory weight can be set by the developer in advance. After the terminal obtains the memory ratio, the memory ratio is used as an index, and the correspondence between the memory ratio and the memory weight ratio is queried, and the memory ratio weight corresponding to the memory ratio is obtained from the corresponding relationship.
- the terminal may quantize the memory ratio. For example, multiple memory ratio intervals may be set, and a correspondence between the memory ratio interval and the memory weight ratio is set.
- the memory ratio ratio of the memory ratio may be obtained from a plurality of memory ratio intervals, and the memory ratio of the application process's memory ratio interval is obtained based on the correspondence between the memory ratio interval and the memory ratio weight. Weights.
- the memory ratio interval can be set by the developer according to actual needs, for example, setting 1%-10% as a memory ratio interval.
- all the memory ratios in a certain range of values can be uniformly unified with a certain memory weight, and the correspondence between the memory ratio and the memory weight is not included in the value range. All memory ratios only need to include the memory ratio interval, which simplifies the correspondence and reduces the amount of data to be stored.
- Step 2 The terminal obtains the recycling priority of each application process according to the user preference of each application process and the memory weight of each application process.
- the recycling priority of the application process is positively correlated with the memory weight and is negatively related to user preference.
- the ratio between the user preference and the memory weight may be calculated to obtain a recycling priority.
- the accuracy of the reclaimed memory can be further improved: for a plurality of application processes whose user preference is close, assuming that the memory of an application process is relatively large, The memory has a larger weight, so the application process has a higher reclaim priority, and the memory of the application process is preferentially reclaimed. It can ensure that more memory is reclaimed, and the free memory is guaranteed to meet the memory requirement as quickly as possible.
- the design may specifically include the following steps 1 to 2:
- Step 1 The terminal determines a function weight corresponding to the function of each application process.
- the function of the application process can include push function, network connection function, etc.
- the application can open one or more application processes at the same time, and each application process can have corresponding process functions according to the currently executing activities, for example, the instant communication application can open the main function.
- the process, the push sub-process, the networked sub-process, etc. push the sub-process to push the message, and the networked sub-process performs the network connection.
- the terminal can interact with the application process to learn the process function of the application process.
- the process of determining the function weight corresponding to the function of the application process for each application process in multiple application processes, after the terminal determines the process function of each application process, the process function is used as an index to query the process function and the function weight Corresponding relationship, the function weight corresponding to the process function is obtained from the corresponding relationship.
- the corresponding relationship between the process function and the function weight includes multiple functions and corresponding multiple function weights, which can be determined according to experience. For example, the more important the process function is, the larger the function weight is, and the more important the process function is. , the smaller the function weight is set.
- a small function weight can be set for the push function to ensure that the application process of the push function is preferentially recycled.
- the level is higher, which in turn preferentially reclaims the memory of the application process.
- Step 2 According to the user preference of each application process and the function weight of each application process, obtain the recycling priority of each application process.
- the recycling priority is negatively related to the function weight and negatively related to the user preference.
- the product between the user preference and the function weight can be calculated to obtain the recycling priority.
- the accuracy of the reclaimed memory can be further improved: for a plurality of application processes with similar user preferences, if the process function of an application process is less important, it can be considered as The current running activity of the application process is of low importance to the terminal, and the impact of reclaiming the memory of the application process is small.
- the re-prioritization priority is determined by the function weight, the revocation priority of the application process is higher, and the terminal takes precedence. Reclaim the memory of the application process to minimize the overall impact of the reclaimed memory on the terminal.
- Design 3 Combine the user preference with the most recent active duration of the application process to determine the recycling priority of the application process.
- the design may specifically include the following steps 1 to 3:
- Step 1 Determine the most recent active weight of each application process, and the most recent active weight of each application process is used to indicate the extent to which each application process is recently active.
- the specific process for determining the most recent active weights may include the following (1)-(2).
- the terminal can obtain the active time duration of the active time duration recorded by the application process from the current time point to obtain the latest active duration.
- the terminal can obtain the end time point of the most recent active time, obtain the current time point, calculate the time difference between the end time point and the current time point, and attenuate the latest active time length based on the time difference, and use the decayed latest active time length as the most recent active time. Weights.
- the attenuation function can be used to calculate the time difference and the most recent active time, and the calculation result is used as the most recent active weight.
- the time difference can reflect the distance between the latest running process of the application process and the current time point.
- the time difference of an application process is small, it indicates that the application process is the most active application process, and the application can be considered as the application.
- the process is more important to the user at present, and the attenuation is less when the latest active duration is attenuated based on the time difference, so as to ensure that the recent active weight of the application process is large.
- the time difference of the application process is large, it indicates that the application process is an active application process that is active a long time ago. It can be considered that the application process is less important to the user at present, and the attenuation is greater when the latest active time is attenuated based on the time difference. Large to ensure that the most recent active weight of the application process is small.
- Step 2 According to the user preference and the recent active weight of each application process, obtain the recycling priority of each application process.
- the reclaim priority of the application process is negatively correlated with the most recent active weight and is negatively correlated with user preference.
- the product between the user preference and the most recent active weight can be calculated to obtain a recycling priority.
- the accuracy of the reclaimed memory can be further improved: for multiple application processes with similar user preferences, if an application process is the most recent active application process The recent active weight will be larger, so the application process will have lower reclaim priority, which will avoid reclaiming the memory of the application process, so as to avoid affecting the normal operation of the recently active application process. If an application process is an active application process that is active for a long time, the active weight of the application is relatively small. Therefore, the application process has a higher revocation priority, and the memory of the application process is preferentially reclaimed. The application process that was active long ago is preferentially recycled. The occupied memory, on the basis of realizing the recovery of memory, ensures that the overall impact on the operation of the terminal is as small as possible.
- Design 4. Determine the recycling priority based on user preference and power consumption of the application process.
- the design may specifically include the following steps 1 to 2:
- Step 1 Determine the power consumption weight corresponding to the power consumption of each application process.
- Power consumption refers to the power consumption of the application process.
- the terminal can record the power consumption of the application process in real time while the application process is running. In this step, for each application process in multiple application processes, the terminal may obtain the power consumption of the recorded application process in the historical operation, for example, the power consumption of the application process may be obtained, and the application process may be acquired. The power consumption of the last preset number of runs, and the average of the power consumption of the preset number of times is calculated.
- the process of determining the power consumption weight the terminal can use the power consumption as an index, query the correspondence between the power consumption and the power weight, and obtain the power consumption weight corresponding to the power consumption from the corresponding relationship.
- the corresponding relationship between power consumption and power consumption weight includes multiple power consumptions and corresponding multiple power consumption weights. The greater the power consumption, the greater the corresponding power weight, and the corresponding relationship between power consumption and power weight can be It is preset by the developer and can be stored in the terminal in advance.
- Step 2 According to the user preference of each application process and the power consumption weight of each application process, obtain the recycling priority of each application process.
- the recycling priority is positively correlated with the power consumption weight and negatively related to the user preference. Further, the ratio between the user preference and the power consumption weight can be calculated to obtain the recycling priority.
- the following technical effects can be achieved: for a plurality of application processes with similar user preferences, if the power consumption of an application process is greater, the work is performed. If the weight of the application is higher, the subsequent terminal will preferentially reclaim the memory occupied by the application process. By preferentially reclaiming the memory occupied by the application process with high power consumption, the power consumption of the terminal can be saved on the basis of realizing the function of reclaiming memory.
- Design 5 Determine the application process to be recycled in combination with the user preference and the calling frequency of the application process.
- the calling frequency refers to the total number of times the application process calls the application process during the time period in the historical running.
- the design may specifically include the following steps 1 to 3:
- Step 1 Determine the calling frequency of each application process, and the calling frequency of each application process is used to indicate the total number of times that multiple application processes call each application process in the historical running time period.
- the specific process of determining the calling frequency may include the following (1)-(2):
- the terminal acquires a call record of each application process.
- the call record is also called the call list.
- the call record of each application process is used to record the events of each application process in each application process except for each application process in the application process.
- the terminal can be in real time.
- the event record of each application process records the events of the application process calling other application processes. For example, for the application process 1 - application process N, in the call record of the application process 1, the application process 1 is recorded to call the event in the application process 2 - application process N.
- the terminal determines the calling frequency of each application process based on the call record of each application process.
- the terminal can calculate the sum of the number of calls to each application process in the multiple call records as the calling frequency of each application process. For example, for the application process 1, the sum of the number of calls of the application process 2 - the application process N calling the application process 1 can be obtained according to the application process 2 - the call record of the application process N, as the calling frequency of the application process 1.
- Step 2 Obtain the recycling priority of each application process based on the calling frequency of each application process.
- the terminal can adjust the reclaim priority based on the calling frequency.
- the terminal may set the first frequency threshold and the second frequency threshold. After the terminal determines the calling frequency of each application process, it may determine whether the calling frequency is higher than the first calling frequency threshold, when the calling frequency is higher than the first calling frequency threshold.
- the application process is considered to be an application process that is frequently called. Recycling the memory occupied by the application process will have a greater impact on the operation of other application processes, and the application process's recycling priority will be lowered to avoid recycling applications. The memory occupied by the process. Similarly, the terminal can determine whether the calling frequency of the application process is lower than the second frequency threshold.
- the application process When the calling frequency is lower than the second calling frequency threshold, the application process is considered to be an application process that is rarely called, and the application process is recycled. After the memory has less impact on the operation of other application processes, the recycling priority of the application process is increased. In addition, when the calling frequency is not higher than the first frequency threshold and not lower than the second frequency threshold, the terminal may not need to adjust the recycling priority of the application process.
- the first call frequency threshold is used to indicate the lowest value of the calling frequency of the frequently invoked application process, and may be set according to actual requirements.
- the second call frequency threshold is used to indicate the highest value of the calling frequency of the application process that is rarely called, and can be set according to actual needs.
- the terminal can set a preset adjustment value, and the preset adjustment value can be a positive number, and the terminal can calculate the sum of the value of the application process recovery priority and the preset adjustment value, and adjust the sum value as a tune.
- the preset adjustment value may be a positive number greater than 1, and the terminal may calculate the product of the application process recovery priority value and the preset adjustment value, and use the product as the reduction priority after the reduction.
- the terminal can set a preset adjustment value, and the preset adjustment value can be a positive number, and the terminal can calculate the difference between the value of the application process recovery priority and the preset adjustment value, and adjust the difference as a tone.
- the preset adjustment value may be a positive number greater than 1, and the terminal may calculate a ratio of the value of the application process recovery priority to the preset adjustment value, and use the ratio as the recovery priority after the adjustment.
- the above design one to design five can form a method for determining the recycling priority by any combination.
- the terminal when design one is combined with design three, the terminal can obtain the memory weight and the recent active weight, and determine the recycling priority according to the user preference, the memory weight, and the recent active weight.
- the terminal when design one, design two, design three and design four are combined, the terminal can obtain memory weight, function weight, recent active weight and power consumption of the application process, according to user preference, memory weight, function weight The recent active weights and power consumption of the application process determine the recycling priority.
- the terminal determines, according to a recycling priority of each application process, an application process to be reclaimed in multiple application processes.
- the terminal can sort the application processes according to the reclaiming priority.
- the application process with the highest priority is used as the application process to be reclaimed, so as to reclaim the memory occupied by the application process.
- the application process with the second highest priority is continuously used as the application process to be recycled.
- the higher the revocation priority of the application process the earlier the memory occupied by the application process is reclaimed.
- the lower the revocation priority of the application process the later the memory occupied by the application process is reclaimed.
- steps 204-205 are only based on determining the revocation priority based on the user preference, and then determining the application process to be reclaimed based on the reclaiming priority.
- the user preference may also be directly based on the user preference. Determine the application process to be reclaimed. If the user preference of the application process is higher, the application process is avoided as the application process to be reclaimed. If the user preference of the application process is lower, the application process is preferentially considered as to be recycled. Application process.
- the active duration of the application process will be longer, and the user preference corresponding to the active duration will be higher, then Avoid the high-frequency application process as the application process to be recycled, ensure that the data of the high-frequency application process resides in the memory, try to avoid affecting the normal operation of the high-frequency application process, and reduce the cold start probability of the high-frequency application process.
- the process of ensuring the memory recovery is close to the user's personal usage habits: considering that the application process preferred by different users in daily life may be different, for example, user A prefers the application process using the instant messaging application, and user B prefers to use the music playing application.
- the application process, user C prefers to use the application process of the online shopping application, and the like.
- the user preference of the application process is not uniformly set, but the terminal calculates the user preference of each application process in real time by self-learning.
- the user preference of each application process can reflect the user's personal usage habits. Therefore, when the memory is recycled in combination with the user preference, the personalized requirement can be satisfied.
- the probability that the user A's terminal reclaims the application process of the instant messaging application has the smallest probability, and the user has the smallest probability.
- the terminal of B recycles the memory of the application process of the music playing application with the least probability of the memory and the like.
- the process of ensuring the recovery of memory is time-sensitive: considering that the application process preferred by the user can change over time, for example, an application process in which a user prefers to use the Weibo application in the past, and now prefers an application using an instant messaging application. Process, etc.
- the user preference for each application process is not obtained in advance, but each application is calculated in real time according to the active duration of the historical running process of the application process when the terminal reclaims the memory occupied by the application process.
- the user preference of the process that is, the user preference of the self-learning application process, the calculated user preference can be dynamically changed with time, and the order of memory occupied by the application process is recycled each time.
- Dynamic changes for example, when the terminal calculates the user preference last month, the application process of the instant messaging application has the highest user preference, and the probability of reclaiming the memory of the application process of the instant messaging application is the smallest, and the music playing application is calculated when the user preference is calculated this month.
- the application process has the highest user preference, and the probability of reclaiming the memory of the application process of the music playing application is the smallest.
- the terminal reclaims memory occupied by the application process to be recycled.
- the memory occupied by the application process is reclaimed. After the memory occupied by the application process is reclaimed, it is possible to detect whether the free memory meets the preset condition. When the free memory has met the preset condition, the application process to be reclaimed need not be determined again, and the process of reclaiming the memory is terminated. . When the idle memory still does not meet the preset condition, the method provided in this embodiment is used again to continue to determine the application process to be recovered until the idle memory meets the preset condition.
- the terminal in combination with determining the design of the application process to be reclaimed according to the reclaiming priority, the terminal reclaims the application process with the highest priority as the application process to be reclaimed, and after reclaiming the memory occupied by the application process, can detect the free memory again.
- the preset condition is met, the process of reclaiming the memory is not required to determine the application process to be reclaimed.
- the application process with the second highest priority is reclaimed as the application process to be reclaimed, so as to reclaim the memory of the application process with the second highest priority, and so on.
- the terminal can run the LMK process, and the LMK process kills the application process to be recycled.
- the application process is a unit for counting user preference and reclaiming memory.
- the application starts multiple application processes, only one application process of multiple application processes may be killed without killing other applications.
- the application process, and the application can still be running.
- a reading application can open multiple application processes such as a main process, a picture display sub-process, and a text display sub-process.
- the picture display sub-process is preferentially killed due to the lower user preference, and the reading is performed at this time.
- the application can continue to run through the main process, and the text can continue to be displayed through the text display subprocess, only the image can not be displayed temporarily.
- Design 2 Transfer the data in the memory of the application process to be recycled to the preset storage space.
- the terminal can sequentially transfer the data in the memory of each application process to the preset storage space according to the order of the reclaiming priority, so that the memory occupied by the application process in the memory is freed to be occupied by the recycling application process.
- the effect of memory may be.
- the data may be compressed first, and the data volume of the compressed data is reduced, and then the compressed data is transferred to the preset storage space. For example, if an application process stores 50M of data in the memory, You can compress 50M data into 20M, and then store 20M data into the preset storage space, then the memory will be free of 50M space.
- the preset storage space may be a zram partition, and the zram partition is also called a Compcache (compression cache), which refers to a module of the Linux kernel.
- the zram can replace the hard disk with a memory to provide a storage data function for the operating system, and can be used for storage. The data of the compressed application process.
- the terminal can run the kswapd process or the process that requests the memory before, and the process of the in-memory data of each application process is sequentially transferred to the preset storage space by the kswapd process or the process that previously requested the memory.
- FIG. 3 a schematic diagram of a method for reclaiming memory provided by an embodiment of the present disclosure is provided.
- a developer may design a program code for reclaiming a memory process in a module by referring to the architecture of FIG. 3.
- the calculation factors may be divided into four modules according to the attribute, the requirement module includes a memory requirement and a free memory, and the user preference module includes an active duration, a time period, a recent active weight, and a calling frequency, and the application process attribute module includes an application process.
- the memory ratio, cold boot time, and process functions, and the expansion module includes the power consumption of the application process.
- the calculation factor of each module can be divided into five levels according to importance.
- the developer can set the value range of the calculation factor according to the level of the calculation factor. For example, the higher the level of the calculation factor, that is, the stronger the importance, the more can be set.
- the range of values of the calculation factor is higher, and the lower the level of the calculation factor, that is, the weaker the importance, the lower the range of values of the calculation factor can be set.
- the method provided in this embodiment takes the user's usage habits into consideration when reclaiming the memory, determines the application process to be recycled according to the user preference of each application process, and then recovers the memory occupied by the application process. Priority is given to reclaiming memory occupied by application processes with low user preference, avoiding reclaiming memory occupied by application processes with high user preference, ensuring the accuracy and rationality of retrieving the memory of each application process, and avoiding the killing process and The application process data is transferred to the preset storage space by mistake, so as to avoid affecting the normal operation of the application process, and ensuring that the overall impact of the process of reclaiming memory on the operation of the terminal is as small as possible.
- FIG. 4 is a schematic structural diagram of an apparatus for reclaiming memory according to an embodiment of the present disclosure. As shown in FIG. 4, the apparatus includes: a determining module 401 and a recycling module 402.
- the determining module 401 is configured to determine, when the idle memory does not meet the preset condition, determine a plurality of application processes that are running in the background;
- the determining module 401 is further configured to determine a user preference of a time period to which the application process belongs to the current time point in the plurality of application processes, where the user preference is used to indicate a possibility of the application process being invoked;
- the determining module 401 is further configured to determine, according to user preference of each application process in the multiple application processes, an application process to be recycled in the multiple application processes;
- the recycling module 402 is configured to recover the memory occupied by the application process to be recycled.
- the determining module 401 is further configured to: determine, according to an active duration of the time period of each application process in the plurality of application processes, the application duration of the multiple application processes User preference for the time period to which the current time point belongs.
- the determining module 401 is further configured to:
- the ratio of the active duration to the sum of the active durations is calculated as the user preference, and the sum of the active durations is the sum of the active durations of the plurality of application processes in the historical operation;
- the ratio between the active duration and the sum of the active durations is calculated, and the product between the ratio and the cold start duration of the application process is calculated as the user preference.
- the determining module 401 further includes:
- Obtaining a sub-module configured to obtain, according to user preference of each application process in the multiple application processes, a reclaiming priority of each application process, and a reclaiming priority of each application process and a user of each application process Preference is negatively correlated;
- the obtaining sub-module is further configured to determine a recent active weight of each application process, and a recent active weight of each application process is used to indicate a degree of recent activeness of each application process; The user preference of each application process and the most recent active weight of each application process, and the recycling priority of each application process is obtained.
- the obtaining sub-module is further configured to obtain a recent active duration of each application process, where a recent active duration of each application process is used to indicate that each application process is last running in the foreground.
- the active duration based on the time difference between the end time point of the latest active duration of each application process and the current time point, attenuating the most recent active duration of each application process to obtain the most recent active duration after the attenuation,
- the most recent active time after decay is used as the most recent active weight.
- the obtaining sub-module is further configured to: determine a function weight corresponding to a function of each application process, where a function weight of each application process is used to indicate a function of each application process The degree of importance; according to the user preference of each application process and the functional weight of each application process, the recycling priority of each application process is obtained.
- the obtaining sub-module is further configured to: determine a power consumption weight corresponding to the power consumption of each application process, and the power consumption weight of each application process is used to indicate the each application process The size of the power consumption; according to the user preference of each application process and the power consumption weight of each application process, the recycling priority of each application process is obtained.
- the obtaining submodule is further configured to: determine a memory ratio weight corresponding to a memory ratio of each application process, and a memory ratio of each application process is used to indicate each of the The ratio of the memory occupied by the application process to the total memory cost; and the reclaiming priority of each application process is obtained according to the user preference of each application process and the memory weight of each application process.
- the obtaining sub-module is further configured to: determine a calling frequency of each application process, and the calling frequency of each application process is used to indicate that the multiple application processes are in the historical running time period The total number of times each application process is invoked; the revocation priority of each application process is obtained according to the user preference of each application process and the calling frequency of each application process.
- the obtaining sub-module is further configured to: obtain a call record of each application process, and the calling record of each application process is used to record that each application process calls the multiple application processes. An event of an application process other than each application process; determining a calling frequency of each application process based on the invocation record of each application process.
- the device further includes: a statistics module, configured to count an active duration of the time period of each application process in the plurality of application processes in the historical operation.
- the recovery module 402 is configured to kill the application process to be recycled; or transfer the data in the memory of the application process to be recycled to the preset storage space.
- the unit and method processes of the examples described in the embodiments of the present application can be implemented by electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the solution. The skilled person can use different methods for each particular application to implement the described functionality.
- the disclosed apparatus and method may be implemented in other manners.
- the device embodiments described above are merely illustrative.
- the division of the unit is only a logical function division, and the actual implementation may have another division manner.
- multiple units or components may be combined or integrated into another system, or some steps may be omitted or not performed.
- the coupling or direct coupling or communication connection of the various units to each other may be through some interfaces, which may be in electrical, mechanical or other form.
- the units described as separate components may or may not be physically separate, and may be located in one place or on multiple network elements.
- each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
- the above embodiments it may be implemented in whole or in part by software, hardware, firmware, or any combination thereof.
- software it may be implemented in whole or in part in the form of a computer program product.
- the computer program product includes one or more computer instructions.
- the computer program instructions When the computer program instructions are loaded and executed on a computer, the processes or functions described in accordance with embodiments of the present invention are generated in whole or in part.
- the computer can be a general purpose computer, a special purpose computer, a computer network, or other programmable device.
- the computer instructions can be stored in a computer readable storage medium or transferred from one computer readable storage medium to another computer readable storage medium, for example, the computer instructions can be from a website site, computer, server or data center Transfer to another website site, computer, server, or data center by wire (eg, coaxial cable, fiber optic, digital subscriber line (DSL), or wireless (eg, infrared, wireless, microwave, etc.).
- the computer readable storage medium can be any available media that can be accessed by a computer or a data storage device such as a server, data center, or the like that includes one or more available media.
- the usable medium may be a magnetic medium (eg, a floppy disk, a hard disk, a magnetic tape), an optical medium (eg, a DVD), or a semiconductor medium (such as a solid state disk (SSD)).
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Stored Programmes (AREA)
Abstract
Provided by the present disclosure are a method and device for reclaiming memory, belonging to the technical field of terminals. Said method comprises: determining a plurality of application processes running in the background when detecting that free memory does not satisfy a preset condition; determining a user preference for each application process in said plurality of application processes in a time period to which a current time point belongs, said user preference being used to indicate the possibility of the application process being called; determining an application process to be reclaimed in said plurality of application processes according to the user preference for each application process in said plurality of application processes; and reclaiming memory occupied by said application process to be reclaimed. The present disclosure takes into account usage habits of a user when reclaiming memory and ensures that the overall impact of the process of reclaiming memory on the operation of a terminal is as small as possible.
Description
本申请要求于2018年1月10日提交中国国家知识产权局、申请号为201810022138.X发明名称为“回收内存的方法及装置”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims priority to Chinese Patent Application No. 201 810 022 138.X, entitled "Recovering Memory Method and Apparatus", issued on January 10, 2018, the entire contents of which are incorporated herein by reference. In the application.
本公开涉及终端技术领域,特别涉及一种回收内存的方法及装置。The present disclosure relates to the field of terminal technologies, and in particular, to a method and an apparatus for reclaiming memory.
随着终端技术的发展,终端可以运行各种各样的进程,进程可以为操作系统的系统进程以及应用的应用进程,其中每个进程在运行过程中会占用一定的内存,在内存中存储自身的数据。随着终端的运行,运行的进程越来越多,占用的内存会越来越多,空闲内存会越来越少,当终端面临空闲内存不满足内存需求的情况时,需要对进程占用的内存进行回收,以保证终端的空闲内存满足内存需求。With the development of the terminal technology, the terminal can run various processes, and the process can be the system process of the operating system and the application process of the application, wherein each process occupies a certain amount of memory during the running process, and stores itself in the memory. The data. As the terminal runs, more and more processes are running, more and more memory is occupied, and free memory is less and less. When the terminal faces the situation that the free memory does not satisfy the memory requirement, the memory occupied by the process is required. Recycling is performed to ensure that the free memory of the terminal meets the memory requirements.
以低内存回收(Low Memory Killer,LMK)进程执行回收内存的过程为例,回收内存的过程具体为:LMK进程获取当前每个进程的oom_adj,并获取每个进程占用的内存,其中,oom_adj用于指示进程的优先级,om_adj值越高代表该进程优先级越低,然后根据每个进程的oom_adj和占用的内存,对每个进程打分,得到每个进程的分值。之后,根据每个进程的分值确定要杀死的进程,进程的分值越大,越优先杀死该进程,杀死进程后其关联的进程会关闭,该进程占用的内存会释放,从而回收了该进程占用的内存。其中,oom_adj的取值固定,例如当进程为后台进程时,oom_adj为2,当进程为原生进程时,oom_adj为-17,oom_adj值越大,进程的分值越高,另外,进程占用的内存越大,进程的分值也会越高。Taking the process of reclaiming memory by the Low Memory Killer (LMK) process as an example, the process of reclaiming memory is specifically as follows: the LMK process acquires the current oom_adj of each process, and acquires the memory occupied by each process, wherein oom_adj uses To indicate the priority of the process, the higher the om_adj value, the lower the priority of the process. Then, according to the oom_adj and occupied memory of each process, each process is scored to obtain the score of each process. After that, according to the score of each process, the process to be killed is determined. The greater the score of the process, the higher the priority is to kill the process. After the process is killed, the associated process is closed, and the memory occupied by the process is released. The memory occupied by the process is reclaimed. Among them, the value of oom_adj is fixed. For example, when the process is a background process, oom_adj is 2. When the process is a native process, oom_adj is -17, the larger the oom_adj value, the higher the score of the process, and the memory occupied by the process. The larger the score, the higher the score of the process.
在实现本公开的过程中,发明人发现相关技术至少存在以下问题:In the process of implementing the present disclosure, the inventors have found that the related art has at least the following problems:
上述方案回收内存时,仅考虑了进程的oom_adj以及进程占用的内存,容易误杀进程,影响进程的正常运行。When the above solution reclaims memory, only the oom_adj of the process and the memory occupied by the process are considered, and it is easy to kill the process and affect the normal operation of the process.
发明内容Summary of the invention
本公开实施例提供了一种回收内存的方法及装置,能够解决相关技术中容易误杀进程的问题。所述技术方案如下:The embodiments of the present disclosure provide a method and an apparatus for reclaiming memory, which can solve the problem of easy to kill the process in the related art. The technical solution is as follows:
第一方面,提供了一种回收内存的方法,所述方法包括:In a first aspect, a method of reclaiming memory is provided, the method comprising:
在检测到空闲内存不满足预设条件时,确定处于后台运行的多个应用进程;Determining a plurality of application processes running in the background when detecting that the free memory does not satisfy the preset condition;
确定所述多个应用进程中每个应用进程在当前时间点所属的时间段的用户偏好度,所述用户偏好度用于指示应用进程被调用的可能性大小;Determining a user preference of a time period to which each application process in the plurality of application processes belongs at a current time point, the user preference being used to indicate a possibility of an application process being invoked;
根据所述多个应用进程中每个应用进程的用户偏好度,确定所述多个应用进程中待回收的应用进程;Determining, according to a user preference of each application process in the multiple application processes, an application process to be recycled in the multiple application processes;
回收所述待回收的应用进程占用的内存。Reclaiming the memory occupied by the application process to be recycled.
本实施例提供的方法,在回收内存时考虑到了用户的使用习惯,结合每个应用进程的用户偏好度确定待回收的应用进程,进而回收待回收的应用进程所占用的内存,优先回收用户偏好度较低的应用进程所占用的内存,避免回收用户偏好度较高的应用进程所占用的内存,保证回收各个应用进程的内存时顺序的准确性以及合理性,避免误杀进程以及误将应用进程的数据转移至预设存储空间的情况,从而避免影响应用进程的正常运行,保证回收内存的过程对终端的运行造成的整体影响尽量小。The method provided in this embodiment takes the user's usage habits into consideration when reclaiming the memory, determines the application process to be recycled according to the user preference of each application process, and then recovers the memory occupied by the application process to be recycled, and preferentially recycles the user preference. The memory occupied by the lower application process avoids reclaiming the memory occupied by the application process with high user preference, ensuring the accuracy and rationality of retrieving the memory of each application process, avoiding the killing process and the application process. The data is transferred to the preset storage space, so as to avoid affecting the normal operation of the application process, and ensuring that the overall impact of the process of reclaiming the memory on the operation of the terminal is as small as possible.
在一种可能的设计中,所述确定所述多个应用进程中每个应用进程在当前时间点所属的时间段的用户偏好度,包括:In a possible design, the determining the user preference of each of the plurality of application processes in the time period to which the current application point belongs includes:
根据所述多个应用进程中每个应用进程在历史运行中所述时间段的活跃时长,确定所述多个应用进程中每个应用进程在当前时间点所属的时间段的用户偏好度。And determining, according to the active duration of the time period of each application process in the historical operation, the user preference of each application process in the plurality of application processes at a time period to which the current time point belongs.
基于本设计,保证回收内存的过程具有时效性:考虑到用户所偏好的应用进程可以随着时间的推移发生变化,例如某用户过去偏好使用微博应用的应用进程,现在偏好使用即时通信应用的应用进程等。本实施例中,并非预先获取了用户对每个应用进程的用户偏好度,而是由终端在回收应用进程占用的内存时,实时根据应用进程最近在历史运行的活跃时长来计算出每个应用进程的用户偏好度,也即是,动态地自学习应用进程的用户偏好度,每次计算出的用户偏好度可以随着时间进行动态变化,则每次回收应用进程占用的内存的顺序也会进行动态变化,例如终端上个月计算用户偏好度时即时通信应用的应用进程的用户偏好度最高,则回收即时通信应用的应用进程的内存的概率最小,这个月计算用户偏好度时音乐播放应用的应用进程的用户偏好度最高,则回收音乐播放应用的应用进程的内存的概率最小。Based on this design, the process of ensuring the memory recovery is time-sensitive: considering that the application process preferred by the user can change over time, for example, a user prefers to use the application process of the Weibo application in the past, and now prefers to use the instant messaging application. Application process, etc. In this embodiment, the user preference for each application process is not obtained in advance, but each application is calculated in real time according to the active duration of the historical running process of the application process when the terminal reclaims the memory occupied by the application process. The user preference of the process, that is, the user preference of the self-learning application process, the calculated user preference can be dynamically changed with time, and the order of memory occupied by the application process is recycled each time. Dynamic changes, for example, when the terminal calculates the user preference last month, the application process of the instant messaging application has the highest user preference, and the probability of reclaiming the memory of the application process of the instant messaging application is the smallest, and the music playing application is calculated when the user preference is calculated this month. The application process has the highest user preference, and the probability of reclaiming the memory of the application process of the music playing application is the smallest.
在一种可能的设计中,所述根据所述多个应用进程中每个应用进程在历史运行中所述时间段的活跃时长,确定所述多个应用进程中每个应用进程在当前时间点所属的时间段的用户偏好度,包括:In a possible design, determining, according to the active duration of the time period of each application process in the historical operation, the application time of each application process in the multiple application processes at the current time point User preference for the time period to which it belongs, including:
将所述活跃时长作为所述用户偏好度。The active duration is taken as the user preference.
在这种设计中,终端可以简单有效地得到用户偏好度。In this design, the terminal can obtain user preference simply and efficiently.
或,计算所述活跃时长与活跃时长总和之间的比值,作为所述用户偏好度,所述活跃时长总和是指所述多个应用进程在历史运行中所述时间段的活跃时长的和值。Or calculating a ratio of the active duration to the sum of the active durations, where the sum of the active durations is the sum of the active durations of the plurality of application processes in the historical operation. .
在这种设计中,终端可以保证用户偏好度处于合理的数值范围内。In this design, the terminal can ensure that the user's preference is within a reasonable range of values.
或,计算所述活跃时长与所述应用进程的冷启动时长之间的乘积,作为所述用户偏好度;Or calculating a product between the active duration and the cold start duration of the application process as the user preference;
在这种设计中,在准确地回收应用进程占用的内存的基础上,兼顾了每个应用进程的冷启动时长,尽量减少对终端造成的整体影响。In this design, on the basis of accurately recovering the memory occupied by the application process, the cold boot duration of each application process is taken into consideration, and the overall impact on the terminal is minimized.
或,计算所述活跃时长与活跃时长总和之间的比值,以及计算所述比值与所述应用进程的冷启动时长之间的乘积,作为所述用户偏好度。Or calculating a ratio between the active duration and the sum of the active durations, and calculating a product between the ratio and the cold start duration of the application process as the user preference.
在这种设计中,在提供了准确获取用户偏好度的方式的基础上,能够保证用户偏好度处于合理的数值范围内,同时兼顾了应用进程的冷启动时长,保证回收应用进程占用的内存时对终端的整体影响尽量小。In this design, on the basis of providing a way to accurately obtain the user's preference, the user's preference can be guaranteed to be within a reasonable numerical range, and the cold start time of the application process is taken into account, and the memory occupied by the application process is guaranteed to be recovered. The overall impact on the terminal is as small as possible.
在一种可能的设计中,所述根据所述多个应用进程中每个应用进程的用户偏好度,确定所述多个应用进程中待回收的应用进程,包括:In a possible design, the determining, according to the user preference of each application process in the multiple application processes, the application process to be reclaimed in the multiple application processes, including:
基于所述多个应用进程中每个应用进程的用户偏好度,获取所述每个应用进程的回收优先级,所述每个应用进程的回收优先级与所述每个应用进程的用户偏好度负相关;Retrieving a revocation priority of each application process based on a user preference of each application process in the plurality of application processes, a reclaiming priority of each application process, and a user preference of each application process Negative correlation
基于所述每个应用进程的回收优先级,确定所述多个应用进程中待回收的应用进程。Determining an application process to be reclaimed among the plurality of application processes based on a recycling priority of each application process.
在一种可能的设计中,所述基于所述多个应用进程中每个应用进程的用户偏好度,获取所述每个应用进程的回收优先级,包括:In a possible design, the obtaining, according to the user preference of each application process in the multiple application processes, the reclaiming priority of each application process, including:
确定所述每个应用进程的最近活跃权重,所述每个应用进程的最近活跃权重用于指示所述每个应用进程最近活跃的程度;Determining a recent active weight of each application process, the most recent active weight of each application process is used to indicate a degree of recent activeness of each application process;
根据所述每个应用进程的用户偏好度与所述每个应用进程的最近活跃权重,获取所述每个应用进程的回收优先级。Retrieving the revocation priority of each application process according to the user preference of each application process and the most recent active weight of each application process.
在一种可能的设计中,所述确定所述每个应用进程的最近活跃权重,包括:In a possible design, the determining the most recent active weight of each application process includes:
获取所述每个应用进程的最近活跃时长,所述每个应用进程的最近活跃时长用于指示所述每个应用进程最近一次处于前台运行的活跃时长;Obtaining the latest active duration of each application process, where the latest active duration of each application process is used to indicate the active duration of the last time each application process is running in the foreground;
基于所述每个应用进程的最近活跃时长的结束时间点与所述当前时间点之间的时间差,对所述每个应用进程的最近活跃时长进行衰减以得到衰减后的最近活跃时长,将所述衰减后的最近活跃时长作为所述最近活跃权重。And attenuating the most recent active duration of each application process to obtain the most recent active duration after the attenuation based on the time difference between the end time point of the most recent active duration of the each application process and the current time point. The most recent active duration after the decay is used as the most recent active weight.
本设计中,通过结合用户偏好度和应用进程的最近活跃权重确定回收优先级,可以进一步提高回收内存的准确性:对于用户偏好度接近的多个应用进程来说,若某个应用进程是最近活跃的应用进程,最近活跃权重会较大,则回收优先级会较低,能避免回收该应用进程的内存,从而尽量避免影响最近活跃的应用进程的正常运行。若某个应用进程是很久之前活跃的应用进程,则最近活跃权重较小,则回收优先级会较高,会优先回收该应用进程的内存,通过优先回收很久以前活跃的应用进程所占用的内存,在实现回收内存的基础上,保证对终端运行的整体影响尽量小。In this design, by determining the recycling priority by combining the user preference and the recent active weight of the application process, the accuracy of the reclaimed memory can be further improved: for a plurality of application processes whose user preference is close, if an application process is the most recent If the active application process has a large active weight, the revocation priority will be lower, and the memory of the application process can be avoided, so as to avoid affecting the normal operation of the recently active application process. If an application process is an active application process that is active for a long time, if the recent active weight is small, the reclaim priority will be higher, and the memory of the application process will be reclaimed preferentially, and the memory occupied by the active application process long ago is preferentially reclaimed. On the basis of realizing the recovery of memory, the overall impact on the operation of the terminal is guaranteed to be as small as possible.
在一种可能的设计中,所述基于所述多个应用进程中每个应用进程的用户偏好度,获取所述每个应用进程的回收优先级,包括:In a possible design, the obtaining, according to the user preference of each application process in the multiple application processes, the reclaiming priority of each application process, including:
确定与所述每个应用进程的功能对应的功能权重,所述每个应用进程的功能权重用于指示所述每个应用进程的功能的重要程度;Determining a function weight corresponding to the function of each application process, the function weight of each application process is used to indicate the importance degree of the function of each application process;
根据所述每个应用进程的用户偏好度与所述每个应用进程的功能权重,获取所述每个应用进程的回收优先级。Retrieving the revocation priority of each application process according to the user preference of each application process and the function weight of each application process.
本设计中,通过结合用户偏好度和功能权重确定回收优先级,可以进一步提高回收内存的准确性:对于用户偏好度接近的多个应用进程来说,若某个应用进程的进程功能较为次要,可以认为该应用进程当前的运行活动对于终端的重要性低,回收该应用进程的内存时造成的影响较小,而结合功能权重确定回收优先级时,回收优先级会较高,终端会优先回收该应用进程的内存,从而尽量减少回收内存对终端造成的整体影响。In this design, by combining user preference and function weight to determine the reclaim priority, the accuracy of reclaiming memory can be further improved: for multiple application processes with similar user preferences, if the process function of an application process is less important It can be considered that the current running activity of the application process is of low importance to the terminal, and the impact of reclaiming the memory of the application process is small, and when the function weight is determined to determine the recycling priority, the recycling priority is higher, and the terminal takes precedence. Reclaim the memory of the application process to minimize the overall impact of the reclaimed memory on the terminal.
在一种可能的设计中,所述基于所述多个应用进程中每个应用进程的用户偏好度,获取所述每个应用进程的回收优先级,包括:In a possible design, the obtaining, according to the user preference of each application process in the multiple application processes, the reclaiming priority of each application process, including:
确定与所述每个应用进程的功耗对应的功耗权重,所述每个应用进程的功耗权重用于指示所述每个应用进程的功耗的大小;Determining power consumption weights corresponding to power consumption of each application process, the power consumption weight of each application process is used to indicate a size of power consumption of each application process;
根据所述每个应用进程的用户偏好度与所述每个应用进程的功耗权重,获取所述每个应用进程的回收优先级。Retrieving the revocation priority of each application process according to the user preference of each application process and the power consumption weight of each application process.
本设计中,通过结合用户偏好度和应用进程的功耗确定回收优先级,可以达到以下技术效果:对于用户偏好度接近的多个应用进程来说,若某个应用进程的功耗越大,则功耗权重越大,回收优先级会越高,则终端会优先回收该应用进程占用的内存。通过优先回收功耗大的应用进程占用的内存,在实现回收内存功能的基础上,能够节约终端的功耗。In this design, by combining the user preference with the power consumption of the application process to determine the recycling priority, the following technical effects can be achieved: for a plurality of application processes with similar user preferences, if the power consumption of an application process is greater, The greater the power consumption weight, the higher the reclaim priority, and the terminal will preferentially reclaim the memory occupied by the application process. By preferentially reclaiming the memory occupied by the application process with high power consumption, the power consumption of the terminal can be saved on the basis of realizing the function of reclaiming memory.
在一种可能的设计中,所述基于所述多个应用进程中每个应用进程的用户偏好度,获取所述每个应用进程的回收优先级,包括:In a possible design, the obtaining, according to the user preference of each application process in the multiple application processes, the reclaiming priority of each application process, including:
确定与所述每个应用进程的内存占比对应的内存占比权重,所述每个应用进程的内存占比用于指示所述每个应用进程占用的内存与总内存开销之间的比值;Determining a memory ratio corresponding to a memory ratio of each application process, where a memory ratio of each application process is used to indicate a ratio between a memory occupied by each application process and a total memory overhead;
根据所述每个应用进程的用户偏好度与所述每个应用进程的内存占比权重,获取所述每个应用进程的回收优先级。Retrieving the revocation priority of each application process according to the user preference of each application process and the memory weight of each application process.
本设计中,通过结合用户偏好度和应用进程的内存占比确定回收优先级,可以进一步提高回收内存的准确性:对于用户偏好度接近的多个应用进程来说,假设某应用进程的内存占比较大,则内存占比权重较大,回收优先级会越高,因此会优先回收该应用进程的内存,能够保证回收的内存较多,保证空闲内存尽量快地满足内存需求。In this design, by determining the reclaim priority by combining the user preference with the memory ratio of the application process, the accuracy of the reclaimed memory can be further improved: for a plurality of application processes with similar user preferences, it is assumed that the memory of an application process accounts for If the memory size is larger, the memory weight will be larger, and the recycling priority will be higher. Therefore, the memory of the application process will be reclaimed preferentially, and the memory that is recovered will be guaranteed to ensure that the free memory satisfies the memory requirement as quickly as possible.
在一种可能的设计中,所述基于所述多个应用进程中每个应用进程的用户偏好度,获取所述每个应用进程的回收优先级,包括:In a possible design, the obtaining, according to the user preference of each application process in the multiple application processes, the reclaiming priority of each application process, including:
确定所述每个应用进程的调用频率,所述每个应用进程的调用频率用于指示所述多个应用进程在历史运行中所述时间段内调用所述每个应用进程的总次数;Determining a frequency of invocation of each application process, the calling frequency of each application process is used to indicate the total number of times the plurality of application processes invoke the each application process in the time period in the historical operation;
根据所述每个应用进程的用户偏好度与所述每个应用进程的调用频率,获取所述每个应用进程的回收优先级。Retrieving the revocation priority of each application process according to the user preference of each application process and the calling frequency of each application process.
在一种可能的设计中,所述确定所述每个应用进程的调用频率,包括:In a possible design, the determining the calling frequency of each application process includes:
获取所述每个应用进程的调用记录,所述每个应用进程的调用记录用于记录所述每个应用进程调用所述多个应用进程中所述每个应用进程以外的应用进程的事件;Obtaining a call record of each application process, where the call record of each application process is used to record an event of each application process calling an application process other than each of the plurality of application processes;
基于所述每个应用进程的调用记录,确定所述每个应用进程的调用频率。Determining the calling frequency of each application process based on the call record of each application process.
本设计中,通过结合用户偏好度和应用进程的调用频率确定回收优先级,能够保证被频繁调用的应用进程的回收顺序靠后,回收优先级会越低,从而尽量避免回收被频繁调用的应用进程时导致的对其他应用进程的运行造成影响。In this design, by combining the user preference and the calling frequency of the application process to determine the recycling priority, it can ensure that the recycling process of the frequently called application process is lower, and the recycling priority will be lower, thereby avoiding recycling the frequently called application. Process-induced effects on the operation of other application processes.
在一种可能的设计中,所述确定处于后台运行的多个应用进程之前,所述方法还包括:In a possible design, before the determining that the plurality of application processes are running in the background, the method further includes:
统计所述多个应用进程中每个应用进程在历史运行中所述时间段的活跃时长。Counting the active duration of the time period of each application process in the plurality of application processes during the historical operation.
基于本设计,保证回收内存的过程贴近用户的个人使用习惯:考虑到日常生活中不同用户所偏好使用的应用进程可能不同,例如用户A偏好使用即时通信应用的应用进程,用户B偏好使用音乐播放应用的应用进程,用户C偏好使用在线购物应用的应用进程等。本实施例中,并非统一地设置了所有用户对应用进程的用户偏好度,而是由终端以自学习的方式,实时统计每个应用进程的活跃时长来分析出每个应用进程的用户偏好度,每个应用进程的用户偏好度能够反映用户的个人使用习惯,因此结合用户偏好度回收内存时能够满足个性化需求,例如用户A的终端回收即时通信应用的应用进程的内存的概率最小,用户B的终端回收音乐播放应用的应用进程的内存的概率最小等等。Based on this design, the process of ensuring the memory recovery is close to the user's personal usage habits: considering that the application process preferred by different users in daily life may be different, for example, user A prefers the application process using the instant messaging application, and user B prefers to use music to play. The application process of the application, user C prefers to use the application process of the online shopping application, and the like. In this embodiment, the user preference of the application process is not uniformly set, but the terminal calculates the user preference of each application process in real time by self-learning. The user preference of each application process can reflect the user's personal usage habits. Therefore, when the memory is recycled in combination with the user preference, the personalized requirement can be satisfied. For example, the probability that the user A's terminal reclaims the application process of the instant messaging application has the smallest probability, and the user has the smallest probability. The terminal of B recycles the memory of the application process of the music playing application with the least probability of the memory and the like.
在一种可能的设计中,所述回收所述待回收的应用进程占用的内存,包括:In a possible design, the recovering the memory occupied by the application process to be recycled includes:
杀死所述待回收的应用进程;或,Killing the application process to be recycled; or,
将所述待回收的应用进程在内存中的数据转移至预设存储空间。Transfer the data in the memory of the application process to be recycled to a preset storage space.
第二方面,提供了一种回收内存的装置,所述装置包括多个功能模块,以实现上述第一方面以及第一方面的任一种可能设计中的回收内存的方法。In a second aspect, there is provided an apparatus for reclaiming memory, the apparatus comprising a plurality of functional modules to implement the method of reclaiming memory in the first aspect and any of the possible designs of the first aspect.
第三方面,提供了一种回收内存的装置,所述回收内存的装置包括:In a third aspect, an apparatus for reclaiming memory is provided, and the apparatus for reclaiming memory includes:
存储器,用于存储程序;Memory for storing programs;
处理器,用于执行所述存储器存储的所述程序,当所述程序被执行时,所述处理器用于执行如上述第一方面以及第一方面的任一种可能设计中的回收内存的方法。a processor, configured to execute the program stored in the memory, when the program is executed, the processor is configured to perform the method of reclaiming memory in any of the possible aspects of the first aspect and the first aspect described above .
第四方面,提供了一种计算机可读存储介质,包括指令,当其在计算机上运行时,使得计算机执行如上述第一方面以及第一方面的任一种可能设计中的回收内存的方法。In a fourth aspect, a computer readable storage medium is provided, comprising instructions, when executed on a computer, causing the computer to perform the method of reclaiming memory in any of the possible aspects of the first aspect and the first aspect described above.
图1是本公开实施例提供的一种回收内存的装置的结构示意图;FIG. 1 is a schematic structural diagram of an apparatus for recycling a memory according to an embodiment of the present disclosure;
图2是本公开实施例提供的一种回收内存的方法的流程图;2 is a flowchart of a method for reclaiming memory provided by an embodiment of the present disclosure;
图3是本公开实施例提供的一种回收内存的方法的设计示意图;3 is a schematic diagram of a design of a method for reclaiming memory provided by an embodiment of the present disclosure;
图4是本公开实施例提供的一种回收内存的装置的结构示意图。FIG. 4 is a schematic structural diagram of an apparatus for reclaiming memory provided by an embodiment of the present disclosure.
为使本公开的目的、技术方案和优点更加清楚,下面将结合附图对本公开实施方式作进一步地详细描述。The embodiments of the present disclosure will be further described in detail below with reference to the accompanying drawings.
为了方便理解,下面先对本公开实施例中涉及的名词进行解释:For ease of understanding, the nouns involved in the embodiments of the present disclosure are first explained below:
冷启动:在启动应用时,若后台没有应用的主进程,则终端会创建一个进程并将进程分配给该应用,由该进程作为该应用的主进程,进而启动该应用,这种启动应用的方式称为冷启动。在终端开机后第一次启动应用的场景中,或在之前杀死了应用的主进程后再次启动应用的场景中,应用会以冷启动的方式启动。冷启动应用时,终端要从磁盘读取应用的数据,再将应用的数据写入到内存中,再从内存中加载数据,才能基于数据启动应用,由于将数据从磁盘交换到内存所耗费的时长通常较长,因此冷启动时长通常较长。Cold boot: When the application is started, if there is no main process applied in the background, the terminal creates a process and assigns the process to the application, which is the main process of the application, and then starts the application. The way is called cold start. In the scenario where the application is started for the first time after the terminal is powered on, or in the scenario where the application is restarted after the main process of the application is killed, the application is started in a cold boot manner. When the application is cold-started, the terminal needs to read the application data from the disk, then write the application data into the memory, and then load the data from the memory to start the application based on the data, because the data is exchanged from the disk to the memory. The duration is usually longer, so the cold start is usually longer.
热启动:在启动应用时,若后台已有应用关联的主进程,则终端会直接采用该主进程启动应用,这种启动应用的方式称为热启动。在终端开机后已经启动了应用,之后将该应用进程切换为后台运行,再重新将该应用切换为前台运行的场景中,应用会以热启动的方式启动。热启动应用时,终端直接从内存中加载数据即可启动应用,而无需重新将应用的数据从磁盘交换到内存中,因此热启动时长通常较短。Hot start: When the application is started, if there is a main process associated with the application in the background, the terminal will directly start the application by using the main process. This method of starting the application is called hot start. After the terminal is powered on, the application is started, and then the application process is switched to run in the background. Then, the application is switched to the foreground running scenario, and the application is started in a warm boot mode. When the application is warm-started, the terminal can start the application by directly loading data from the memory without re-switching the application's data from disk to memory, so the warm boot time is usually shorter.
低内存回收(Low Memory Killer,LMK)机制:是Linux操作系统的一种内存保护机制,LMK进程会检测终端的空闲内存,当空闲内存小于内存阈值时,获取当前每个进程的oom_adj,并获取每个进程占用的内存,根据每个进程的oom_adj和占用的内存,对每个进程打分,得到每个进程的分值(oom_score_adj),根据每个进程的分值依次杀死每个进程,已回收进程占用的空闲内存,直到空闲内存不小于内存阈值。Low Memory Killer (LMK) mechanism: It is a memory protection mechanism of the Linux operating system. The LMK process detects the free memory of the terminal. When the free memory is less than the memory threshold, it acquires the current oom_adj of each process and obtains The memory occupied by each process, according to the oom_adj of each process and the occupied memory, score each process, get the score of each process (oom_score_adj), kill each process in turn according to the score of each process, Reclaim free memory occupied by the process until the free memory is not less than the memory threshold.
kswapd进程机制:为Linux操作系统中的一种内存保护机制,kswapd进程又称页面交换守护进程,同样会检测终端的空闲内存,当空闲内存小于内存阈值时,kswapd进程会扫 描内存中已存储数据的每个内存页,当内存页的访问次数较少或者存储时间较早时,会将内存页中的数据转移至zram分区(一种存储空间)中,从而将内存空闲出来,直至空闲内存不小于内存阈值。Kswapd process mechanism: A memory protection mechanism in the Linux operating system. The kswapd process, also known as the page swapping daemon, also detects the free memory of the terminal. When the free memory is less than the memory threshold, the kswapd process scans the stored data in the memory. Each memory page, when the number of memory pages is accessed less or the storage time is earlier, the data in the memory page is transferred to the zram partition (a kind of storage space), thereby freeing the memory until the free memory is not Less than the memory threshold.
内存直接回收(Direct reclaim)机制:为Linux操作系统中的一种内存保护机制,当某进程向操作系统请求内存,而请求的内存超过当前的空闲内存时,该进程会扫描内存中已存储数据的每个内存页,当内存页的访问次数较少或者存储时间较早时,会将内存页中的数据转移至zram分区中,从而将内存空闲出来,直至空闲内存不小于请求的内存。Direct reclaim mechanism: A memory protection mechanism in the Linux operating system. When a process requests memory from the operating system and the requested memory exceeds the current free memory, the process scans the stored data in the memory. Each memory page, when the number of memory pages is accessed less frequently or stored earlier, will transfer the data in the memory page to the zram partition, thereby freeing the memory until the free memory is not less than the requested memory.
用户偏好度:用于指示应用进程被调用的可能性大小。应用进程可以由用户或者其他应用进程调用,用户偏好度越高,指示应用被调用的可能性越大,用户偏好度越低,指示应用被调用的可能性越小,用户偏好度能够表征用户对应用进程的偏好程度。对于任一应用进程来说,该应用进程在当前时间点所属的时间段的用户偏好度根据应用进程在历史运行中该时间段的活跃时长确定,例如,假设当前时间点为9:10,所属的时间段为9:00-10:00,则应用进程的用户偏好度根据历史运行中9:00-10:00的活跃时长确定,例如根据应用进程在昨天的9:00-10:00的活跃时长确定,根据应用进程在上个月9:00-10:00的活跃时长确定等。User Preference: Used to indicate the likelihood of an application process being called. The application process can be called by the user or other application process. The higher the user preference, the greater the possibility that the application is called. The lower the user preference, the less likely the application is called. The user preference can represent the user. The degree of preference for the application process. For any application process, the user preference of the application process at the current time point is determined according to the active duration of the time period of the application process in the historical operation, for example, assuming that the current time point is 9:10, belonging to The time period is from 9:00 to 10:00, and the user preference of the application process is determined according to the active duration of 9:00-10:00 in the historical operation, for example, according to the application process at yesterday's 9:00-10:00. The active duration is determined, based on the active duration of the application process from 9:00 to 10:00 last month.
回收优先级:与用户偏好度负相关,用于表征回收内存时的优先程度,应用进程的回收优先级高,则回收应用进程占用的内存的顺序越靠前,应用进程的回收优先级低,则回收应用进程占用的内存的顺序越靠后。Recycling priority: negatively related to user preference. It is used to represent the priority when reclaiming memory. The revocation priority of the application process is high. The higher the order of memory used by the reclaiming application process, the lower the revocation priority of the application process. The later the memory usage of the application process is recycled.
图1是本公开实施例提供的一种回收内存的装置的结构示意图,参见图1,该回收内存的装置包括:接收器101、发射器102、存储器103和处理器104,该接收器101、该发射器102和该存储器103分别与该处理器104连接,该存储器103存储程序,该处理器104用于执行存储器103存储的程序,当该程序被执行时,处理器104用于执行下述回收内存的方法。1 is a schematic structural diagram of an apparatus for reclaiming memory according to an embodiment of the present disclosure. Referring to FIG. 1, the apparatus for reclaiming memory includes: a receiver 101, a transmitter 102, a memory 103, and a processor 104. The receiver 101, The transmitter 102 and the memory 103 are respectively connected to the processor 104. The memory 103 stores a program for executing a program stored in the memory 103. When the program is executed, the processor 104 is configured to execute the following. The method of recycling memory.
在示例性实施例中,还提供了一种计算机可读存储介质,该计算机可读存储介质包括指令,例如包括指令的存储器,当指令在计算机上运行时,使得计算机可以执行如下述实施例中的回收内存的方法。例如,该计算机可读存储介质可以是只读存储器(Read-Only Memory,ROM)、随机存取存储器(Random Access Memory,RAM)、CD-ROM、磁带、软盘和光数据存储设备等。In an exemplary embodiment, there is also provided a computer readable storage medium comprising instructions, such as a memory including instructions, that when executed on a computer, cause the computer to execute as in the embodiments described below The method of recycling memory. For example, the computer readable storage medium may be a read-only memory (ROM), a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, and an optical data storage device.
本公开实施例引入了一种针对用户的个人使用习惯,以动态自学习的方式获取应用进程的用户偏好度,进而结合用户偏好度来回收内存的策略,可以嵌入现有的Linux操作系统以及Android(安卓)操作系统中,作为各种操作系统中的一种全新的内存保护机制。本公开实施例可以应用于各种回收内存的场景中,能够对应用进程占用的内存进行回收与管控,保证终端运行的流畅度和响应度。以下以三种示例性场景为例进行阐述:The embodiment of the present disclosure introduces a user's personal usage habits, obtains the user preference of the application process in a dynamic self-learning manner, and combines the user preference to recover the memory strategy, and can embed the existing Linux operating system and Android. (Android) operating system, as a new memory protection mechanism in various operating systems. The embodiments of the present disclosure can be applied to various memory recovery scenarios, and can recover and control the memory occupied by the application process to ensure smoothness and responsiveness of the terminal operation. The following is an example of three exemplary scenarios:
场景一、LMK机制。当LMK进程检测到空闲内存小于内存阈值时,终端可以采用本公开实施例提供的方法,确定每个处于后台运行的应用进程的用户偏好度,进而确定出待回收的应用进程,将待回收的应用进程提供给LMK进程,LMK进程可以杀掉待回收的应用进程,从而回收待回收的应用进程占用的内存。Scene 1, LMK mechanism. When the LMK process detects that the free memory is less than the memory threshold, the terminal may determine the user preference of each application process running in the background by using the method provided by the embodiment of the present disclosure, and determine the application process to be recycled, which is to be recovered. The application process is provided to the LMK process, and the LMK process can kill the application process to be recycled, thereby reclaiming the memory occupied by the application process to be recycled.
在该场景中,LMK进程会优先杀用户偏好度较低的应用进程,在空闲内存不小于内存阈值时即停止杀进程,降低了杀掉用户频繁使用的应用进程的概率,从而避免了误杀应用进程,也就避免影响到用户频繁使用的应用进程的运行,保证终端运行的流畅度。In this scenario, the LMK process preferentially kills application processes with low user preference, and stops the kill process when the free memory is not less than the memory threshold, thereby reducing the probability of killing the application process frequently used by the user, thereby avoiding the killing application. The process also avoids affecting the operation of the application process that the user frequently uses, and ensures the smoothness of the terminal operation.
场景二、kswapd进程机制。当kswapd进程检测到空闲内存小于内存阈值时,终端可以采用本公开实施例提供的方法,确定每个处于后台运行的应用进程的用户偏好度,进而确定出待回收的应用进程,将待回收的应用进程提供给kswapd进程,kswapd进程会将待回收的应用进程在内存中的数据转移至预设存储空间中,以回收应用进程占用的内存。Scene 2, kswapd process mechanism. When the kswapd process detects that the free memory is less than the memory threshold, the terminal may determine the user preference of each application process running in the background by using the method provided by the embodiment of the present disclosure, and determine the application process to be recycled, which is to be recovered. The application process is provided to the kswapd process, and the kswapd process transfers the data in the in-memory application process to the preset storage space to recover the memory occupied by the application process.
在该场景中,kswapd进程会优先将用户偏好度较低的应用进程在内存中的数据转移至预设存储空间,在空闲内存不小于内存阈值时即停止转移数据的过程,因此降低了kswapd进程将用户频繁使用的应用进程在内存中的数据转移至预设存储空间的概率,也就避免影响到用户频繁使用的应用进程的运行,保证终端运行的流畅度。In this scenario, the kswapd process preferentially transfers the in-memory data of the application process with lower user preference to the preset storage space, and stops the process of transferring data when the free memory is not less than the memory threshold, thus reducing the kswapd process. The probability of transferring the data in the memory of the application process frequently used by the user to the preset storage space avoids affecting the operation of the application process frequently used by the user and ensuring the smoothness of the terminal operation.
场景三、内存直接回收机制。当任一进程向终端请求内存,而请求的内存超过空闲内存时,终端可以采用本公开实施例提供的方法,确定每个处于后台运行的应用进程的用户偏好度,进而确定出待回收的应用进程,将待回收的应用进程提供给该请求内存的进程,该请求内存的进程会将待回收的应用进程在内存中的数据转移至预设存储空间中,以回收应用进程占用的内存。Scene 3, the direct memory recovery mechanism. When any process requests memory from the terminal, and the requested memory exceeds the free memory, the terminal may determine the user preference of each application process running in the background by using the method provided by the embodiment of the present disclosure, thereby determining the application to be recycled. The process provides the process to be reclaimed to the process of requesting the memory, and the process of requesting the memory transfers the data in the memory of the application process to be recycled to the preset storage space to recover the memory occupied by the application process.
在该场景中,请求内存的进程会优先将用户偏好度较低的应用进程在内存中的数据转移至预设存储空间,在空闲内存超过请求的内存时即停止转移数据的过程,因此降低了将用户频繁使用的应用进程在内存中的数据转移至预设存储空间的概率,也就避免影响到用户频繁使用的应用进程的运行,保证终端运行的流畅度。In this scenario, the process requesting memory preferentially transfers the data in the memory of the application process with lower user preference to the preset storage space, and stops the process of transferring data when the free memory exceeds the requested memory, thereby reducing the process. The probability of transferring the data in the memory of the application process frequently used by the user to the preset storage space avoids affecting the operation of the application process frequently used by the user and ensuring the smoothness of the terminal operation.
图2是本公开实施例提供的一种回收内存的方法的流程图,如图2所示,该方法的执行主体为终端,该终端可以为手机、平板电脑等,该方法包括以下步骤:2 is a flowchart of a method for reclaiming memory according to an embodiment of the present disclosure. As shown in FIG. 2, the execution body of the method is a terminal, and the terminal may be a mobile phone, a tablet computer, or the like. The method includes the following steps:
201、终端统计多个应用进程中每个应用进程在历史运行中每个时间段的活跃时长。201. The terminal collects an active duration of each application process in each application process in a historical operation.
活跃时长:活跃时长是指应用进程处于前台运行的时长。每当某一应用进程某次处于前台运行时,终端可以记录活跃时长:当应用进程开始处于前台运行时,终端可以记录当前时间点,作为活跃时长的开始时间点,当应用进程结束处于前台运行时,终端可以记录当前时间点,作为活跃时长的结束时间点,计算该结束时间点和开始时间点之间的时间差,得到该应用进程本次处于前台运行的活跃时长。例如当应用进程9:00开始在前台运行,9:10时结束在前台运行时,记录活跃时长为10min。Active duration: Active duration refers to the length of time the application process is running in the foreground. Whenever an application process is running in the foreground, the terminal can record the active duration: when the application process starts running in the foreground, the terminal can record the current time point as the start time of the active duration, when the application process ends in the foreground. The terminal can record the current time point as the end time point of the active duration, calculate the time difference between the end time point and the start time point, and obtain the active duration that the application process is currently running in the foreground. For example, when the application process starts running in the foreground at 9:00 and ends in the foreground at 9:10, the record active time is 10 minutes.
时间段:时间段可以预先对一天划分得到,例如时间段可以包括早上对应的时间段、中午对应的时间段或晚上对应的时间段,每个时间段的时长可以为8小时。The time period: the time period may be divided into a day, for example, the time period may include a time period corresponding to the morning, a time period corresponding to the noon, or a time period corresponding to the night, and the duration of each time period may be 8 hours.
可选地,时间段可以根据用户的生理作息确定,可以将发生某一生理作息行为的时间段作为时间段,例如,可以将午饭时间段作为一个时间段,将晚饭时间段作为一个时间段,将临睡时间段作为一个时间段等等,通过这种确定时间段的方式,可以提高用户偏好度的时效性,其技术效果的详细阐述参见以下步骤204。Optionally, the time period may be determined according to a physiological condition of the user, and a time period in which a certain physiological behavior is generated may be used as a time period. For example, the lunch time period may be used as a time period, and the dinner time period may be used as a time period. The time period of the sleep period is taken as a time period and the like, and the timeliness of the user preference can be improved by the method of determining the time period. For the detailed description of the technical effects, refer to the following step 204.
统计活跃时长的具体方式:终端可以每当开始进入任一时间段,即当前时间点为时间段的起始点时,从零开始累计每个应用进程的活跃时长,当离开时间段,即当前时间点为时间段的结束点时,结束累计每个应用进程在该时间段的活跃时长,存储该时间段内每个 应用进程累计的活跃时长,并开始下一次的统计过程,再次从零开始累计,依次类推。其中,针对每个时间段内累计活跃时长的过程,在每个时间段内每个应用进程可以活跃一次或多次,当应用进程在每个时间段内第一次活跃时,可以从零开始记录该应用进程的活跃时长,直至应用进程暂停活跃,而当应用进程第二次活跃至第N次活跃时,可以在已记录的该时间段内该应用进程的活跃时长的基础上增加本次活跃的活跃时长。The specific method of counting the active duration: the terminal can accumulate the active duration of each application process from zero every time when it starts to enter any time period, that is, the current time point is the starting point of the time period, when leaving the time period, that is, the current time When the point is the end point of the time period, the accumulated active time of each application process in the time period is ended, the active duration accumulated by each application process in the time period is stored, and the next statistical process is started, and the accumulation is started again from zero. ,And so on. In the process of accumulating the active duration in each time period, each application process may be active one or more times in each time period, and may start from zero when the application process is active for the first time in each time period. Record the active duration of the application process until the application process is paused, and when the application process is active for the second time to the Nth active time, the active time of the application process may be added to the recorded time period. Active active time.
示例性地,假设当前时间点进入时间段8:00-10:00时,若应用进程A第一次活跃,活跃了5分钟,则此时应用进程A的活跃时长为5分钟,若应用进程A第二次活跃,活跃了10分钟,则此时应用进程A的活跃时长为5+10=15分钟,若应用进程A第三次活跃,活跃了8分钟,则此时应用进程A的活跃时长为15+8=23分钟,而在当前时间点达到10:00,进入下一时间段10:00-13:00时,应用进程A的活跃时长会重新从0开始统计。Exemplarily, if the current time point enters the time period of 8:00-10:00, if the application process A is active for the first time and is active for 5 minutes, then the active time of the application process A is 5 minutes, if the application process A is active for the second time and is active for 10 minutes. At this time, the active duration of application process A is 5+10=15 minutes. If application process A is active for the third time and is active for 8 minutes, then application process A is active. The duration is 15+8=23 minutes, and at the current time point, it reaches 10:00, and when the next time period is 10:00-13:00, the active duration of the application process A will start counting again from 0.
可选地,每当终端获取某应用进程某次处于前台运行的活跃时长时,可以获取当前时间点所属的时间段,获取当前日期以作为记录日期,并获取应用进程的应用进程标识,记录活跃时长、时间段、记录日期、应用进程标识之间的对应关系,以便后续可以根据该对应关系获取到活跃时长。示例性地,终端可以记录“00:00-08:00(时间段),12月7日(记录日期)、APP1(应用进程标识),50分钟(活跃时长)”。Optionally, each time the terminal acquires an active duration of the application process in the foreground, the time period to which the current time point belongs is obtained, the current date is obtained as the record date, and the application process identifier of the application process is obtained, and the record is active. The correspondence between the duration, the time period, the record date, and the application process identifier, so that the active duration can be obtained according to the correspondence. Illustratively, the terminal can record "00:00-08:00 (time period), December 7 (recording date), APP1 (application process identification), 50 minutes (active duration)".
需要说明的是,本步骤201可以由终端的活动管理服务(Activity Manager Service,AMS)执行。AMS是Android操作系统的核心服务,在实施中,可以对AMS的程序代码进行改进,向AMS的程序代码中添加统计每个处于前台运行的应用进程的活跃时长的程序代码,以便AMS在加载并运行程序代码时,可以实现统计活跃时长的功能。It should be noted that this step 201 can be performed by the activity management service (AMS) of the terminal. AMS is the core service of the Android operating system. In the implementation, the program code of the AMS can be improved, and the program code of the active time of each application process running in the foreground is added to the program code of the AMS, so that the AMS is loaded and When you run the program code, you can implement the function of counting active time.
202、在终端检测到空闲内存不满足预设条件时,确定处于后台运行的多个应用进程。202. Determine, when the terminal detects that the free memory does not meet the preset condition, determine that multiple application processes are running in the background.
为了保证终端的正常运行,终端可以在运行过程中检测空闲内存是否满足预设条件,当检测到空闲内存不满足预设条件时,即确定处于后台运行的多个应用进程,以便从这些应用进程中确定出待回收的应用进程,进而进行内存回收。其中,预设条件以及检测空闲内存是否满足预设条件的过程具体可以包括以下两种设计:To ensure the normal operation of the terminal, the terminal can detect whether the free memory meets the preset condition during the running process. When it detects that the free memory does not meet the preset condition, it determines the multiple application processes running in the background, so as to Determine the application process to be recycled, and then perform memory recycling. The preset condition and the process of detecting whether the free memory meets the preset condition may specifically include the following two designs:
设计一、预设条件可以为空闲内存小于内存阈值,终端可以实时或周期性地检测当前的空闲内存是否小于内存阈值,该内存阈值用于指示终端正常运行所需内存的最小值,当空闲内存小于内存阈值时,终端会确定空闲内存不满足预设条件。可选地,终端可以启动LMK进程或kswapd进程,由LMK进程或kswapd进程执行检测空闲内存是否小于内存阈值的过程。The default condition is that the free memory is less than the memory threshold, and the terminal can detect whether the current free memory is less than the memory threshold in real time or periodically. The memory threshold is used to indicate the minimum memory required for the terminal to operate normally. When the memory threshold is less than the memory threshold, the terminal determines that the free memory does not meet the preset condition. Optionally, the terminal may start the LMK process or the kswapd process, and the LMK process or the kswapd process performs a process of detecting whether the free memory is less than a memory threshold.
其中,LMK进程检测到空闲内存小于内存阈值时,可以获取当前运行的所有进程的oom_adj,根据每个进程的oom_adj生成待杀进程列表,该待杀进程列表包括LMK进程确定可以杀掉的处于后台运行的进程,终端可以确定待杀进程列表中每个进程所关联的应用进程,作为后续要获取用户偏好度并可回收内存的应用进程。When the LMK process detects that the free memory is less than the memory threshold, it can obtain the oom_adj of all the currently running processes, and generate a list of the to-be-killed processes according to the oom_adj of each process, and the list of the to-be-killed processes includes the LMK process that is determined to be able to be killed in the background. The running process, the terminal can determine the application process associated with each process in the to-be-killed process list, as an application process that subsequently acquires user preference and can reclaim memory.
设计二、预设条件可以为请求的内存超过空闲内存,当任一应用进程向终端请求内存时,可以向终端发送内存请求,该内存请求携带应用进程所请求的内存,终端可以根据该内存请求获取应用进程请求的内存,判断请求的内存是否超过空闲内存,当请求的内存超过空闲内存时,终端可以确定空闲内存不满足预设条件。The second preset condition may be that the requested memory exceeds the free memory. When any application process requests memory from the terminal, the memory request may be sent to the terminal, where the memory request carries the memory requested by the application process, and the terminal may request the memory according to the memory request. The memory requested by the application process is obtained to determine whether the requested memory exceeds the free memory. When the requested memory exceeds the free memory, the terminal may determine that the free memory does not meet the preset condition.
203、终端确定多个应用进程中每个应用进程在当前时间点所属的时间段的用户偏好度。203. The terminal determines a user preference of each application process in the multiple application processes at a time period to which the current time point belongs.
当终端确定了当前处于后台运行的多个应用进程后,会确定多个应用进程中每个应用进程的用户偏好度,以便基于每个应用进程的用户偏好度,从多个应用进程中确定出待回收的应用进程。可选地,确定用户偏好度的具体过程可以包括以下步骤一至步骤二:After the terminal determines that multiple application processes are currently running in the background, the user preference of each application process in the multiple application processes is determined, so as to determine from multiple application processes based on the user preference of each application process. The application process to be recycled. Optionally, the specific process of determining the user preference may include the following steps 1 to 2:
步骤一、获取每个应用进程在历史运行中当前时间点所属的时间段的活跃时长。Step 1: Obtain an active duration of a time period to which the current time point of each application process belongs in the historical operation.
对于多个应用进程中的每个应用进程,终端可以获取应用进程在历史运行中当前时间点所属的时间段的活跃时长,该活跃时长反映了应用进程在历史运行中该时间段的活跃程度,由于时间段是根据当前时间点确定的,可以认为活跃时长与应用进程在当前运行过程中当前时间点前后的活跃程度较为匹配,从而保证后续基于活跃时长确定出的用户偏好度具有高时效性,准确性高。For each application process in a plurality of application processes, the terminal may obtain an active duration of the time period to which the current time point of the application process belongs in the historical operation, and the active duration reflects the activity level of the application process in the historical operation. Since the time period is determined according to the current time point, it can be considered that the active duration matches the activity level of the application process before and after the current time point in the current running process, thereby ensuring that the user preference determined based on the active duration is highly time-sensitive. High accuracy.
获取应用进程在历史运行中时间段的活跃时长的过程具体可以包括以下步骤(1)-(3):The process of obtaining the active duration of the time period of the application process in the historical running may specifically include the following steps (1)-(3):
(1)获取时间段。(1) Obtain the time period.
终端可以获取当前时间点,确定当前时间段所属的时间段。The terminal can acquire the current time point and determine the time period to which the current time period belongs.
(2)获取历史周期。(2) Obtain the historical period.
终端可以根据当前日期以及预设统计周期确定历史周期,该历史周期以当前日期为时间结束点且时长为预设统计周期。以当前日期为2017年12月7日为例,假设预设统计周期为1天,则历史周期为2017年12月6日至2017年12月7日,假设预设统计周期为一个月,则历史周期为2017年11月7日至2017年12月7日。其中,预设统计周期可以根据实际需求确定,本实施例对预设统计周期的具体数值不做限定。The terminal may determine the historical period according to the current date and the preset statistical period, where the current period is the time end point and the duration is the preset statistical period. Taking the current date as December 7, 2017 as an example, assuming that the preset statistical period is 1 day, the historical period is from December 6, 2017 to December 7, 2017, assuming that the preset statistical period is one month, then The historical period is from November 7, 2017 to December 7, 2017. The preset statistical period can be determined according to the actual requirement. The specific value of the preset statistical period is not limited in this embodiment.
(3)根据历史周期以及时间段,获取应用进程在历史运行中该时间段的活跃时长。(3) According to the historical period and the time period, obtain the active duration of the application process in the historical operation period.
终端可以根据历史周期、时间段以及应用进程的应用进程标识,查询活跃时长、时间段、记录日期、应用进程标识之间的对应关系,得到与时间段、历史周期以及应用进程标识均对应的活跃时长,即对应该时间段、对应的记录日期为历史周期、且对应于应用进程标识的活跃时长,作为应用进程在历史运行中该时间段的活跃时长。例如假设历史周期为2017年11月7日至2017年12月7日,时间段为17:00-19:00,应用进程标识为service1,终端可以获取service1的位于2017年11月7日至2017年12月7日的17:00-19:00的活跃时长。The terminal can query the correspondence between the active duration, the time period, the recording date, and the application process identifier according to the historical period, the time period, and the application process identifier of the application process, and obtain the active corresponding to the time period, the historical period, and the application process identifier. The duration, that is, the corresponding time period, the corresponding recording date is the historical period, and corresponds to the active duration of the application process identifier, as the active duration of the application process in the historical operation. For example, suppose the historical period is from November 7, 2017 to December 7, 2017, the time period is 17:00-19:00, the application process ID is service1, and the terminal can obtain service1 from November 7, 2017 to 2017. The active time of 17:00-19:00 on December 7th.
步骤二、根据多个应用进程中每个应用进程在历史运行中该时间段的活跃时长,确定多个应用进程中每个应用进程的用户偏好度。Step 2: Determine user preference of each application process in multiple application processes according to the active duration of the time period of each application process in the plurality of application processes.
当获取到每个应用进程在历史运行中该时间段(即当前时间点所属的时间段)的活跃时长后,终端可以基于活跃时长获取每个应用进程的用户偏好度,以便后续基于用户偏好度确定待回收的应用进程。获取用户偏好度的具体过程可以包括以下几种设计:After obtaining the active duration of each application process in the historical running period (that is, the time period to which the current time point belongs), the terminal may acquire the user preference of each application process based on the active duration, so as to be based on the user preference. Determine the application process to be recycled. The specific process of obtaining user preferences can include the following designs:
设计一、将活跃时长作为用户偏好度。Design one, the active time is taken as the user preference.
也即是,终端可以直接将应用进程在历史运行中该时间段的活跃时长作为应用进程的用户偏好度,从而简单有效地得到了用户偏好度。That is, the terminal can directly use the active duration of the application process in the historical running period as the user preference of the application process, thereby obtaining the user preference simply and effectively.
设计二、计算活跃时长与活跃时长总和之间的比值,作为用户偏好度。Design 2: Calculate the ratio between the active duration and the active duration as the user preference.
活跃时长总和是指当前在后台运行的多个应用进程在历史运行中该时间段的活跃时长的和值,针对获取活跃时长总和的过程,终端可以遍历多个应用进程中的每个应用进程,通过上述步骤203提供的方式确定每个应用进程的活跃时长,得到多个应用进程的活跃时长,计算多个活跃时长的和值,得到活跃时长总和。The sum of the active durations refers to the sum of the active durations of the multiple application processes currently running in the background during the historical running. For the process of obtaining the sum of the active durations, the terminal can traverse each application process in multiple application processes. The active duration of each application process is determined by the method provided in the foregoing step 203, and the active duration of the multiple application processes is obtained, and the sum of the active durations is calculated to obtain the sum of the active durations.
本设计中,当要确定某个应用进程的用户偏好度时,计算该应用进程的活跃时长与该活跃时长总和之间的比值,将该比值作为用户偏好度,该用户偏好度也可以称为活跃时间占比,即应用进程的活跃时长在多个应用进程的活跃时长中的比例。通过这种结合应用进程的活跃时长与多个应用进程的活跃时长总和来获取用户偏好度,可以达到以下技术效果:In this design, when the user preference of an application process is to be determined, the ratio between the active duration of the application process and the sum of the active durations is calculated, and the ratio is used as the user preference, and the user preference may also be referred to as The proportion of active time, that is, the proportion of the active duration of the application process in the active duration of multiple application processes. By combining the active duration of the application process with the active duration of multiple application processes to obtain user preference, the following technical effects can be achieved:
保证用户偏好度处于合理的数值范围内:考虑到实际应用进程中,用户在不同日期对终端的整体使用情况可以不同,则在不同日期统计用户偏好度时获取的活跃时长也会不同。例如,节假日可以为用户使用终端的高峰期,在节假日期间每个应用进程在各个时间段的活跃时长通常会较长,若此时统计用户偏好度,获取到的每个应用进程的活跃时长偏长,而通过计算应用进程的活跃时长与活跃时长总和之间的比值,能够保证用户偏好度不会过高。又如,考试周以及工作日可能为用户使用终端的低潮期,在考试周以及工作日期间每个应用进程在各个时间段的活跃时长都会偏短,若此时统计用户偏好度,获取到的每个应用进程获取到的活跃时长偏短,而通过计算活跃时长与活跃时长总和之间的比值,能够保证用户偏好度不会过低。也即是,保证计算得到的应用进程的用户偏好度相对稳定,而不会由于当前日期的影响产生过高或过低的情况,那么后续基于用户偏好度确定待回收的应用进程时,能够保证回收应用进程占用的内存过程的准确性。Ensure that the user preference is within a reasonable range of values: Considering the actual application process, the user's overall usage of the terminal on different dates may be different, and the active duration obtained when the user preference is counted on different dates will also be different. For example, the holiday can use the peak period of the terminal for the user. During the holiday period, the active time of each application process in each time period is usually longer. If the user preference is counted at this time, the active time length of each application process obtained is obtained. Long, and by calculating the ratio between the active duration of the application process and the sum of the active durations, it is guaranteed that the user's preference is not too high. For example, the test week and the workday may be the low tide period for the user to use the terminal. During the test week and the working day, the active time of each application process in each time period will be short. If the user preference is collected at this time, the obtained time is obtained. The active duration obtained by each application process is short, and by calculating the ratio between the active duration and the active duration, the user preference is not too low. That is, the user preference of the calculated application process is relatively stable, and the situation is not too high or too low due to the influence of the current date, so that the subsequent application process to be recovered based on the user preference can be guaranteed. Recycle the accuracy of the memory process used by the application process.
设计三、计算活跃时长与应用进程的冷启动时长之间的乘积,作为用户偏好度。Design 3: Calculate the product between the active duration and the cold start duration of the application process as the user preference.
应用进程的冷启动时长是指应用进程以冷启动的方式启动对应的应用时耗费的时长。针对获取冷启动时长的方式,可以预先在任一应用以冷启动的方式启动时,记录冷启动时长和启动该应用的应用进程之间的对应关系,当要获取冷启动时长时,可以获取该应用进程已记录的所有冷启动时长中最新记录的冷启动时长,以便基于该冷启动时长计算用户偏好度。另外,还可以获取应用进程已记录的所有冷启动时长中最近n次记录的冷启动时长,计算n个冷启动时长的平均值,作为获取到的冷启动时长。The cold start duration of an application process refers to the length of time it takes for the application process to start the corresponding application in a cold boot manner. For the method of obtaining the cold boot duration, the relationship between the cold boot duration and the application process that starts the application may be recorded in advance when any application is started in a cold boot manner, and the application may be acquired when the cold boot duration is to be obtained. The cold-start duration of the most recent record of all cold-start durations that have been recorded by the process to calculate user preference based on the cold-start duration. In addition, it is also possible to obtain the cold start duration of the last n records of all the cold boot durations recorded by the application process, and calculate the average of the n cold boot durations as the obtained cold boot duration.
本设计中,在计算用户偏好度时,会获取应用进程的冷启动时长,采用该冷启动时长对活跃时长进行加权,即计算冷启动时长与活跃时长之间的乘积作为用户偏好度,通过结合冷启动时长与活跃时长来获取用户偏好度,可以达到以下技术效果:In this design, when the user preference is calculated, the cold start duration of the application process is obtained, and the active duration is weighted by the cold start duration, that is, the product between the cold start duration and the active duration is calculated as the user preference, by combining The cold start time and active time to obtain user preference can achieve the following technical effects:
对于活跃时长相等的应用进程A和应用进程B来说,假设应用进程A的冷启动时长较长,应用进程B的冷启动时长较短,应用进程A冷启动时速度较慢,如果回收了应用进程A占用的内存,之后再次启动应用进程A时会由于速度较慢,对终端的运行造成较大的影响,同时容易带来终端卡顿的用户体验。而本设计中,通过采用冷启动时长对活跃时长进行加权,能适当增大应用进程A的用户偏好度,后续确定待回收的应用进程时,会避免将应用进程A确定为待回收的应用进程,进而避免再次启动应用进程A时,由于冷启动时长较长对终端的运行造成的较大的影响。For application process A and application process B with the same active time, it is assumed that the cold start time of application process A is long, the cold start time of application process B is short, and the application process A is slow when cold start, if the application is recycled. The memory occupied by process A, and then the application process A is started again. The slower speed will have a greater impact on the operation of the terminal, and it will easily bring the user experience of the terminal. In this design, by weighting the active duration by using the cold start duration, the user preference of the application process A can be appropriately increased, and when the application process to be recovered is subsequently determined, the application process A is determined to be determined as the application process to be recycled. In addition, when the application process A is started again, the long-term cold running time has a large impact on the operation of the terminal.
同理地,应用进程B冷启动时速度较快,即使回收了应用进程B占用的内存,之后再次启动应用进程B时由于速度较快,对终端运行造成的影响较小,同时不容易造成终端卡顿的用户体验。而本设计中,通过采用冷启动时长对活跃时长进行加权,能适当衰减应用进程B的用户偏好度,则后续会优先将应用进程B作为待回收的应用进程,优先回收应用进程B占用的内存,也即是,在准确地回收应用进程占用的内存的基础上,兼顾了每个应用进程的冷启动时长,尽量减少对终端造成的整体影响。Similarly, the application process B is faster when it is cold-started. Even if the memory occupied by the application process B is recovered, the application process B is restarted again because of the faster speed, which has less impact on the terminal operation and is less likely to cause the terminal. Caton's user experience. In this design, by weighting the active duration by using the cold boot duration, the user preference of the application process B can be appropriately attenuated, and then the application process B is preferentially used as the application process to be recycled, and the memory occupied by the application process B is preferentially recycled. That is, on the basis of accurately recovering the memory occupied by the application process, taking into account the cold boot time of each application process, and minimizing the overall impact on the terminal.
需要说明的是,在实施中,应用在运行过程中可以开启多个应用进程,由该多个应用 进程中的主进程以冷启动的方式或热启动的方式启动应用,而主进程以外的每个子进程分别用于提供启动应用以外的功能。在本步骤中,当应用进程为主进程时,可以直接获取已记录的主进程启动对应的应用的冷启动时长,以计算该主进程的用户偏好度。而当应用进程为子进程时,可以确定子进程对应的主进程的冷启动时长,作为子进程的冷启动时长,以计算子进程的用户偏好度。It should be noted that, in the implementation, the application may start multiple application processes during the running process, and the main process in the multiple application processes starts the application in a cold start manner or a hot start manner, and each of the main processes The child processes are used to provide functions other than launching the application. In this step, when the application process is the main process, the cold boot time of the corresponding application started by the recorded main process can be directly obtained to calculate the user preference of the main process. When the application process is a child process, the cold boot time of the main process corresponding to the child process may be determined as the cold start duration of the child process to calculate the user preference of the child process.
设计四、计算活跃时长与活跃时长和值之间的比值,以及计算比值与应用进程的冷启动时长之间的乘积,作为用户偏好度。Design 4. Calculate the ratio between the active duration and the active duration and value, and calculate the product between the ratio and the cold start duration of the application process as the user preference.
本设计为设计二与设计三相结合的方式,活跃时长和值的获取方式详见设计二,冷启动时长的获取方式详见设计三,在此不做赘述。本设计中,在提供了准确获取用户偏好度的方式的基础上,能够保证用户偏好度处于合理的数值范围内,同时兼顾了应用进程的冷启动时长,保证回收应用进程占用的内存时对终端的整体影响尽量小。This design is the combination of design two and design three-phase. The acquisition method of active duration and value is detailed in Design 2. The acquisition method of cold start time is detailed in Design III, and will not be described here. In this design, on the basis of providing a method for accurately obtaining user preference, the user preference can be guaranteed to be within a reasonable numerical range, and the cold start time of the application process is taken into consideration, and the memory occupied by the application process is guaranteed to be recycled to the terminal. The overall impact is as small as possible.
需要说明的是,当上述步骤201中时间段根据用户的生理作息行为确定,本步骤中还可以达到用户偏好度与用户的生理作息习惯相匹配的效果:例如考虑到用户通常在午饭时间段和晚饭时间段偏好使用外卖订餐应用的应用进程,预先将午饭时间段和晚饭时间段设置为时间段来实时统计活跃时长,如果在当前时间点为午饭时间段和晚饭时间段时要回收内存,计算出的外卖订餐应用的应用进程的用户偏好度会较高,则可以避免回收外卖订餐应用的应用进程占用的内存,又如考虑到用户通常在临睡时间段偏好使用音乐播放应用的应用进程,预先将临睡时间段设置为时间段来实时统计活跃时长,如果在当前时间点为临睡时间段时要回收内存,计算出的音乐播放应用的应用进程的用户偏好度会较高,则可以避免回收音乐播放应用的应用进程占用的内存。It should be noted that, when the time period in the above step 201 is determined according to the physiological behavior of the user, in this step, the effect that the user preference matches the physiological habits of the user can be achieved: for example, considering that the user usually has a lunch time period and During the dinner time period, the application process of the take-out ordering application is preferred, and the lunch time period and the dinner time period are set as the time period in advance to calculate the active time length in real time, and if the current time point is the lunch time period and the dinner time period, the memory is to be recovered, and the calculation is performed. The user preference of the application process of the take-out ordering application is higher, and the memory occupied by the application process of the take-out ordering application can be avoided, and the application process of the user who prefers to use the music playing application during the sleeping time period is considered, for example. The sleep time period is set to the time period in advance to calculate the active duration in real time. If the memory is to be reclaimed during the current sleep time period, the calculated user preference of the application process of the music playing application is higher, then Avoid reclaiming memory used by the app process of the music player application.
204、终端基于每个应用进程的用户偏好度,获取每个应用进程的回收优先级。204. The terminal acquires a recycling priority of each application process based on user preference of each application process.
终端可以获取每个应用进程的回收优先级,以便基于每个应用进程的回收优先级确定待回收的应用进程。其中,每个应用进程的回收优先级与每个应用进程的用户偏好度负相关,若应用进程的用户偏好度越高,则应用进程的回收优先级越低,应用进程的用户偏好度越低,则应用进程的回收优先级越高。The terminal can obtain the recycling priority of each application process, so as to determine the application process to be recycled based on the recycling priority of each application process. The reclaiming priority of each application process is negatively related to the user preference of each application process. If the user preference of the application process is higher, the revocation priority of the application process is lower, and the user preference of the application process is lower. , the higher the recycling priority of the application process.
进一步地,在提供了基于用户偏好度确定回收优先级的基础上,本实施例还提供了结合用户偏好度与应用进程的内存占比、应用进程的功能、应用进程最近一次的活跃时长、应用进程的功耗等因素,共同确定回收优先级的方式,详见以下设计一至设计四。需要说明的是,以下各种设计中回收优先级的数值与回收优先级的高低成反比,即回收优先级的数值越小,回收优先级越高,回收优先级的数值越大,回收优先级越低。Further, on the basis of determining the revocation priority based on the user preference, the embodiment further provides the memory ratio of the user preference and the application process, the function of the application process, the latest active duration of the application process, and the application. The power consumption of the process and other factors together determine the way to reclaim the priority. See Design 1 to Design 4 below for details. It should be noted that the value of the recycling priority in the following various designs is inversely proportional to the level of the recycling priority. That is, the smaller the value of the recycling priority, the higher the recycling priority, the larger the value of the recycling priority, and the recycling priority. The lower.
设计一、结合用户偏好度与应用进程的内存占比确定回收优先级。Design 1. Determine the recycling priority by combining the user preference with the memory ratio of the application process.
本设计具体可以包括以下步骤一至步骤三:The design may specifically include the following steps 1 to 3:
步骤一、终端确定与每个应用进程的内存占比对应的内存占比权重,每个应用进程的内存占比用于指示每个应用进程占用的内存与总内存开销之间的比值。Step 1: The terminal determines the memory weight corresponding to the memory ratio of each application process, and the memory ratio of each application process is used to indicate the ratio between the memory occupied by each application process and the total memory overhead.
内存占比:对于多个应用进程中的每个应用进程,终端可以获取该每个应用进程占用的内存以及当前的总内存开销,计算该每个应用进程占用的内存与总内存开销之间的比值,将该比值作为内存占比。其中总内存开销是指终端当前总计占用的内存大小,为终端运行的各种应用进程所占用的内存的总和。示例性地,假设应用进程占用的内存为100M,当前的总内存开销为1000M,则得到应用进程的内存占比为100M/1000M=10%。Memory ratio: For each application process in multiple application processes, the terminal can obtain the memory occupied by each application process and the current total memory cost, and calculate the memory occupied by each application process and the total memory overhead. Ratio, the ratio is taken as the memory ratio. The total memory overhead refers to the total memory occupied by the terminal, which is the sum of the memory occupied by various application processes running on the terminal. Exemplarily, if the memory occupied by the application process is 100M and the current total memory overhead is 1000M, the memory ratio of the application process is 100M/1000M=10%.
内存占比权重:终端可以基于应用进程的内存占比与内存占比权重之间的对应关系,获取应用进程的内存占比对应的内存占比权重。其中,内存占比与内存占比权重之间的对应关系包括多个内存占比以及对应的多个内存占比权重,内存占比越大,对应的内存占比权重越大。内存占比与内存占比权重之间的对应关系可以由开发人员预先设置。当终端得到内存占比后,可以采用内存占比为索引,查询内存占比与内存占比权重之间的对应关系,从对应关系中获取内存占比对应的内存占比权重。Memory weight ratio: The terminal can obtain the memory weight ratio corresponding to the memory ratio of the application process based on the correspondence between the memory ratio of the application process and the memory weight. The correspondence between the memory ratio and the memory weight ratio includes a plurality of memory ratios and corresponding memory weight ratios. The larger the memory ratio, the larger the corresponding memory weight. The correspondence between the memory ratio and the memory weight can be set by the developer in advance. After the terminal obtains the memory ratio, the memory ratio is used as an index, and the correspondence between the memory ratio and the memory weight ratio is queried, and the memory ratio weight corresponding to the memory ratio is obtained from the corresponding relationship.
可选地,终端可以对内存占比进行量化,例如可以设置多个内存占比区间,并设置内存占比区间与内存占比权重之间的对应关系,当得到应用进程的内存占比时,可以从多个内存占比区间中获取该内存占比所属的内存占比区间,基于内存占比区间与内存占比权重之间的对应关系,获取应用进程的内存占比区间对应的内存占比权重。其中,内存占比区间可以由开发人员根据实际需求设置,例如设置1%-10%为一个内存占比区间。Optionally, the terminal may quantize the memory ratio. For example, multiple memory ratio intervals may be set, and a correspondence between the memory ratio interval and the memory weight ratio is set. When the memory ratio of the application process is obtained, The memory ratio ratio of the memory ratio may be obtained from a plurality of memory ratio intervals, and the memory ratio of the application process's memory ratio interval is obtained based on the correspondence between the memory ratio interval and the memory ratio weight. Weights. Among them, the memory ratio interval can be set by the developer according to actual needs, for example, setting 1%-10% as a memory ratio interval.
通过对内存占比进行量化,可以将一定数值范围内的所有内存占比统一与某个内存占比权重对应,则内存占比与内存占比权重之间的对应关系中无需包括该数值范围内的所有内存占比,只需包括内存占比区间,从而实现了对应关系的简化,减少了要存储的数据量。By quantifying the memory ratio, all the memory ratios in a certain range of values can be uniformly unified with a certain memory weight, and the correspondence between the memory ratio and the memory weight is not included in the value range. All memory ratios only need to include the memory ratio interval, which simplifies the correspondence and reduces the amount of data to be stored.
步骤二、终端根据每个应用进程的用户偏好度与每个应用进程的内存占比权重,获取每个应用进程的回收优先级。Step 2: The terminal obtains the recycling priority of each application process according to the user preference of each application process and the memory weight of each application process.
应用进程的回收优先级与内存占比权重正相关,且与用户偏好度负相关。可选地,可以计算用户偏好度与内存占比权重之间的比值,得到回收优先级。示例性地,可以采用以下公式计算回收优先级:Yi=Bi/Ai,其中,Yi表征回收优先级,Bi表征用户偏好度,Ai表征内存占比权重。The recycling priority of the application process is positively correlated with the memory weight and is negatively related to user preference. Optionally, the ratio between the user preference and the memory weight may be calculated to obtain a recycling priority. Illustratively, the recycling priority can be calculated using the following formula: Yi = Bi / Ai, where Yi represents the recycling priority, Bi represents the user preference, and Ai represents the memory weight.
本设计中,应用进程的内存占比权重越大,则回收优先级越高,因此后续被确定为待回收的应用进程的概率越大,应用进程的内存占比权重越小,则回收优先级越低,因此后续被确定为待回收的应用进程的概率越小。In this design, the greater the memory weight of the application process, the higher the reclaim priority. Therefore, the greater the probability that the application process is determined to be reclaimed, the smaller the memory weight of the application process is, and the reclaim priority is reclaimed. The lower the probability, the less likely the subsequent process is determined to be the application process to be recycled.
通过结合用户偏好度和应用进程的内存占比确定回收优先级,可以进一步提高回收内存的准确性:对于用户偏好度接近的多个应用进程来说,假设某应用进程的内存占比较大,则内存占比权重较大,因此该应用进程的回收优先级会较高,会优先回收该应用进程的内存,能够保证回收的内存较多,保证空闲内存尽量快地满足内存需求。By determining the reclaiming priority by combining the user preference with the memory ratio of the application process, the accuracy of the reclaimed memory can be further improved: for a plurality of application processes whose user preference is close, assuming that the memory of an application process is relatively large, The memory has a larger weight, so the application process has a higher reclaim priority, and the memory of the application process is preferentially reclaimed. It can ensure that more memory is reclaimed, and the free memory is guaranteed to meet the memory requirement as quickly as possible.
设计二、结合用户偏好度和应用进程的功能,确定应用进程的回收优先级。Design 2. Combine user preference and application process functions to determine the recycling priority of the application process.
本设计具体可以包括以下步骤一至步骤二:The design may specifically include the following steps 1 to 2:
步骤一、终端确定与每个应用进程的功能对应的功能权重。Step 1: The terminal determines a function weight corresponding to the function of each application process.
应用进程的功能:可以包括推送功能、网络连接功能等,应用可以同时开启一个或多个应用进程,每个应用进程可以根据其当前执行的活动具有对应的进程功能,例如即时通信应用可以开启主进程、推送子进程、连网子进程等,由推送子进程进行推送消息,由连网子进程进行网络连接。对于任一应用进程来说,终端可以与该应用进程之间进行交互,获知应用进程的进程功能。The function of the application process: it can include push function, network connection function, etc. The application can open one or more application processes at the same time, and each application process can have corresponding process functions according to the currently executing activities, for example, the instant communication application can open the main function. The process, the push sub-process, the networked sub-process, etc., push the sub-process to push the message, and the networked sub-process performs the network connection. For any application process, the terminal can interact with the application process to learn the process function of the application process.
确定应用进程的功能对应的功能权重的过程:对于多个应用进程中每个应用进程,当终端确定每个应用进程的进程功能后,采用进程功能为索引,查询进程功能与功能权重之间的对应关系,从对应关系中获取进程功能对应的功能权重。其中,进程功能与功能权重之间的对应关系包括多个功能以及对应的多个功能权重,可以根据经验确定,例如认为进 程功能越重要,则设置的功能权重越大,认为进程功能越次要,则设置的功能权重越小。示例性地,考虑到推送功能的应用进程在运行过程中通常会打扰用户,同时影响终端接收网络数据的速度,可以为推送功能设置较小的功能权重,以保证推送功能的应用进程的回收优先级较高,进而优先回收该应用进程的内存。The process of determining the function weight corresponding to the function of the application process: for each application process in multiple application processes, after the terminal determines the process function of each application process, the process function is used as an index to query the process function and the function weight Corresponding relationship, the function weight corresponding to the process function is obtained from the corresponding relationship. The corresponding relationship between the process function and the function weight includes multiple functions and corresponding multiple function weights, which can be determined according to experience. For example, the more important the process function is, the larger the function weight is, and the more important the process function is. , the smaller the function weight is set. Exemplarily, considering that the application process of the push function usually disturbs the user during the operation, and affects the speed at which the terminal receives the network data, a small function weight can be set for the push function to ensure that the application process of the push function is preferentially recycled. The level is higher, which in turn preferentially reclaims the memory of the application process.
步骤二、根据每个应用进程的用户偏好度与每个应用进程的功能权重,获取每个应用进程的回收优先级。Step 2: According to the user preference of each application process and the function weight of each application process, obtain the recycling priority of each application process.
其中,回收优先级与功能权重负相关,且与用户偏好度负相关。进一步地,可以计算用户偏好度与功能权重之间的乘积,得到回收优先级。示例性地,可以采用以下公式计算回收优先级:Yi=Bi×Di,其中,Yi表征回收优先级,Bi表征用户偏好度,Di表征功能权重。Among them, the recycling priority is negatively related to the function weight and negatively related to the user preference. Further, the product between the user preference and the function weight can be calculated to obtain the recycling priority. Illustratively, the recycling priority can be calculated using the following formula: Yi = Bi x Di, where Yi represents the recycling priority, Bi represents the user preference, and Di represents the functional weight.
本设计中,应用进程的功能权重越小,则回收优先级越高,因此后续被确定为待回收的应用进程的概率越大,应用进程的功能权重越大,则回收优先级越低,因此后续被确定为待回收的应用进程的概率越大。In this design, the smaller the function weight of the application process is, the higher the reclaim priority is. Therefore, the greater the probability that the subsequent application process is determined to be reclaimed, the higher the function weight of the application process is, the lower the reclaim priority is. The greater the probability that the subsequent application process is determined to be recycled.
通过结合用户偏好度和功能权重确定回收优先级,可以进一步提高回收内存的准确性:对于用户偏好度接近的多个应用进程来说,若某个应用进程的进程功能较为次要,可以认为该应用进程当前的运行活动对于终端的重要性低,回收该应用进程的内存时造成的影响较小,而结合功能权重确定回收优先级时,该应用进程的回收优先级会较高,终端会优先回收该应用进程的内存,从而尽量减少回收内存对终端造成的整体影响。By combining the user preference and the function weight to determine the recycling priority, the accuracy of the reclaimed memory can be further improved: for a plurality of application processes with similar user preferences, if the process function of an application process is less important, it can be considered as The current running activity of the application process is of low importance to the terminal, and the impact of reclaiming the memory of the application process is small. When the re-prioritization priority is determined by the function weight, the revocation priority of the application process is higher, and the terminal takes precedence. Reclaim the memory of the application process to minimize the overall impact of the reclaimed memory on the terminal.
设计三、结合用户偏好度和应用进程的最近一次的活跃时长,确定应用进程的回收优先级。Design 3. Combine the user preference with the most recent active duration of the application process to determine the recycling priority of the application process.
本设计具体可以包括以下步骤一至步骤三:The design may specifically include the following steps 1 to 3:
步骤一、确定每个应用进程的最近活跃权重,每个应用进程的最近活跃权重用于指示该每个应用进程最近活跃的程度。Step 1: Determine the most recent active weight of each application process, and the most recent active weight of each application process is used to indicate the extent to which each application process is recently active.
确定最近活跃权重的具体过程可以包括以下(1)-(2)。The specific process for determining the most recent active weights may include the following (1)-(2).
(1)获取每个应用进程的最近活跃时长,每个应用进程的最近活跃时长用于指示应用进程最近一次在前台运行的活跃时长。(1) Obtain the latest active duration of each application process, and the latest active duration of each application process is used to indicate the active duration of the application process running in the foreground.
对于多个应用进程中每个应用进程,终端可以获取应用进程已记录的多个活跃时长中距离当前时间点最近的活跃时长,得到最近活跃时长。For each application process in multiple application processes, the terminal can obtain the active time duration of the active time duration recorded by the application process from the current time point to obtain the latest active duration.
(2)基于最近活跃时长的结束时间点与当前时间点之间的时间差,对每个应用进程的最近活跃时长进行衰减,将衰减后的最近活跃时长作为最近活跃权重。(2) Attenuating the most recent active duration of each application process based on the time difference between the end time point of the most recent active duration and the current time point, and using the decayed most recent active duration as the most recent active weight.
终端可以获取最近活跃时长的结束时间点,并获取当前时间点,计算该结束时间点与当前时间点之前的时间差,基于该时间差对最近活跃时长进行衰减,将衰减后的最近活跃时长作为最近活跃权重。The terminal can obtain the end time point of the most recent active time, obtain the current time point, calculate the time difference between the end time point and the current time point, and attenuate the latest active time length based on the time difference, and use the decayed latest active time length as the most recent active time. Weights.
针对基于时间差对最近活跃时长进行衰减的具体过程,可以采用衰减函数对时间差和最近活跃时长进行计算,将计算结果作为最近活跃权重。其中,衰减函数可以为Ti=w×y^(-t),Ti表征最近活跃权重,w表征归一化的最近活跃时长,y为一个常数,t表征时间差。For the specific process of attenuating the most recent active time based on the time difference, the attenuation function can be used to calculate the time difference and the most recent active time, and the calculation result is used as the most recent active weight. Wherein, the attenuation function can be Ti=w×y^(-t), Ti represents the most recent active weight, w represents the normalized most active duration, y is a constant, and t represents the time difference.
基于上述计算方式,由于时间差能够反映应用进程最近一次的运行过程与当前时间点之间距离的远近,当某应用进程的时间差较小时,表明该应用进程是最近活跃的应用进程, 可以认为该应用进程对用户当前的重要性较强,则基于时间差对最近活跃时长进行衰减时,衰减程度较少,以保证该应用进程的最近活跃权重较大。而当应用进程的时间差较大时,表明该应用进程是很久以前活跃的应用进程,可以认为该应用进程对用户当前的重要性较弱,则基于时间差对最近活跃时长进行衰减时,衰减程度较大,以保证应用进程的最近活跃权重较小。Based on the above calculation method, the time difference can reflect the distance between the latest running process of the application process and the current time point. When the time difference of an application process is small, it indicates that the application process is the most active application process, and the application can be considered as the application. The process is more important to the user at present, and the attenuation is less when the latest active duration is attenuated based on the time difference, so as to ensure that the recent active weight of the application process is large. When the time difference of the application process is large, it indicates that the application process is an active application process that is active a long time ago. It can be considered that the application process is less important to the user at present, and the attenuation is greater when the latest active time is attenuated based on the time difference. Large to ensure that the most recent active weight of the application process is small.
步骤二、根据每个应用进程的用户偏好度与最近活跃权重,获取每个应用进程的回收优先级。Step 2: According to the user preference and the recent active weight of each application process, obtain the recycling priority of each application process.
应用进程的回收优先级与最近活跃权重负相关,且与用户偏好度负相关。可选地,可以计算用户偏好度与最近活跃权重之间的乘积,得到回收优先级。示例性地,可以采用以下公式计算回收优先级:Yi=Bi×Ti,其中,Yi表征回收优先级,Bi表征用户偏好度,Ti表征最近活跃权重。The reclaim priority of the application process is negatively correlated with the most recent active weight and is negatively correlated with user preference. Alternatively, the product between the user preference and the most recent active weight can be calculated to obtain a recycling priority. Illustratively, the recycling priority can be calculated using the following formula: Yi = Bi x Ti, where Yi represents the recycling priority, Bi represents the user preference, and Ti represents the most recent active weight.
本设计中,应用进程的最近活跃权重越小,则回收优先级越高,因此后续被确定为待回收的应用进程的概率越大。应用进程的最近活跃权重越大,则回收优先级越低,因此后续被确定为待回收的应用进程的概率越小。In this design, the smaller the recent active weight of the application process, the higher the reclaim priority, so the probability that the subsequent application process is determined to be reclaimed is larger. The greater the recent active weight of the application process, the lower the revocation priority, so the probability that the subsequent application process is determined to be reclaimed is smaller.
通过结合用户偏好度和应用进程的最近活跃权重确定回收优先级,可以进一步提高回收内存的准确性:对于用户偏好度接近的多个应用进程来说,若某个应用进程是最近活跃的应用进程,最近活跃权重会较大,因此该应用进程的回收优先级会较低,则会避免回收该应用进程的内存,从而尽量避免影响最近活跃的应用进程的正常运行。若某个应用进程是很久之前活跃的应用进程,则最近活跃权重较小,因此该应用进程的回收优先级会较高,会优先回收该应用进程的内存,通过优先回收很久以前活跃的应用进程所占用的内存,在实现回收内存的基础上,保证对终端运行的整体影响尽量小。By determining the reclaim priority in combination with the user preference and the most recent active weight of the application process, the accuracy of the reclaimed memory can be further improved: for multiple application processes with similar user preferences, if an application process is the most recent active application process The recent active weight will be larger, so the application process will have lower reclaim priority, which will avoid reclaiming the memory of the application process, so as to avoid affecting the normal operation of the recently active application process. If an application process is an active application process that is active for a long time, the active weight of the application is relatively small. Therefore, the application process has a higher revocation priority, and the memory of the application process is preferentially reclaimed. The application process that was active long ago is preferentially recycled. The occupied memory, on the basis of realizing the recovery of memory, ensures that the overall impact on the operation of the terminal is as small as possible.
设计四、结合用户偏好度和应用进程的功耗确定回收优先级。Design 4. Determine the recycling priority based on user preference and power consumption of the application process.
本设计具体可以包括以下步骤一至步骤二:The design may specifically include the following steps 1 to 2:
步骤一、确定与每个应用进程的功耗对应的功耗权重。Step 1: Determine the power consumption weight corresponding to the power consumption of each application process.
功耗:功耗是指应用进程运行的耗电量,针对获取功耗的过程,终端可以预先在应用进程运行时,实时记录应用进程的功耗。则本步骤中,对于多个应用进程中每个应用进程,终端可以获取已记录的应用进程在历史运行中的功耗,例如可以获取应用进程最近一次运行的功耗,又如可以获取应用进程最近预设次数运行的功耗,计算预设次数的功耗的平均值。Power consumption: Power consumption refers to the power consumption of the application process. For the process of obtaining power consumption, the terminal can record the power consumption of the application process in real time while the application process is running. In this step, for each application process in multiple application processes, the terminal may obtain the power consumption of the recorded application process in the historical operation, for example, the power consumption of the application process may be obtained, and the application process may be acquired. The power consumption of the last preset number of runs, and the average of the power consumption of the preset number of times is calculated.
确定功耗权重的过程:终端可以采用功耗为索引,查询功耗与功耗权重之间的对应关系,从对应关系中获取功耗对应的功耗权重。其中,功耗与功耗权重之间的对应关系包括多个功耗以及对应的多个功耗权重,功耗越大,对应的功耗权重越大,功耗与功耗权重的对应关系可以由开发人员预先设置,可以预先存储在终端中。The process of determining the power consumption weight: the terminal can use the power consumption as an index, query the correspondence between the power consumption and the power weight, and obtain the power consumption weight corresponding to the power consumption from the corresponding relationship. The corresponding relationship between power consumption and power consumption weight includes multiple power consumptions and corresponding multiple power consumption weights. The greater the power consumption, the greater the corresponding power weight, and the corresponding relationship between power consumption and power weight can be It is preset by the developer and can be stored in the terminal in advance.
步骤二、根据每个应用进程的用户偏好度与每个应用进程的功耗权重,获取每个应用进程的回收优先级。Step 2: According to the user preference of each application process and the power consumption weight of each application process, obtain the recycling priority of each application process.
其中,回收优先级与功耗权重正相关,且与用户偏好度负相关。进一步地,可以计算用户偏好度与功耗权重之间的比值,得到回收优先级。示例性地,可以采用以下公式计算回收优先级:Yi=Bi/Hi,其中,Yi表征回收优先级,Bi表征用户偏好度,Hi表征功耗权重。Among them, the recycling priority is positively correlated with the power consumption weight and negatively related to the user preference. Further, the ratio between the user preference and the power consumption weight can be calculated to obtain the recycling priority. Illustratively, the recycling priority can be calculated using the following formula: Yi = Bi / Hi, where Yi represents the recycling priority, Bi represents the user preference, and Hi represents the power consumption weight.
本设计中,应用进程的功耗权重越大,则回收优先级越高,后续被确定为待回收的应用进程的概率越大。应用进程的功耗权重越小,则回收优先级越低,后续被确定为待回收的应用进程的概率越小。In this design, the greater the power consumption weight of the application process, the higher the reclaim priority, and the greater the probability that the subsequent application process is determined to be reclaimed. The smaller the power consumption weight of the application process, the lower the reclaim priority, and the smaller the probability that the subsequent application process is determined to be reclaimed.
通过结合用户偏好度和应用进程的功耗确定待回收的应用进程,可以达到以下技术效果:对于用户偏好度接近的多个应用进程来说,若某个应用进程的功耗越大,则功耗权重越大,则由于回收优先级较高,后续终端会优先回收该应用进程占用的内存。通过优先回收功耗大的应用进程占用的内存,在实现回收内存功能的基础上,能够节约终端的功耗。By determining the application process to be recycled in combination with the user preference and the power consumption of the application process, the following technical effects can be achieved: for a plurality of application processes with similar user preferences, if the power consumption of an application process is greater, the work is performed. If the weight of the application is higher, the subsequent terminal will preferentially reclaim the memory occupied by the application process. By preferentially reclaiming the memory occupied by the application process with high power consumption, the power consumption of the terminal can be saved on the basis of realizing the function of reclaiming memory.
设计五、结合用户偏好度和应用进程的调用频率确定待回收的应用进程,调用频率是指多个应用进程在历史运行中该时间段内调用应用进程的总次数。Design 5. Determine the application process to be recycled in combination with the user preference and the calling frequency of the application process. The calling frequency refers to the total number of times the application process calls the application process during the time period in the historical running.
本设计具体可以包括以下步骤一至步骤三:The design may specifically include the following steps 1 to 3:
步骤一、确定每个应用进程的调用频率,每个应用进程的调用频率用于指示多个应用进程在历史运行中时间段内调用每个应用进程的总次数。Step 1: Determine the calling frequency of each application process, and the calling frequency of each application process is used to indicate the total number of times that multiple application processes call each application process in the historical running time period.
确定调用频率的具体过程可以包括以下(1)-(2):The specific process of determining the calling frequency may include the following (1)-(2):
(1)终端获取每个应用进程的调用记录。(1) The terminal acquires a call record of each application process.
调用记录也称调用链表,每个应用进程的调用记录用于记录每个应用进程调用多个应用进程中每个应用进程以外的应用进程的事件,当每个应用进程运行时,终端可以实时在每个应用进程的调用记录中记录应用进程调用其他应用进程的事件。例如,对于应用进程1-应用进程N来说,会在应用进程1的调用记录中,记录应用进程1调用应用进程2-应用进程N中的事件。The call record is also called the call list. The call record of each application process is used to record the events of each application process in each application process except for each application process in the application process. When each application process runs, the terminal can be in real time. The event record of each application process records the events of the application process calling other application processes. For example, for the application process 1 - application process N, in the call record of the application process 1, the application process 1 is recorded to call the event in the application process 2 - application process N.
(2)终端基于每个应用进程的调用记录,确定每个应用进程的调用频率。(2) The terminal determines the calling frequency of each application process based on the call record of each application process.
对于多个应用进程中的每个应用进程,终端可以计算多个调用记录中调用该每个应用进程的调用次数的和值,作为该每个应用进程的调用频率。例如,对于应用进程1来说,可以根据应用进程2-应用进程N的调用记录,获取应用进程2-应用进程N调用应用进程1的调用次数的和值,作为应用进程1的调用频率。For each application process in multiple application processes, the terminal can calculate the sum of the number of calls to each application process in the multiple call records as the calling frequency of each application process. For example, for the application process 1, the sum of the number of calls of the application process 2 - the application process N calling the application process 1 can be obtained according to the application process 2 - the call record of the application process N, as the calling frequency of the application process 1.
步骤二、基于每个应用进程的调用频率,获取每个应用进程的回收优先级Step 2: Obtain the recycling priority of each application process based on the calling frequency of each application process.
回收优先级与调用频率负相关,且与用户偏好度负相关。可选地,终端可以基于调用频率,对回收优先级进行调节。终端可以设置第一频率阈值和第二频率阈值,当终端确定了每个应用进程的调用频率后,可以判断调用频率是否高于第一调用频率阈值,当调用频率高于第一调用频率阈值时,认为应用进程是被频繁调用的应用进程,回收该应用进程占用的内存后会对其他应用进程的运行造成较大的影响,则会将应用进程的回收优先级调低,以尽量避免回收应用进程占用的内存。同理地,终端可以判断应用进程的调用频率是否低于第二频率阈值,当调用频率低于第二调用频率阈值时,认为应用进程是很少被调用的应用进程,回收该应用进程占用的内存后对其他应用进程的运行造成的影响较小,则将应用进程的回收优先级调高。另外,当调用频率不高于第一频率阈值且不低于第二频率阈值时,终端可以无需调节应用进程的回收优先级。其中,第一调用频率阈值用于指示频繁调用的应用进程的调用频率的最低值,可以根据实际需求设置。第二调用频率阈值用于指示很少被调用的应用进程的调用频率的最高值,可以根据实际需求设置。Recycling priority is negatively correlated with the calling frequency and negatively related to user preference. Optionally, the terminal can adjust the reclaim priority based on the calling frequency. The terminal may set the first frequency threshold and the second frequency threshold. After the terminal determines the calling frequency of each application process, it may determine whether the calling frequency is higher than the first calling frequency threshold, when the calling frequency is higher than the first calling frequency threshold. The application process is considered to be an application process that is frequently called. Recycling the memory occupied by the application process will have a greater impact on the operation of other application processes, and the application process's recycling priority will be lowered to avoid recycling applications. The memory occupied by the process. Similarly, the terminal can determine whether the calling frequency of the application process is lower than the second frequency threshold. When the calling frequency is lower than the second calling frequency threshold, the application process is considered to be an application process that is rarely called, and the application process is recycled. After the memory has less impact on the operation of other application processes, the recycling priority of the application process is increased. In addition, when the calling frequency is not higher than the first frequency threshold and not lower than the second frequency threshold, the terminal may not need to adjust the recycling priority of the application process. The first call frequency threshold is used to indicate the lowest value of the calling frequency of the frequently invoked application process, and may be set according to actual requirements. The second call frequency threshold is used to indicate the highest value of the calling frequency of the application process that is rarely called, and can be set according to actual needs.
关于调低回收优先级的过程,终端可以设置预设调节数值,预设调节数值可以为正数,终端可以计算应用进程回收优先级的数值与预设调节数值的和值,将和值作为调低后的回 收优先级。或者,预设调节数值可以为大于1的正数,终端可以计算应用进程回收优先级的数值与预设调节数值的乘积,将乘积作为调低后的回收优先级。Regarding the process of lowering the recycling priority, the terminal can set a preset adjustment value, and the preset adjustment value can be a positive number, and the terminal can calculate the sum of the value of the application process recovery priority and the preset adjustment value, and adjust the sum value as a tune. Low recycling priority. Alternatively, the preset adjustment value may be a positive number greater than 1, and the terminal may calculate the product of the application process recovery priority value and the preset adjustment value, and use the product as the reduction priority after the reduction.
关于调高回收优先级的过程,终端可以设置预设调节数值,预设调节数值可以为正数,终端可以计算应用进程回收优先级的数值与预设调节数值的差值,将差值作为调高后的回收优先级。或者,预设调节数值可以为大于1的正数,终端可以计算应用进程回收优先级的数值与预设调节数值的比值,将比值作为调高后的回收优先级。Regarding the process of increasing the priority of recycling, the terminal can set a preset adjustment value, and the preset adjustment value can be a positive number, and the terminal can calculate the difference between the value of the application process recovery priority and the preset adjustment value, and adjust the difference as a tone. High recycling priority. Alternatively, the preset adjustment value may be a positive number greater than 1, and the terminal may calculate a ratio of the value of the application process recovery priority to the preset adjustment value, and use the ratio as the recovery priority after the adjustment.
本设计中,应用进程的调用频率越小,则回收优先级越高,后续被确定为待回收的应用进程的概率越大。应用进程的调用频率越大,则回收优先级越低,后续被确定为待回收的应用进程的概率越小。通过结合用户偏好度和应用进程的调用频率确定回收优先级,能够保证被频繁调用的应用进程的回收优先级较低,从而尽量避免回收被频繁调用的应用进程时导致的对其他应用进程的运行造成影响。In this design, the smaller the calling frequency of the application process, the higher the recycling priority, and the greater the probability that the subsequent application process is determined to be recycled. The higher the calling frequency of the application process, the lower the reclaiming priority, and the smaller the probability that the subsequent application process is determined to be reclaimed. By determining the reclaiming priority by combining the user preference and the calling frequency of the application process, it is possible to ensure that the reclaiming priority of the frequently invoked application process is low, thereby avoiding the operation of other application processes caused by reclaiming the frequently invoked application process. Make an impact.
需要说明的是,上述设计一至设计五可以采用任意结合的方式形成确定回收优先级的方式。例如,设计一与设计三结合时,终端可以获取内存占比权重和最近活跃权重,根据算用户偏好度、内存占比权重、最近活跃权重,确定回收优先级。又如,设计一、设计二、设计三和设计四结合时,终端可以获取内存占比权重、功能权重、最近活跃权重和应用进程的功耗,根据用户偏好度、内存占比权重、功能权重、最近活跃权重和应用进程的功耗,确定回收优先级。例如,终端可以采用以下公式计算回收优先级:Yi=(Bi×Di×Ti)/(Ai×Hi),其中,Yi表征回收优先级,Bi表征用户偏好度,Di表征功能权重,Ti表征最近活跃权重,Ai表征内存占比权重,Hi表征功耗权重。It should be noted that the above design one to design five can form a method for determining the recycling priority by any combination. For example, when design one is combined with design three, the terminal can obtain the memory weight and the recent active weight, and determine the recycling priority according to the user preference, the memory weight, and the recent active weight. For example, when design one, design two, design three and design four are combined, the terminal can obtain memory weight, function weight, recent active weight and power consumption of the application process, according to user preference, memory weight, function weight The recent active weights and power consumption of the application process determine the recycling priority. For example, the terminal can calculate the recycling priority by the following formula: Yi=(Bi×Di×Ti)/(Ai×Hi), where Yi represents the recycling priority, Bi represents the user preference, Di represents the functional weight, Ti represents the nearest The active weight, Ai represents the memory weight, and Hi represents the power weight.
205、终端基于每个应用进程的回收优先级,确定多个应用进程中待回收的应用进程。205. The terminal determines, according to a recycling priority of each application process, an application process to be reclaimed in multiple application processes.
终端可以对多个应用进程按照回收优先级进行排序,先将回收优先级最高的应用进程作为待回收的应用进程,以便回收该应用进程占用的内存。之后,若空闲内存仍不满足预设条件,会继续将回收优先级第二高的应用进程作为待回收的应用进程。那么,应用进程的回收优先级越高,越早回收应用进程所占用的内存,应用进程的回收优先级越低,越晚回收应用进程所占用的内存。The terminal can sort the application processes according to the reclaiming priority. The application process with the highest priority is used as the application process to be reclaimed, so as to reclaim the memory occupied by the application process. After that, if the free memory still does not meet the preset condition, the application process with the second highest priority is continuously used as the application process to be recycled. Then, the higher the revocation priority of the application process, the earlier the memory occupied by the application process is reclaimed. The lower the revocation priority of the application process, the later the memory occupied by the application process is reclaimed.
需要说明的是,上述步骤204-步骤205仅是以先基于用户偏好度确定回收优先级,再基于回收优先级确定待回收的应用进程为例进行说明,在实施中也可以直接基于用户偏好度确定待回收的应用进程,其中,若应用进程的用户偏好度越高,则会避免将应用进程作为待回收的应用进程,若应用进程的用户偏好度越低,则优先将应用进程作为待回收的应用进程。It should be noted that the above steps 204-205 are only based on determining the revocation priority based on the user preference, and then determining the application process to be reclaimed based on the reclaiming priority. In the implementation, the user preference may also be directly based on the user preference. Determine the application process to be reclaimed. If the user preference of the application process is higher, the application process is avoided as the application process to be reclaimed. If the user preference of the application process is lower, the application process is preferentially considered as to be recycled. Application process.
通过基于用户偏好度确定待回收的应用进程的方式,可以达到以下技术效果:The following technical effects can be achieved by determining the application process to be recycled based on user preference:
第一,提高回收内存的准确性:对于高频应用进程(即平时频繁运行的应用进程)来说,应用进程的活跃时长会较长,则活跃时长对应的用户偏好度会较高,那么会避免将高频应用进程作为待回收的应用进程,保证高频应用进程的数据驻留在内存中,尽量避免影响高频应用进程的正常运行,同时降低高频应用进程的冷启动概率。First, improve the accuracy of the reclaimed memory: for the high-frequency application process (that is, the application process that runs normally frequently), the active duration of the application process will be longer, and the user preference corresponding to the active duration will be higher, then Avoid the high-frequency application process as the application process to be recycled, ensure that the data of the high-frequency application process resides in the memory, try to avoid affecting the normal operation of the high-frequency application process, and reduce the cold start probability of the high-frequency application process.
第二,提高回收内存的及时性:对于平时不经常运行的应用进程来说,该应用进程的活跃时长会较短,则活跃时长对应的用户偏好度会较小,那么会优先将低频应用进程作为待回收的应用进程,低频应用进程所占用的内存被回收的概率较大,能够及时回收低频应用进程所占用的内存。Second, improve the timeliness of reclaiming memory: for an application process that does not normally run, the active duration of the application process will be shorter, and the user preference corresponding to the active duration will be smaller, then the low-frequency application process will be prioritized. As the application process to be recycled, the memory occupied by the low-frequency application process is highly recovered, and the memory occupied by the low-frequency application process can be recovered in time.
第三,保证回收内存的过程贴近用户的个人使用习惯:考虑到日常生活中不同用户所偏好使用的应用进程可能不同,例如用户A偏好使用即时通信应用的应用进程,用户B偏好使用音乐播放应用的应用进程,用户C偏好使用在线购物应用的应用进程等。本实施例中,并非统一地设置了所有用户对应用进程的用户偏好度,而是由终端以自学习的方式,实时统计每个应用进程的活跃时长来分析出每个应用进程的用户偏好度,每个应用进程的用户偏好度能够反映用户的个人使用习惯,因此结合用户偏好度回收内存时能够满足个性化需求,例如用户A的终端回收即时通信应用的应用进程的内存的概率最小,用户B的终端回收音乐播放应用的应用进程的内存的概率最小等等。Third, the process of ensuring the memory recovery is close to the user's personal usage habits: considering that the application process preferred by different users in daily life may be different, for example, user A prefers the application process using the instant messaging application, and user B prefers to use the music playing application. The application process, user C prefers to use the application process of the online shopping application, and the like. In this embodiment, the user preference of the application process is not uniformly set, but the terminal calculates the user preference of each application process in real time by self-learning. The user preference of each application process can reflect the user's personal usage habits. Therefore, when the memory is recycled in combination with the user preference, the personalized requirement can be satisfied. For example, the probability that the user A's terminal reclaims the application process of the instant messaging application has the smallest probability, and the user has the smallest probability. The terminal of B recycles the memory of the application process of the music playing application with the least probability of the memory and the like.
第四,保证回收内存的过程具有时效性:考虑到用户所偏好的应用进程可以随着时间的推移发生变化,例如某用户过去偏好使用微博应用的应用进程,现在偏好使用即时通信应用的应用进程等。本实施例中,并非预先获取了用户对每个应用进程的用户偏好度,而是由终端在回收应用进程占用的内存时,实时根据应用进程最近在历史运行的活跃时长来计算出每个应用进程的用户偏好度,也即是,动态地自学习应用进程的用户偏好度,每次计算出的用户偏好度可以随着时间进行动态变化,则每次回收应用进程占用的内存的顺序也会进行动态变化,例如终端上个月计算用户偏好度时即时通信应用的应用进程的用户偏好度最高,则回收即时通信应用的应用进程的内存的概率最小,这个月计算用户偏好度时音乐播放应用的应用进程的用户偏好度最高,则回收音乐播放应用的应用进程的内存的概率最小。Fourth, the process of ensuring the recovery of memory is time-sensitive: considering that the application process preferred by the user can change over time, for example, an application process in which a user prefers to use the Weibo application in the past, and now prefers an application using an instant messaging application. Process, etc. In this embodiment, the user preference for each application process is not obtained in advance, but each application is calculated in real time according to the active duration of the historical running process of the application process when the terminal reclaims the memory occupied by the application process. The user preference of the process, that is, the user preference of the self-learning application process, the calculated user preference can be dynamically changed with time, and the order of memory occupied by the application process is recycled each time. Dynamic changes, for example, when the terminal calculates the user preference last month, the application process of the instant messaging application has the highest user preference, and the probability of reclaiming the memory of the application process of the instant messaging application is the smallest, and the music playing application is calculated when the user preference is calculated this month. The application process has the highest user preference, and the probability of reclaiming the memory of the application process of the music playing application is the smallest.
206、终端回收待回收的应用进程占用的内存。206. The terminal reclaims memory occupied by the application process to be recycled.
当终端确定待回收的应用进程后,会回收该应用进程占用的内存。其中,当回收该应用进程占用的内存后,可以再次检测空闲内存是否满足预设条件,当空闲内存已经满足预设条件时,则无需再次确定待回收的应用进程,结束本次回收内存的过程。当空闲内存仍不满足预设条件时,则再次采用本实施例提供的方法,继续确定待回收的应用进程,直至空闲内存满足预设条件为止。After the terminal determines the application process to be recycled, the memory occupied by the application process is reclaimed. After the memory occupied by the application process is reclaimed, it is possible to detect whether the free memory meets the preset condition. When the free memory has met the preset condition, the application process to be reclaimed need not be determined again, and the process of reclaiming the memory is terminated. . When the idle memory still does not meet the preset condition, the method provided in this embodiment is used again to continue to determine the application process to be recovered until the idle memory meets the preset condition.
示例性地,假设当检测到空闲内存不满足预设条件时,确定共有5个处于后台运行的应用进程,当回收了两个应用进程占用的内存后,确定空闲内存已经满足预设条件,则可以结束回收内存的过程,无需继续回收剩余的3个应用进程占用的内存。Exemplarily, when it is detected that the idle memory does not meet the preset condition, it is determined that there are 5 application processes running in the background. After the memory occupied by the two application processes is recovered, it is determined that the free memory has met the preset condition, then You can end the process of reclaiming memory without having to continue to reclaim the memory occupied by the remaining 3 application processes.
可选地,结合根据回收优先级确定待回收的应用进程的设计,终端将回收优先级最高的应用进程作为待回收的应用进程,回收了该应用进程占用的内存后,可以再次检测空闲内存是否满足预设条件,当空闲内存已经满足预设条件时,则无需确定待回收的应用进程,结束本次回收内存的过程。当空闲内存仍不满足预设条件时,则将回收优先级第二高的应用进程作为待回收的应用进程,以便回收回收优先级第二高的应用进程的内存,以此类推。Optionally, in combination with determining the design of the application process to be reclaimed according to the reclaiming priority, the terminal reclaims the application process with the highest priority as the application process to be reclaimed, and after reclaiming the memory occupied by the application process, can detect the free memory again. When the preset condition is met, the process of reclaiming the memory is not required to determine the application process to be reclaimed. When the idle memory still does not meet the preset condition, the application process with the second highest priority is reclaimed as the application process to be reclaimed, so as to reclaim the memory of the application process with the second highest priority, and so on.
针对回收应用进程的内存的具体过程,本实施例提供了以下两种设计:The present embodiment provides the following two designs for the specific process of reclaiming the memory of the application process:
设计一、杀死待回收的应用进程。Design one, kill the application process to be recycled.
杀死待回收的应用进程后,应用进程所占用的内存会释放,达到回收应用进程所占用的内存的效果。可选地,终端可以运行LMK进程,由LMK进程杀死待回收的应用进程。After killing the application process to be reclaimed, the memory occupied by the application process is released, and the effect of reclaiming the memory occupied by the application process is achieved. Optionally, the terminal can run the LMK process, and the LMK process kills the application process to be recycled.
需要说明的是,本实施例以应用进程为统计用户偏好度以及回收内存的单位,当应用开启多个应用进程时,可以仅杀死多个应用进程中的某个应用进程而不杀死其他应用进程,则而应用可以仍保持运行状态。例如某阅读应用可以开启主进程、图片展示子进程、文字 展示子进程等多个应用进程,其中计算用户偏好度时,图片展示子进程由于用户偏好度较低被优先杀死,此时该阅读应用可通过主进程继续运行,文字可通过文字展示子进程继续展示,仅是图片暂时无法显示。It should be noted that, in this embodiment, the application process is a unit for counting user preference and reclaiming memory. When the application starts multiple application processes, only one application process of multiple application processes may be killed without killing other applications. The application process, and the application can still be running. For example, a reading application can open multiple application processes such as a main process, a picture display sub-process, and a text display sub-process. When calculating the user preference, the picture display sub-process is preferentially killed due to the lower user preference, and the reading is performed at this time. The application can continue to run through the main process, and the text can continue to be displayed through the text display subprocess, only the image can not be displayed temporarily.
设计二、将待回收的应用进程在内存中的数据转移至预设存储空间中。Design 2: Transfer the data in the memory of the application process to be recycled to the preset storage space.
终端可以按照回收优先级从高到低的顺序,依次将每个应用进程在内存中的数据转移至预设存储空间中,从而将应用进程在内存占用的内存空闲出来,达到回收应用进程所占用的内存的效果。可选地,可以先将数据进行压缩,压缩后数据的数据量会减小,之后再将压缩后的数据转移至预设存储空间中,例如,假设某应用进程在内存存储了50M的数据,可以将50M的数据压缩成20M,再将20M数据存储至预设存储空间中,则内存会空闲出50M的空间。其中,该预设存储空间可以为zram分区,zram分区也称为Compcache(压缩缓存),是指Linux内核的一个模块,zram可以用内存替代硬盘为操作系统提供存储数据的功能,可以用于存储压缩后的应用进程的数据。The terminal can sequentially transfer the data in the memory of each application process to the preset storage space according to the order of the reclaiming priority, so that the memory occupied by the application process in the memory is freed to be occupied by the recycling application process. The effect of memory. Optionally, the data may be compressed first, and the data volume of the compressed data is reduced, and then the compressed data is transferred to the preset storage space. For example, if an application process stores 50M of data in the memory, You can compress 50M data into 20M, and then store 20M data into the preset storage space, then the memory will be free of 50M space. The preset storage space may be a zram partition, and the zram partition is also called a Compcache (compression cache), which refers to a module of the Linux kernel. The zram can replace the hard disk with a memory to provide a storage data function for the operating system, and can be used for storage. The data of the compressed application process.
可选地,终端可以运行kswapd进程或之前请求内存的进程,由kswapd进程或之前请求内存的进程依次将每个应用进程在内存中的数据转移至预设存储空间中。Optionally, the terminal can run the kswapd process or the process that requests the memory before, and the process of the in-memory data of each application process is sequentially transferred to the preset storage space by the kswapd process or the process that previously requested the memory.
需要说明的是,参见图3,其示出了本公开实施例提供的一种回收内存的方法的设计示意图,开发人员可以参照图3的架构,分模块地设计回收内存过程的程序代码。其中,各种计算因子可以按照属性划分为4个模块,需求模块包括内存需求和空闲内存,用户偏好度模块包括活跃时长、时间段、最近活跃权重和调用频率,应用进程属性模块包括应用进程的内存占比、冷启动时长和进程功能,扩展模块包括应用进程的功耗。另外,每个模块的计算因子可以按照重要性划分为5个等级,开发人员可以按照计算因子的等级设置计算因子的数值范围,例如计算因子的等级越高,即重要性越强时,可以设置计算因子的数值范围较高,计算因子的等级越低,即重要性越弱时,可以设置计算因子的数值范围较低。It should be noted that, referring to FIG. 3, a schematic diagram of a method for reclaiming memory provided by an embodiment of the present disclosure is provided. A developer may design a program code for reclaiming a memory process in a module by referring to the architecture of FIG. 3. The calculation factors may be divided into four modules according to the attribute, the requirement module includes a memory requirement and a free memory, and the user preference module includes an active duration, a time period, a recent active weight, and a calling frequency, and the application process attribute module includes an application process. The memory ratio, cold boot time, and process functions, and the expansion module includes the power consumption of the application process. In addition, the calculation factor of each module can be divided into five levels according to importance. The developer can set the value range of the calculation factor according to the level of the calculation factor. For example, the higher the level of the calculation factor, that is, the stronger the importance, the more can be set. The range of values of the calculation factor is higher, and the lower the level of the calculation factor, that is, the weaker the importance, the lower the range of values of the calculation factor can be set.
本实施例提供的方法,在回收内存时考虑到了用户的使用习惯,结合每个应用进程的用户偏好度确定待回收的应用进程,进而回收应用进程所占用的内存。优先回收用户偏好度较低的应用进程所占用的内存,避免回收用户偏好度较高的应用进程所占用的内存,保证回收各个应用进程的内存时顺序的准确性以及合理性,避免误杀进程以及误将应用进程的数据转移至预设存储空间的情况,从而避免影响应用进程的正常运行,保证回收内存的过程对终端的运行造成的整体影响尽量小。The method provided in this embodiment takes the user's usage habits into consideration when reclaiming the memory, determines the application process to be recycled according to the user preference of each application process, and then recovers the memory occupied by the application process. Priority is given to reclaiming memory occupied by application processes with low user preference, avoiding reclaiming memory occupied by application processes with high user preference, ensuring the accuracy and rationality of retrieving the memory of each application process, and avoiding the killing process and The application process data is transferred to the preset storage space by mistake, so as to avoid affecting the normal operation of the application process, and ensuring that the overall impact of the process of reclaiming memory on the operation of the terminal is as small as possible.
图4是本公开实施例提供的一种回收内存的装置的结构示意图,如图4所示,该装置包括:确定模块401和回收模块402。FIG. 4 is a schematic structural diagram of an apparatus for reclaiming memory according to an embodiment of the present disclosure. As shown in FIG. 4, the apparatus includes: a determining module 401 and a recycling module 402.
确定模块401,用于在检测到空闲内存不满足预设条件时,确定处于后台运行的多个应用进程;The determining module 401 is configured to determine, when the idle memory does not meet the preset condition, determine a plurality of application processes that are running in the background;
该确定模块401,还用于确定该多个应用进程中每个应用进程在当前时间点所属的时间段的用户偏好度,该用户偏好度用于指示应用进程被调用的可能性大小;The determining module 401 is further configured to determine a user preference of a time period to which the application process belongs to the current time point in the plurality of application processes, where the user preference is used to indicate a possibility of the application process being invoked;
该确定模块401,还用于根据该多个应用进程中每个应用进程的用户偏好度,确定该多个应用进程中待回收的应用进程;The determining module 401 is further configured to determine, according to user preference of each application process in the multiple application processes, an application process to be recycled in the multiple application processes;
回收模块402,用于回收该待回收的应用进程占用的内存。The recycling module 402 is configured to recover the memory occupied by the application process to be recycled.
在一种可能的设计中,该确定模块401,还用于:根据该多个应用进程中每个应用进程 在历史运行中该时间段的活跃时长,确定该多个应用进程中每个应用进程在当前时间点所属的时间段的用户偏好度。In a possible design, the determining module 401 is further configured to: determine, according to an active duration of the time period of each application process in the plurality of application processes, the application duration of the multiple application processes User preference for the time period to which the current time point belongs.
在一种可能的设计中,该确定模块401,还用于:In a possible design, the determining module 401 is further configured to:
将该活跃时长作为该用户偏好度;或,Using the active duration as the user preference; or,
计算该活跃时长与活跃时长总和之间的比值,作为该用户偏好度,该活跃时长总和是指该多个应用进程在历史运行中该时间段的活跃时长的和值;或,The ratio of the active duration to the sum of the active durations is calculated as the user preference, and the sum of the active durations is the sum of the active durations of the plurality of application processes in the historical operation; or
计算该活跃时长与该应用进程的冷启动时长之间的乘积,作为该用户偏好度;或,Calculating the product of the active duration and the cold start duration of the application process as the user preference; or
计算该活跃时长与活跃时长总和之间的比值,以及计算该比值与该应用进程的冷启动时长之间的乘积,作为该用户偏好度。The ratio between the active duration and the sum of the active durations is calculated, and the product between the ratio and the cold start duration of the application process is calculated as the user preference.
在一种可能的设计中,该确定模块401,还包括:In a possible design, the determining module 401 further includes:
获取子模块,用于基于该多个应用进程中每个应用进程的用户偏好度,获取该每个应用进程的回收优先级,该每个应用进程的回收优先级与该每个应用进程的用户偏好度负相关;Obtaining a sub-module, configured to obtain, according to user preference of each application process in the multiple application processes, a reclaiming priority of each application process, and a reclaiming priority of each application process and a user of each application process Preference is negatively correlated;
确定子模块,用于基于该每个应用进程的回收优先级,确定该多个应用进程中待回收的应用进程。Determining a sub-module for determining an application process to be reclaimed in the plurality of application processes based on a reclaiming priority of each application process.
在一种可能的设计中,述获取子模块,还用于确定该每个应用进程的最近活跃权重,该每个应用进程的最近活跃权重用于指示该每个应用进程最近活跃的程度;根据该每个应用进程的用户偏好度与该每个应用进程的最近活跃权重,获取该每个应用进程的回收优先级。In a possible design, the obtaining sub-module is further configured to determine a recent active weight of each application process, and a recent active weight of each application process is used to indicate a degree of recent activeness of each application process; The user preference of each application process and the most recent active weight of each application process, and the recycling priority of each application process is obtained.
在一种可能的设计中,该获取子模块,还用于获取该每个应用进程的最近活跃时长,该每个应用进程的最近活跃时长用于指示该每个应用进程最近一次处于前台运行的活跃时长;基于该每个应用进程的最近活跃时长的结束时间点与该当前时间点之间的时间差,对该每个应用进程的最近活跃时长进行衰减以得到衰减后的最近活跃时长,将该衰减后的最近活跃时长作为该最近活跃权重。In a possible design, the obtaining sub-module is further configured to obtain a recent active duration of each application process, where a recent active duration of each application process is used to indicate that each application process is last running in the foreground. The active duration; based on the time difference between the end time point of the latest active duration of each application process and the current time point, attenuating the most recent active duration of each application process to obtain the most recent active duration after the attenuation, The most recent active time after decay is used as the most recent active weight.
在一种可能的设计中,该获取子模块,还用于:确定与该每个应用进程的功能对应的功能权重,该每个应用进程的功能权重用于指示该每个应用进程的功能的重要程度;根据该每个应用进程的用户偏好度与该每个应用进程的功能权重,获取该每个应用进程的回收优先级。In a possible design, the obtaining sub-module is further configured to: determine a function weight corresponding to a function of each application process, where a function weight of each application process is used to indicate a function of each application process The degree of importance; according to the user preference of each application process and the functional weight of each application process, the recycling priority of each application process is obtained.
在一种可能的设计中,该获取子模块,还用于:确定与该每个应用进程的功耗对应的功耗权重,该每个应用进程的功耗权重用于指示该每个应用进程的功耗的大小;根据该每个应用进程的用户偏好度与该每个应用进程的功耗权重,获取该每个应用进程的回收优先级。In a possible design, the obtaining sub-module is further configured to: determine a power consumption weight corresponding to the power consumption of each application process, and the power consumption weight of each application process is used to indicate the each application process The size of the power consumption; according to the user preference of each application process and the power consumption weight of each application process, the recycling priority of each application process is obtained.
在一种可能的设计中,该获取子模块,还用于:确定与该每个应用进程的内存占比对应的内存占比权重,该每个应用进程的内存占比用于指示该每个应用进程占用的内存与总内存开销之间的比值;根据该每个应用进程的用户偏好度与该每个应用进程的内存占比权重,获取该每个应用进程的回收优先级。In a possible design, the obtaining submodule is further configured to: determine a memory ratio weight corresponding to a memory ratio of each application process, and a memory ratio of each application process is used to indicate each of the The ratio of the memory occupied by the application process to the total memory cost; and the reclaiming priority of each application process is obtained according to the user preference of each application process and the memory weight of each application process.
在一种可能的设计中,该获取子模块,还用于:确定该每个应用进程的调用频率,该每个应用进程的调用频率用于指示该多个应用进程在历史运行中该时间段内调用该每个应用进程的总次数;根据该每个应用进程的用户偏好度与该每个应用进程的调用频率,获取 该每个应用进程的回收优先级。In a possible design, the obtaining sub-module is further configured to: determine a calling frequency of each application process, and the calling frequency of each application process is used to indicate that the multiple application processes are in the historical running time period The total number of times each application process is invoked; the revocation priority of each application process is obtained according to the user preference of each application process and the calling frequency of each application process.
在一种可能的设计中,该获取子模块,还用于:获取该每个应用进程的调用记录,该每个应用进程的调用记录用于记录该每个应用进程调用该多个应用进程中该每个应用进程以外的应用进程的事件;基于该每个应用进程的调用记录,确定该每个应用进程的调用频率。In a possible design, the obtaining sub-module is further configured to: obtain a call record of each application process, and the calling record of each application process is used to record that each application process calls the multiple application processes. An event of an application process other than each application process; determining a calling frequency of each application process based on the invocation record of each application process.
在一种可能的设计中,该装置还包括:统计模块,用于统计该多个应用进程中每个应用进程在历史运行中该时间段的活跃时长。In a possible design, the device further includes: a statistics module, configured to count an active duration of the time period of each application process in the plurality of application processes in the historical operation.
在一种可能的设计中,该回收模块402,用于杀死该待回收的应用进程;或,将该待回收的应用进程在内存中的数据转移至预设存储空间。In a possible design, the recovery module 402 is configured to kill the application process to be recycled; or transfer the data in the memory of the application process to be recycled to the preset storage space.
本申请实施例描述的各示例的单元及方法过程,能够以电子硬件、或者计算机软件和电子硬件的结合来实现。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能。The unit and method processes of the examples described in the embodiments of the present application can be implemented by electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the solution. The skilled person can use different methods for each particular application to implement the described functionality.
在本申请所提供的几个实施例中,应该理解到,所揭露的装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式。例如多个单元或组件可以结合或者可以集成到另一个系统,或一些步骤可以忽略,或不执行。此外,各个单元相互之间的耦合或直接耦合或通信连接可以是通过一些接口实现,这些可以是电性、机械或其它的形式。In the several embodiments provided by the present application, it should be understood that the disclosed apparatus and method may be implemented in other manners. For example, the device embodiments described above are merely illustrative. For example, the division of the unit is only a logical function division, and the actual implementation may have another division manner. For example, multiple units or components may be combined or integrated into another system, or some steps may be omitted or not performed. Furthermore, the coupling or direct coupling or communication connection of the various units to each other may be through some interfaces, which may be in electrical, mechanical or other form.
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,既可以位于一个地方,也可以分布到多个网络单元上。The units described as separate components may or may not be physically separate, and may be located in one place or on multiple network elements.
另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
在上述实施例中,可以全部或部分地通过软件、硬件、固件或者其任意组合来实现。当使用软件实现时,可以全部或部分地以计算机程序产品的形式实现。所述计算机程序产品包括一个或多个计算机指令。在计算机上加载和执行所述计算机程序指令时,全部或部分地产生按照本发明实施例所述的流程或功能。所述计算机可以是通用计算机、专用计算机、计算机网络、或者其他可编程装置。所述计算机指令可以存储在计算机可读存储介质中,或者从一个计算机可读存储介质向另一个计算机可读存储介质传输,例如,所述计算机指令可以从一个网站站点、计算机、服务器或数据中心通过有线(例如同轴电缆、光纤、数字用户线(DSL))或无线(例如红外、无线、微波等)方式向另一个网站站点、计算机、服务器或数据中心进行传输。所述计算机可读存储介质可以是计算机能够存取的任何可用介质或者是包含一个或多个可用介质集成的服务器、数据中心等数据存储设备。所述可用介质可以是磁性介质,(例如,软盘、硬盘、磁带)、光介质(例如,DVD)、或者半导体介质(例如固态硬盘Solid State Disk(SSD))等。In the above embodiments, it may be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented in software, it may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the processes or functions described in accordance with embodiments of the present invention are generated in whole or in part. The computer can be a general purpose computer, a special purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer readable storage medium or transferred from one computer readable storage medium to another computer readable storage medium, for example, the computer instructions can be from a website site, computer, server or data center Transfer to another website site, computer, server, or data center by wire (eg, coaxial cable, fiber optic, digital subscriber line (DSL), or wireless (eg, infrared, wireless, microwave, etc.). The computer readable storage medium can be any available media that can be accessed by a computer or a data storage device such as a server, data center, or the like that includes one or more available media. The usable medium may be a magnetic medium (eg, a floppy disk, a hard disk, a magnetic tape), an optical medium (eg, a DVD), or a semiconductor medium (such as a solid state disk (SSD)).
Claims (28)
- 一种回收内存的方法,其特征在于,所述方法包括:A method of recycling memory, the method comprising:在检测到空闲内存不满足预设条件时,确定处于后台运行的多个应用进程;Determining a plurality of application processes running in the background when detecting that the free memory does not satisfy the preset condition;确定所述多个应用进程中每个应用进程在当前时间点所属的时间段的用户偏好度,所述用户偏好度用于指示应用进程被调用的可能性大小;Determining a user preference of a time period to which each application process in the plurality of application processes belongs at a current time point, the user preference being used to indicate a possibility of an application process being invoked;根据所述多个应用进程中每个应用进程的用户偏好度,确定所述多个应用进程中待回收的应用进程;Determining, according to a user preference of each application process in the multiple application processes, an application process to be recycled in the multiple application processes;回收所述待回收的应用进程占用的内存。Reclaiming the memory occupied by the application process to be recycled.
- 根据权利要求1所述的方法,其特征在于,所述确定所述多个应用进程中每个应用进程在当前时间点所属的时间段的用户偏好度,包括:The method according to claim 1, wherein the determining the user preference of each of the plurality of application processes in the time period to which the current time point belongs includes:根据所述多个应用进程中每个应用进程在历史运行中所述时间段的活跃时长,确定所述多个应用进程中每个应用进程在当前时间点所属的时间段的用户偏好度。And determining, according to the active duration of the time period of each application process in the historical operation, the user preference of each application process in the plurality of application processes at a time period to which the current time point belongs.
- 根据权利要求2所述的方法,其特征在于,所述根据所述多个应用进程中每个应用进程在历史运行中所述时间段的活跃时长,确定所述多个应用进程中每个应用进程在当前时间点所属的时间段的用户偏好度,包括:The method according to claim 2, wherein the determining, according to the active duration of the time period of each application process in the historical operation, determines each application of the plurality of application processes The user preference of the time period to which the process belongs at the current time point, including:将所述活跃时长作为所述用户偏好度;或,Using the active duration as the user preference; or,计算所述活跃时长与活跃时长总和之间的比值,作为所述用户偏好度,所述活跃时长总和是指所述多个应用进程在历史运行中所述时间段的活跃时长的和值;或,Calculating a ratio of the active duration to the sum of the active durations, where the sum of the active durations refers to a sum of active durations of the plurality of application processes in the historical operation; or ,计算所述活跃时长与所述应用进程的冷启动时长之间的乘积,作为所述用户偏好度;或,Calculating a product between the active duration and a cold start duration of the application process as the user preference; or计算所述活跃时长与活跃时长总和之间的比值,以及计算所述比值与所述应用进程的冷启动时长之间的乘积,作为所述用户偏好度。Calculating a ratio between the active duration and the sum of active durations, and calculating a product between the ratio and a cold start duration of the application process as the user preference.
- 根据权利要求1-3任一所述的方法,其特征在于,所述根据所述多个应用进程中每个应用进程的用户偏好度,确定所述多个应用进程中待回收的应用进程,包括:The method according to any one of claims 1-3, wherein the determining, according to a user preference of each application process in the plurality of application processes, an application process to be recycled in the plurality of application processes, include:基于所述多个应用进程中每个应用进程的用户偏好度,获取所述每个应用进程的回收优先级,所述每个应用进程的回收优先级与所述每个应用进程的用户偏好度负相关;Retrieving a revocation priority of each application process based on a user preference of each application process in the plurality of application processes, a reclaiming priority of each application process, and a user preference of each application process Negative correlation基于所述每个应用进程的回收优先级,确定所述多个应用进程中待回收的应用进程。Determining an application process to be reclaimed among the plurality of application processes based on a recycling priority of each application process.
- 根据权利要求4所述的方法,其特征在于,所述基于所述多个应用进程中每个应用进程的用户偏好度,获取所述每个应用进程的回收优先级,包括:The method according to claim 4, wherein the obtaining a revocation priority of each application process based on user preference of each application process in the plurality of application processes comprises:确定所述每个应用进程的最近活跃权重,所述每个应用进程的最近活跃权重用于指示所述每个应用进程最近活跃的程度;Determining a recent active weight of each application process, the most recent active weight of each application process is used to indicate a degree of recent activeness of each application process;根据所述每个应用进程的用户偏好度与所述每个应用进程的最近活跃权重,获取所述每个应用进程的回收优先级。Retrieving the revocation priority of each application process according to the user preference of each application process and the most recent active weight of each application process.
- 根据权利要求5所述的方法,其特征在于,所述确定所述每个应用进程的最近活跃权 重,包括:The method according to claim 5, wherein the determining the most recent active weight of each application process comprises:获取所述每个应用进程的最近活跃时长,所述每个应用进程的最近活跃时长用于指示所述每个应用进程最近一次处于前台运行的活跃时长;Obtaining the latest active duration of each application process, where the latest active duration of each application process is used to indicate the active duration of the last time each application process is running in the foreground;基于所述每个应用进程的最近活跃时长的结束时间点与所述当前时间点之间的时间差,对所述每个应用进程的最近活跃时长进行衰减以得到衰减后的最近活跃时长,将所述衰减后的最近活跃时长作为所述最近活跃权重。And attenuating the most recent active duration of each application process to obtain the most recent active duration after the attenuation based on the time difference between the end time point of the most recent active duration of the each application process and the current time point. The most recent active duration after the decay is used as the most recent active weight.
- 根据权利要求4所述的方法,其特征在于,所述基于所述多个应用进程中每个应用进程的用户偏好度,获取所述每个应用进程的回收优先级,包括:The method according to claim 4, wherein the obtaining a revocation priority of each application process based on user preference of each application process in the plurality of application processes comprises:确定与所述每个应用进程的功能对应的功能权重,所述每个应用进程的功能权重用于指示所述每个应用进程的功能的重要程度;Determining a function weight corresponding to the function of each application process, the function weight of each application process is used to indicate the importance degree of the function of each application process;根据所述每个应用进程的用户偏好度与所述每个应用进程的功能权重,获取所述每个应用进程的回收优先级。Retrieving the revocation priority of each application process according to the user preference of each application process and the function weight of each application process.
- 根据权利要求4所述的方法,其特征在于,所述基于所述多个应用进程中每个应用进程的用户偏好度,获取所述每个应用进程的回收优先级,包括:The method according to claim 4, wherein the obtaining a revocation priority of each application process based on user preference of each application process in the plurality of application processes comprises:确定与所述每个应用进程的功耗对应的功耗权重,所述每个应用进程的功耗权重用于指示所述每个应用进程的功耗的大小;Determining power consumption weights corresponding to power consumption of each application process, the power consumption weight of each application process is used to indicate a size of power consumption of each application process;根据所述每个应用进程的用户偏好度与所述每个应用进程的功耗权重,获取所述每个应用进程的回收优先级。Retrieving the revocation priority of each application process according to the user preference of each application process and the power consumption weight of each application process.
- 根据权利要求4所述的方法,其特征在于,所述基于所述多个应用进程中每个应用进程的用户偏好度,获取所述每个应用进程的回收优先级,包括:The method according to claim 4, wherein the obtaining a revocation priority of each application process based on user preference of each application process in the plurality of application processes comprises:确定与所述每个应用进程的内存占比对应的内存占比权重,所述每个应用进程的内存占比用于指示所述每个应用进程占用的内存与总内存开销之间的比值;Determining a memory ratio corresponding to a memory ratio of each application process, where a memory ratio of each application process is used to indicate a ratio between a memory occupied by each application process and a total memory overhead;根据所述每个应用进程的用户偏好度与所述每个应用进程的内存占比权重,获取所述每个应用进程的回收优先级。Retrieving the revocation priority of each application process according to the user preference of each application process and the memory weight of each application process.
- 根据权利要求4所述的方法,其特征在于,所述基于所述多个应用进程中每个应用进程的用户偏好度,获取所述每个应用进程的回收优先级,包括:The method according to claim 4, wherein the obtaining a revocation priority of each application process based on user preference of each application process in the plurality of application processes comprises:确定所述每个应用进程的调用频率,所述每个应用进程的调用频率用于指示所述多个应用进程在历史运行中所述时间段内调用所述每个应用进程的总次数;Determining a frequency of invocation of each application process, the calling frequency of each application process is used to indicate the total number of times the plurality of application processes invoke the each application process in the time period in the historical operation;根据所述每个应用进程的用户偏好度与所述每个应用进程的调用频率,获取所述每个应用进程的回收优先级。Retrieving the revocation priority of each application process according to the user preference of each application process and the calling frequency of each application process.
- 根据权利要求10所述的方法,其特征在于,所述确定所述每个应用进程的调用频率,包括:The method according to claim 10, wherein the determining the calling frequency of each application process comprises:获取所述每个应用进程的调用记录,所述每个应用进程的调用记录用于记录所述每个应用进程调用所述多个应用进程中所述每个应用进程以外的应用进程的事件;Obtaining a call record of each application process, where the call record of each application process is used to record an event of each application process calling an application process other than each of the plurality of application processes;基于所述每个应用进程的调用记录,确定所述每个应用进程的调用频率。Determining the calling frequency of each application process based on the call record of each application process.
- 根据权利要求2至11任一所述的方法,其特征在于,所述确定处于后台运行的多个应用进程之前,所述方法还包括:The method according to any one of claims 2 to 11, wherein before the determining a plurality of application processes running in the background, the method further comprises:统计所述多个应用进程中每个应用进程在历史运行中所述时间段的活跃时长。Counting the active duration of the time period of each application process in the plurality of application processes during the historical operation.
- 根据权利要求1-12任一所述的方法,其特征在于,所述回收所述待回收的应用进程占用的内存,包括:The method according to any one of claims 1 to 12, wherein the reclaiming the memory occupied by the application process to be recycled includes:杀死所述待回收的应用进程;或,Killing the application process to be recycled; or,将所述待回收的应用进程在内存中的数据转移至预设存储空间。Transfer the data in the memory of the application process to be recycled to a preset storage space.
- 一种回收内存的装置,其特征在于,所述装置包括:A device for recovering a memory, characterized in that the device comprises:确定模块,用于在检测到空闲内存不满足预设条件时,确定处于后台运行的多个应用进程;a determining module, configured to determine, when the idle memory does not meet the preset condition, determine a plurality of application processes running in the background;所述确定模块,还用于确定所述多个应用进程中每个应用进程在当前时间点所属的时间段的用户偏好度,所述用户偏好度用于指示应用进程被调用的可能性大小;The determining module is further configured to determine a user preference of a time period that each application process in the multiple application processes belongs to at a current time point, where the user preference is used to indicate a possibility of an application process being invoked;所述确定模块,还用于根据所述多个应用进程中每个应用进程的用户偏好度,确定所述多个应用进程中待回收的应用进程;The determining module is further configured to determine, according to user preference of each application process in the multiple application processes, an application process to be recycled in the multiple application processes;回收模块,用于回收所述待回收的应用进程占用的内存。The recycling module is configured to recover the memory occupied by the application process to be recycled.
- 根据权利要求14所述的装置,其特征在于,所述确定模块,还用于:根据所述多个应用进程中每个应用进程在历史运行中所述时间段的活跃时长,确定所述多个应用进程中每个应用进程在当前时间点所属的时间段的用户偏好度。The device according to claim 14, wherein the determining module is further configured to: determine, according to an active duration of the time period of each application process in the historical operation, The user preference of each application process in the time period to which the application process belongs at the current time point.
- 根据权利要求15所述的装置,其特征在于,所述确定模块,还用于:The device according to claim 15, wherein the determining module is further configured to:将所述活跃时长作为所述用户偏好度;或,Using the active duration as the user preference; or,计算所述活跃时长与活跃时长总和之间的比值,作为所述用户偏好度,所述活跃时长总和是指所述多个应用进程在历史运行中所述时间段的活跃时长的和值;或,Calculating a ratio of the active duration to the sum of the active durations, where the sum of the active durations refers to a sum of active durations of the plurality of application processes in the historical operation; or ,计算所述活跃时长与所述应用进程的冷启动时长之间的乘积,作为所述用户偏好度;或,Calculating a product between the active duration and a cold start duration of the application process as the user preference; or计算所述活跃时长与活跃时长总和之间的比值,以及计算所述比值与所述应用进程的冷启动时长之间的乘积,作为所述用户偏好度。Calculating a ratio between the active duration and the sum of active durations, and calculating a product between the ratio and a cold start duration of the application process as the user preference.
- 根据权利要求14-16任一所述的装置,其特征在于,所述确定模块,还包括:The device according to any one of claims 14-16, wherein the determining module further comprises:获取子模块,用于基于所述多个应用进程中每个应用进程的用户偏好度,获取所述每个应用进程的回收优先级,所述每个应用进程的回收优先级与所述每个应用进程的用户偏好度负相关;Obtaining a sub-module, configured to acquire, according to a user preference of each application process in the multiple application processes, a reclaim priority of each application process, where each application process has a reclaim priority and each of the The user preference of the application process is negatively correlated;确定子模块,用于基于所述每个应用进程的回收优先级,确定所述多个应用进程中待回收的应用进程。Determining a sub-module, configured to determine, according to a recycling priority of each application process, an application process to be reclaimed among the multiple application processes.
- 根据权利要求17所述的装置,其特征在于,所述获取子模块,还用于确定所述每个应用进程的最近活跃权重,所述每个应用进程的最近活跃权重用于指示所述每个应用进程最近活跃的程度;根据所述每个应用进程的用户偏好度与所述每个应用进程的最近活跃权重,获取所述每个应用进程的回收优先级。The apparatus according to claim 17, wherein the obtaining submodule is further configured to determine a most recent active weight of each application process, and a recent active weight of each application process is used to indicate the each The extent to which the application process is recently active; the revocation priority of each application process is obtained according to the user preference of each application process and the most recent active weight of each application process.
- 根据权利要求18所述的装置,其特征在于,所述获取子模块,还用于获取所述每个应用进程的最近活跃时长,所述每个应用进程的最近活跃时长用于指示所述每个应用进程最近一次处于前台运行的活跃时长;基于所述每个应用进程的最近活跃时长的结束时间点与所述当前时间点之间的时间差,对所述每个应用进程的最近活跃时长进行衰减以得到衰减后的最近活跃时长,将所述衰减后的最近活跃时长作为所述最近活跃权重。The device according to claim 18, wherein the obtaining sub-module is further configured to obtain a recent active duration of each application process, and a latest active duration of each application process is used to indicate the each The active time period in which the application process was last run in the foreground; based on the time difference between the end time point of the latest active time of each application process and the current time point, the latest active time of each application process is performed. Attenuation to obtain the most recent active duration after attenuation, and the decayed most recent active duration is taken as the most recent active weight.
- 根据权利要求17所述的装置,其特征在于,所述获取子模块,还用于:确定与所述每个应用进程的功能对应的功能权重,所述每个应用进程的功能权重用于指示所述每个应用进程的功能的重要程度;根据所述每个应用进程的用户偏好度与所述每个应用进程的功能权重,获取所述每个应用进程的回收优先级。The apparatus according to claim 17, wherein the obtaining submodule is further configured to: determine a function weight corresponding to a function of each application process, and a function weight of each application process is used to indicate The importance of the function of each application process; obtaining the reclaim priority of each application process according to the user preference of each application process and the functional weight of each application process.
- 根据权利要求17所述的装置,其特征在于,所述获取子模块,还用于:确定与所述每个应用进程的功耗对应的功耗权重,所述每个应用进程的功耗权重用于指示所述每个应用进程的功耗的大小;根据所述每个应用进程的用户偏好度与所述每个应用进程的功耗权重,获取所述每个应用进程的回收优先级。The apparatus according to claim 17, wherein the obtaining submodule is further configured to: determine a power consumption weight corresponding to the power consumption of each application process, and a power consumption weight of each application process And a size of the power consumption of each application process is obtained, and a recycling priority of each application process is obtained according to the user preference of each application process and the power consumption weight of each application process.
- 根据权利要求17所述的装置,其特征在于,所述获取子模块,还用于:确定与所述每个应用进程的内存占比对应的内存占比权重,所述每个应用进程的内存占比用于指示所述每个应用进程占用的内存与总内存开销之间的比值;根据所述每个应用进程的用户偏好度与所述每个应用进程的内存占比权重,获取所述每个应用进程的回收优先级。The device according to claim 17, wherein the obtaining submodule is further configured to: determine a memory ratio weight corresponding to a memory ratio of each application process, and the memory of each application process The ratio is used to indicate the ratio between the memory occupied by each application process and the total memory overhead; and the user preference is calculated according to the user preference of each application process and the memory weight of each application process. Recycling priority for each application process.
- 根据权利要求17所述的装置,其特征在于,所述获取子模块,还用于:确定所述每个应用进程的调用频率,所述每个应用进程的调用频率用于指示所述多个应用进程在历史运行中所述时间段内调用所述每个应用进程的总次数;根据所述每个应用进程的用户偏好度与所述每个应用进程的调用频率,获取所述每个应用进程的回收优先级。The apparatus according to claim 17, wherein the obtaining submodule is further configured to: determine a calling frequency of each application process, and the calling frequency of each application process is used to indicate the multiple The application process invokes the total number of times of each application process in the time period of the historical operation; and acquires each application according to the user preference of each application process and the calling frequency of each application process. The recycling priority of the process.
- 根据权利要求23所述的装置,其特征在于,所述获取子模块,还用于:获取所述每个应用进程的调用记录,所述每个应用进程的调用记录用于记录所述每个应用进程调用所述多个应用进程中所述每个应用进程以外的应用进程的事件;基于所述每个应用进程的调用记录,确定所述每个应用进程的调用频率。The apparatus according to claim 23, wherein the obtaining submodule is further configured to: acquire a call record of each application process, and the call record of each application process is used to record each of the An application process invokes an event of an application process other than each of the plurality of application processes; and based on the call record of each application process, determines a calling frequency of each application process.
- 根据权利要求15至24任一所述的装置,其特征在于,所述装置还包括:The device according to any one of claims 15 to 24, wherein the device further comprises:统计模块,用于统计所述多个应用进程中每个应用进程在历史运行中所述时间段的活跃时长。The statistics module is configured to count the active duration of the time period of each application process in the plurality of application processes during the historical operation.
- 根据权利要求14-25任一所述的装置,其特征在于,所述回收模块,用于杀死所述待回收的应用进程;或,将所述待回收的应用进程在内存中的数据转移至预设存储空间。The device according to any one of claims 14-25, wherein the recycling module is configured to kill the application process to be recycled; or transfer the data of the application process to be recycled in memory To the default storage space.
- 一种回收内存的装置,其特征在于,所述回收内存的装置包括:The device for recovering a memory is characterized in that: the device for recovering memory comprises:存储器,用于存储程序;Memory for storing programs;处理器,用于执行所述存储器存储的所述程序,当所述程序被执行时,所述处理器用于执行如权利要求1-13中任一所述的步骤。A processor for executing the program stored by the memory, the processor for performing the steps of any of claims 1-13 when the program is executed.
- 一种计算机可读存储介质,其特征在于,包括指令,当其在计算机上运行时,使得计算机执行如权利要求1-13任意一项所述的方法。A computer readable storage medium, comprising instructions that, when run on a computer, cause the computer to perform the method of any of claims 1-13.
Applications Claiming Priority (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810022138.XA CN110018899B (en) | 2018-01-10 | 2018-01-10 | Method and device for recycling memory |
CN201810022138.X | 2018-01-10 |
Publications (1)
Publication Number | Publication Date |
---|---|
WO2019136963A1 true WO2019136963A1 (en) | 2019-07-18 |
Family
ID=67188060
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
PCT/CN2018/099419 WO2019136963A1 (en) | 2018-01-10 | 2018-08-08 | Method and device for reclaiming memory |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN110018899B (en) |
WO (1) | WO2019136963A1 (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
EP4124951A1 (en) * | 2021-07-27 | 2023-02-01 | Beijing Xiaomi Mobile Software Co., Ltd. | Memory management method and system for android system, and storage medium |
Families Citing this family (10)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110413415B (en) * | 2019-07-30 | 2023-10-17 | 努比亚技术有限公司 | Memory management control method, equipment and computer readable storage medium |
CN112835689B (en) * | 2019-11-25 | 2024-07-26 | 航天信息股份有限公司 | Method and device for controlling application process |
CN111143844B (en) * | 2019-12-25 | 2022-01-28 | 杭州安恒信息安全技术有限公司 | Safety detection method and system for Internet of things equipment and related device |
CN111274039B (en) * | 2020-02-14 | 2023-12-08 | Oppo广东移动通信有限公司 | Memory recycling method and device, storage medium and electronic equipment |
CN113778816A (en) * | 2020-05-21 | 2021-12-10 | 北京小米移动软件有限公司 | Process false killing rate determination method and device, intelligent equipment and medium |
CN111756927B (en) * | 2020-06-23 | 2021-06-01 | 广东小天才科技有限公司 | Output method of positioning information, terminal equipment and storage medium |
CN112231016A (en) * | 2020-10-27 | 2021-01-15 | 山东云缦智能科技有限公司 | Android process management mechanism processing method based on application starting frequency |
CN113467958B (en) * | 2021-09-02 | 2021-12-14 | 腾讯科技(深圳)有限公司 | Data processing method, device, equipment and readable storage medium |
CN113986559B (en) * | 2021-12-24 | 2022-06-24 | 荣耀终端有限公司 | Memory management method and related device |
CN114385357A (en) * | 2021-12-31 | 2022-04-22 | 北京梧桐车联科技有限责任公司 | Memory recovery method, device, equipment and storage medium |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105701025A (en) * | 2015-12-31 | 2016-06-22 | 华为技术有限公司 | Memory recovery method and device |
CN106775809A (en) * | 2016-11-15 | 2017-05-31 | 北京奇虎科技有限公司 | A kind of method of mobile terminal internal memory cleaning, device and mobile terminal |
CN106776030A (en) * | 2016-12-21 | 2017-05-31 | 维沃移动通信有限公司 | The method and mobile terminal of a kind of dynamic managing internal memory |
CN107133094A (en) * | 2017-06-05 | 2017-09-05 | 努比亚技术有限公司 | Application management method, mobile terminal and computer-readable recording medium |
US20170347320A1 (en) * | 2014-11-28 | 2017-11-30 | Samsung Electronics Co., Ltd. | Device and method for controlling standby power of mobile terminal |
Family Cites Families (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103902437A (en) * | 2014-03-11 | 2014-07-02 | 深圳市同洲电子股份有限公司 | Detecting method and server |
CN104598315A (en) * | 2014-12-12 | 2015-05-06 | 广州三星通信技术研究有限公司 | Memory managing method, device and terminal |
CN105354093A (en) * | 2015-12-09 | 2016-02-24 | 广东欧珀移动通信有限公司 | Memory management method and mobile terminal |
CN107133097B (en) * | 2017-04-16 | 2020-06-16 | 深圳前海财信云科技有限公司 | Memory optimization method and device |
CN107479967A (en) * | 2017-07-04 | 2017-12-15 | 深圳天珑无线科技有限公司 | A kind of automatic method and intelligent terminal for removing internal memory |
CN107402804B (en) * | 2017-07-31 | 2019-12-10 | Oppo广东移动通信有限公司 | background process control method and device, storage medium and electronic equipment |
CN107491353A (en) * | 2017-09-11 | 2017-12-19 | 深圳天珑无线科技有限公司 | Method for recovering internal storage, device and computer-readable recording medium |
-
2018
- 2018-01-10 CN CN201810022138.XA patent/CN110018899B/en active Active
- 2018-08-08 WO PCT/CN2018/099419 patent/WO2019136963A1/en active Application Filing
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20170347320A1 (en) * | 2014-11-28 | 2017-11-30 | Samsung Electronics Co., Ltd. | Device and method for controlling standby power of mobile terminal |
CN105701025A (en) * | 2015-12-31 | 2016-06-22 | 华为技术有限公司 | Memory recovery method and device |
CN106775809A (en) * | 2016-11-15 | 2017-05-31 | 北京奇虎科技有限公司 | A kind of method of mobile terminal internal memory cleaning, device and mobile terminal |
CN106776030A (en) * | 2016-12-21 | 2017-05-31 | 维沃移动通信有限公司 | The method and mobile terminal of a kind of dynamic managing internal memory |
CN107133094A (en) * | 2017-06-05 | 2017-09-05 | 努比亚技术有限公司 | Application management method, mobile terminal and computer-readable recording medium |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
EP4124951A1 (en) * | 2021-07-27 | 2023-02-01 | Beijing Xiaomi Mobile Software Co., Ltd. | Memory management method and system for android system, and storage medium |
Also Published As
Publication number | Publication date |
---|---|
CN110018899B (en) | 2021-09-07 |
CN110018899A (en) | 2019-07-16 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
WO2019136963A1 (en) | Method and device for reclaiming memory | |
US20240054079A1 (en) | Memory Management Method and Apparatus, Electronic Device, and Computer-Readable Storage Medium | |
CN111176698B (en) | Dynamic adjustment of mobile devices based on peer-to-peer event data | |
WO2020078135A1 (en) | Resource scheduling method and computer device | |
KR101980138B1 (en) | Dynamic adjustment of mobile device based on user activity | |
US7698513B2 (en) | Methods and mechanisms for proactive memory management | |
KR20060129873A (en) | Method for executing garbage collection of mobile terminal | |
EP3819773A1 (en) | Data prefetching method and terminal device | |
CN112131005B (en) | Resource adjustment strategy determination method and device | |
CN110837480A (en) | Processing method and device of cache data, computer storage medium and electronic equipment | |
WO2021077261A1 (en) | Application program management method and apparatus, electronic device, and storage medium | |
US11422857B2 (en) | Multi-level scheduling | |
WO2021164560A1 (en) | Multi-core chip and scheduling method therefor | |
CN110688062A (en) | Cache space management method and device | |
CN110647392A (en) | Intelligent elastic expansion method based on container cluster | |
CN111045824A (en) | Application control method and device, electronic equipment and computer readable medium | |
CN110515721A (en) | A kind of application management method, device, terminal and computer storage medium | |
CN113094392A (en) | Data caching method and device | |
CN116700816B (en) | Resource management method and electronic equipment | |
CN112131029B (en) | Broadcast processing method, apparatus, computer device and storage medium | |
CN110928635B (en) | Working set dividing method and system | |
CN111400148A (en) | Application program management method, device, equipment and medium | |
CN110401708A (en) | Session processing system and method based on server load state | |
JP2005025727A (en) | Information storage control device, information storage control method, and information storage control program | |
CN115174289B (en) | Log data storage method and device, storage medium and electronic device |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 18899571 Country of ref document: EP Kind code of ref document: A1 |
|
NENP | Non-entry into the national phase |
Ref country code: DE |
|
122 | Ep: pct application non-entry in european phase |
Ref document number: 18899571 Country of ref document: EP Kind code of ref document: A1 |