WO2017114288A1 - 一种内存回收方法及装置 - Google Patents

一种内存回收方法及装置 Download PDF

Info

Publication number
WO2017114288A1
WO2017114288A1 PCT/CN2016/111557 CN2016111557W WO2017114288A1 WO 2017114288 A1 WO2017114288 A1 WO 2017114288A1 CN 2016111557 W CN2016111557 W CN 2016111557W WO 2017114288 A1 WO2017114288 A1 WO 2017114288A1
Authority
WO
WIPO (PCT)
Prior art keywords
memory
application
user
terminal
recovery
Prior art date
Application number
PCT/CN2016/111557
Other languages
English (en)
French (fr)
Inventor
王斌田
裘稀石
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Priority to EP16881077.8A priority Critical patent/EP3388946B1/en
Priority to KR1020187020861A priority patent/KR20180097674A/ko
Priority to BR112018013524-0A priority patent/BR112018013524B1/pt
Priority to KR1020207027212A priority patent/KR102206364B1/ko
Publication of WO2017114288A1 publication Critical patent/WO2017114288A1/zh
Priority to US16/023,126 priority patent/US11023372B2/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/0223User address space allocation, e.g. contiguous or non contiguous base addressing
    • G06F12/023Free address space management
    • G06F12/0253Garbage collection, i.e. reclamation of unreferenced memory
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/0223User address space allocation, e.g. contiguous or non contiguous base addressing
    • G06F12/023Free address space management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/34Recording or statistical evaluation of computer activity, e.g. of down time, of input/output operation ; Recording or statistical evaluation of user activity, e.g. usability assessment
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2212/00Indexing scheme relating to accessing, addressing or allocation within memory systems or architectures
    • G06F2212/10Providing a specific technical effect
    • G06F2212/1016Performance improvement
    • G06F2212/1024Latency reduction
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2212/00Indexing scheme relating to accessing, addressing or allocation within memory systems or architectures
    • G06F2212/10Providing a specific technical effect
    • G06F2212/1041Resource optimization
    • G06F2212/1044Space efficiency improvement
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2212/00Indexing scheme relating to accessing, addressing or allocation within memory systems or architectures
    • G06F2212/72Details relating to flash memory management
    • G06F2212/7205Cleaning, compaction, garbage collection, erase control

Definitions

  • the present application relates to the field of computer technologies, and in particular, to a memory recovery method and apparatus.
  • the memory capacity of terminal devices tends to be relatively small, mostly 1 to 2G.
  • the kernel's demand for application memory is based on the principle of satisfying as much as possible. This leads to applications that consume relatively large amounts of memory (such as cameras) on mobile phones and other terminal products. Memory (for example, some applications will apply for 300MB to 500MB of memory in an instant) and the card may even cause the application to repeatedly exit and restart.
  • the memory recovery strategy of the Linux system is triggered when the memory is insufficient. For example, when an application is started or switched to the foreground interface, the application process of the user state applies for memory to the kernel state, and if the application needs to occupy more memory than the system free memory. , it will trigger the memory recovery, specifically through the Least Recently Used (LRU) algorithm to select the longest and least used memory for recycling, in addition, through memory compression, the same page merge, memory fragmentation Finishing and other memory recovery.
  • LRU Least Recently Used
  • the Android system triggers memory reclamation in the kernel state by setting the free memory level in the kernel state. For example, if the memory is less than n 1 MB, the application process with the lowest priority is killed, and if the memory is less than n 2 (n) 1 ⁇ n 2 )MB, the application process with the highest priority is released.
  • the above memory recovery strategy triggers memory reclamation when the kernel state finds that there is less free memory available, which may cause the memory with low utilization rate in the system to be released in time.
  • the memory recovery is triggered when the free memory is found to be insufficient, it is easy to cause the currently running application to be stuck due to the inability to apply for the required memory in time.
  • the present application provides a memory recovery method and device, which are used to solve the problem that the memory recovery is not timely and the application is likely to be stuck.
  • the present application provides a memory recovery method, which is executed in a user state: monitoring information used by a user to be used by a user and memory occupation information; if information is used by a user according to an application installed in the terminal, and information occupied by memory At least one of determining that the memory recovery condition is currently satisfied, determining an application to be reclaimed from the currently running application of the terminal according to information and memory usage information used by the user currently running in the terminal, and calling
  • the memory recycling interface provided by kernel mode performs memory reclamation.
  • the application actively performs memory recovery by using an application installed in the user state monitoring terminal by the user to operate and use the memory, thereby speeding up the memory recovery frequency when the application is frequently used by the user and the memory usage is large. To ensure the normal use of memory.
  • the current memory recovery condition is determined, including: information used by the user according to the application installed in the terminal, and memory occupation information. Determine the memory reclamation interval; when the current time reaches the memory reclamation time indicated by the memory reclamation interval, determine that the memory reclamation condition is currently satisfied.
  • the memory recovery time interval is first determined according to the rule of the user using the application, and then the memory recovery is actively performed according to the memory recovery time indicated by the memory collection time interval. In this way, the memory is scheduledly recycled, and the terminal can be made. The available free memory is kept at a good level.
  • an optional manner for determining a memory collection time interval is: respectively determining information used by the user to operate the application installed in the terminal in each of the preset at least one time period and The memory occupation information is determined for each time period of the at least one time period according to the information and the memory occupation information used by the user in the terminal during the time period, and determined during the time period. Memory reclamation interval.
  • This method can be used because the user operates differently in different time periods. By using different memory reclamation intervals in different time periods, it is possible to further improve the timeliness of memory reclamation while avoiding wasting system resources due to frequent execution of unnecessary memory reclamation processes.
  • determining, according to the memory occupation information of the application installed in the terminal, that the memory recovery condition is currently met if: determining that the idle memory in the system is less than the first set threshold, determining that the memory recovery condition is currently satisfied.
  • determining, according to the information and memory occupation information used by the user, that the application installed in the terminal is currently satisfying the memory recovery condition includes: if the application is detected to be activated or switched to the foreground interface, according to the application The memory usage information, and the size of the free memory in the system, to determine whether memory recovery is required; if memory recovery is required, it is determined that the memory recovery condition is currently satisfied.
  • this method can ensure the normal operation of the newly launched application or the application switched to the front-end interface, thereby improving system performance and improving the user experience.
  • determining, according to information used by the user that the application installed in the terminal is used by the user, that the current memory recovery condition is met including: if the number of applications currently running in the background is greater than the number of applications allowed to run in the background, Then determine that the memory reclamation condition is currently satisfied.
  • the number of applications allowed to run in the background can be set at intervals according to the current free memory size. Since the application running in the background is usually not the application that the user is using, limiting the number of applications in this part can avoid excessive invalid use of memory.
  • an option for determining an application to be reclaimed memory and performing memory reclamation by calling a memory reclaiming interface provided by the kernel state is: selecting according to a priority order of the pre-stored reclaimed memory application.
  • An application currently running in the terminal that is not in use by the user determining whether the current time is in a high probability usage period of the selected application, and the high probability usage period of the application is determined based on information used by the user to be operated by the user. If not, it is determined that the selected application is an application that is reclaimed memory, and performs memory recovery by calling a memory recovery interface provided by the kernel state; the above steps are repeated until the termination condition of the memory recovery is satisfied.
  • the memory of the application with a lower reclaim priority (this part of the application is usually used by the user) and whose current time is not in the high probability running period is preferred, which can further improve system performance and improve users.
  • this part of the application is usually used by the user
  • whose current time is not in the high probability running period is preferred, which can further improve system performance and improve users.
  • the termination condition of the memory recovery may include one or more of the following conditions:
  • the amount of free memory in the system is greater than a second set threshold
  • the memory required for the currently launched application is less than the system free memory
  • the memory required to switch to the front-end interface is less than the system free memory
  • the number of applications running in the background is less than or equal to the number of applications allowed to run in the background.
  • the priority order of the applications of the reclaimed memory can be set according to the following steps:
  • each application is grouped, wherein applications in the same group have the same frequency range of use; according to the frequency range of use corresponding to each group, the application in each group is determined to be reclaimed memory. Priority order; where applications within the same group have the same priority order.
  • determining that the memory recovery condition is currently satisfied performing memory recovery by calling a memory recovery interface provided by the kernel state, including: if the terminal is detected to be present If the application stays in the background for longer than the set duration, it determines that the memory recovery condition is currently satisfied.
  • the memory recovery interface provided by the kernel state By calling the memory recovery interface provided by the kernel state, the memory of the application that stays in the background for longer than the set duration is recovered.
  • the application that stays in the background for a long time is generally an application that the user does not operate for a certain period of time, and the memory of the part of the application can be released, so as to be provided to a more necessary application, thereby improving the effective utilization of the memory.
  • the application also provides a memory recycling device, including:
  • a determining module configured to use information and memory occupation information used by the user in the user state monitoring terminal
  • a memory recycling module configured to determine that the memory recovery condition is currently satisfied according to at least one of information and memory usage information used by the user installed in the terminal, according to the The information about the currently running application in the terminal is used by the user and the memory occupation information.
  • the application that is to be reclaimed memory is determined from the application currently running by the terminal, and the memory recovery is performed by calling the memory recovery interface provided by the kernel state.
  • the application actively performs memory recovery by using an application installed in the user state monitoring terminal by the user to operate and use the memory, thereby speeding up the memory recovery frequency when the application is frequently used by the user and the memory usage is large. To ensure the normal use of memory.
  • the memory recovery module is specifically configured to:
  • the memory recovery time interval is determined according to the information used by the user operation and the memory occupation information of the application installed in the terminal; when the current time reaches the memory recovery time indicated by the memory recovery time interval, it is determined that the memory recovery condition is currently satisfied.
  • the memory recovery time interval is first determined according to the rule of the user using the application, and then the memory recovery is actively performed according to the memory recovery time indicated by the memory collection time interval. In this way, the memory is scheduledly recycled, and the terminal can be made. The available free memory is kept at a good level.
  • an optional manner for the memory collection module to determine the memory collection time interval is: respectively determining that the application installed in the terminal is used by the user in each of the preset at least one time period. Information and memory occupation information; for each time period of the at least one time period, according to information and memory occupation information used by the user operation in the terminal during the time period, respectively, determining at the time The memory reclamation interval within the segment.
  • the memory recovery module is specifically configured to: if it is determined that the idle memory in the system is less than the first set threshold, determine that the memory recovery condition is currently satisfied.
  • the memory recovery module is specifically configured to: if an application is detected to be started or switched to the foreground interface, according to the memory usage information of the application, and the free memory in the system is large. Small, to determine whether memory reclamation is required; if memory reclamation is required, it is determined that the memory reclamation condition is currently satisfied.
  • this method can ensure the normal operation of the newly launched application or the application switched to the front-end interface, thereby improving system performance and improving the user experience.
  • the memory recovery module is specifically configured to: if the number of applications currently running in the background is greater than the number of allowed running applications in the background, determine that the memory recovery condition is currently satisfied.
  • the number of applications allowed to run in the background can be set at intervals according to the current free memory size. Since the application running in the background is usually not the application that the user is using, limiting the number of applications in this part can avoid excessive invalid use of memory.
  • the memory reclamation module determines the application to be reclaimed memory, and an optional way to perform memory reclaiming by calling the memory reclaiming interface provided by the kernel state is: prioritizing the application according to the pre-saved reclaimed memory. Sequence, selecting an application currently running in the terminal that is not used by the user, determining whether the current time is in a high probability usage period of the selected application, and the high probability usage period of the application is based on the application being used by the user. The information is determined; if not, it is determined that the selected application is an application that is reclaimed memory, and the memory is recovered by calling a memory recovery interface provided by the kernel state; the above steps are repeated until the termination condition of the memory recovery is satisfied.
  • the memory of the application with a lower reclaim priority (this part of the application is usually used by the user) and whose current time is not in the high probability running period is preferred, which can further improve system performance and improve users.
  • this part of the application is usually used by the user
  • whose current time is not in the high probability running period is preferred, which can further improve system performance and improve users.
  • the termination condition of the memory recovery may include one or more of the following conditions:
  • the amount of free memory in the system is greater than a second set threshold
  • the memory required for the currently launched application is less than the system free memory
  • the memory required to switch to the front-end interface is less than the system free memory
  • the number of applications running in the background is less than or equal to the number of applications allowed to run in the background.
  • the memory recycling module may be specifically configured to set a priority order of the applications of the reclaimed memory according to the following steps: grouping the applications according to the frequency of use of each application installed in the terminal, wherein the applications in the same group have the same The frequency range is used; according to the frequency range of use corresponding to each group, the priority order of the reclaimed memory of the application in each group is determined; wherein the applications in the same group have the same priority order.
  • the memory recovery module is specifically configured to: if it is detected that the time in the terminal memory staying in the background exceeds the set duration, determine that the memory recovery condition is currently satisfied, and call the memory recovery interface provided by the kernel state. The memory of the application that stays in the background for longer than the set duration is recycled.
  • the application provides a user equipment, which includes a processor, a memory, and a bus; the memory is used to store execution instructions, including a memory and an external memory; the memory here is also referred to as an internal memory for temporarily storing operations in the processor. Data, and data exchanged with an external memory such as a hard disk, the processor exchanges data with the external memory through the memory.
  • the processor communicates with the memory through the bus, so that the processor executes the following instructions in the user mode:
  • the information of the application installed in the terminal is used by the user and the memory occupation information; and at least one of the information and the memory occupation information used by the user according to the application installed in the terminal determines that the memory recovery condition is currently satisfied, according to the terminal.
  • the information that the currently running application is used by the user and the memory occupation information, determine the application to be reclaimed from the application currently running by the terminal, and perform memory recovery by calling the memory recovery interface provided by the kernel state.
  • the application actively performs memory recovery by using an application installed in the user state monitoring terminal by the user to operate and use the memory, thereby speeding up the memory recovery frequency when the application is frequently used by the user and the memory usage is large. To ensure the normal use of memory.
  • the instruction executed by the processor determining, according to the information used by the user operation and the memory occupation information, that the application installed in the terminal is currently satisfying the memory recovery condition, including: being operated by the user according to the application installed in the terminal
  • the information used and the memory usage information determine the memory reclamation interval; when the current time reaches the memory reclamation time indicated by the memory reclamation interval, Determine that the memory reclamation condition is currently met.
  • the memory recovery time interval is first determined according to the rule of the user using the application, and then the memory recovery is actively performed according to the memory recovery time indicated by the memory collection time interval. In this way, the memory is scheduledly recycled, and the terminal can be made. The available free memory is kept at a good level.
  • an optional way to determine the memory collection time interval is:
  • determining, according to the memory occupation information of the application installed in the terminal, that the memory recovery condition is currently met including: determining that the idle memory in the system is less than the first set threshold, determining the current Meet the memory recycling conditions.
  • the instructions executed by the processor determine, according to the information used by the user operation and the memory occupation information, that the current memory recovery condition is met, including: if the application is detected to be started or switched to The front-end interface determines whether memory reclaiming is required according to the memory usage information of the application and the amount of free memory in the system; if memory reclamation is required, it determines that the memory reclaiming condition is currently satisfied.
  • this method can ensure the normal operation of the newly launched application or the application switched to the front-end interface, thereby improving system performance and improving the user experience.
  • the instructions executed by the processor are based on the application installed in the terminal.
  • the information used by the user operation determines that the memory recovery condition is currently satisfied, including: if the number of applications currently running in the background is greater than the number of applications allowed to run in the background, it is determined that the memory recovery condition is currently satisfied.
  • the number of applications allowed to run in the background can be set at intervals according to the current free memory size. Since the application running in the background is usually not the application that the user is using, limiting the number of applications in this part can avoid excessive invalid use of memory.
  • an application that determines the memory to be reclaimed and performs memory recovery by calling the memory recovery interface provided by the kernel state is: according to the pre-stored reclaimed memory.
  • the priority order of the application, selecting an application currently running in the terminal and not used by the user, determining whether the current time is in a high probability use period of the selected application, and the high probability use period of the application is based on the application.
  • the information used by the user operation is determined; if not, the selected application is determined to be the application of the reclaimed memory, and the memory is recovered by calling the memory recovery interface provided by the kernel state; the above steps are repeated until the termination condition of the memory recovery is satisfied. .
  • the memory of the application with a lower reclaim priority (this part of the application is usually used by the user) and whose current time is not in the high probability running period is preferred, which can further improve system performance and improve users.
  • this part of the application is usually used by the user
  • whose current time is not in the high probability running period is preferred, which can further improve system performance and improve users.
  • the termination condition of the memory recovery may include one or more of the following conditions:
  • the amount of free memory in the system is greater than a second set threshold
  • the memory required for the currently launched application is less than the system free memory
  • the memory required to switch to the front-end interface is less than the system free memory
  • the number of applications running in the background is less than or equal to the number of applications allowed to run in the background.
  • an optional manner of setting the priority order of the application of the reclaimed memory is:
  • Each application is grouped according to the frequency of use of each application installed in the terminal, wherein applications in the same group have the same frequency range of use; according to the frequency range of use corresponding to each group, The priority order of the reclaimed memory of the applications within each group is determined; wherein the applications in the same group have the same priority order.
  • the instructions executed by the processor determine, according to the information used by the user that the application installed in the terminal is used by the user, that the memory recovery condition is currently met, and perform memory recovery by calling a memory recovery interface provided by the kernel state, including : If it is detected that the duration of the application staying in the background exceeds the set duration, it is determined that the memory recovery condition is currently satisfied, and the memory recovery interface provided by the kernel state is used to apply the application that stays in the background for longer than the set duration. Memory is recycled.
  • the application that stays in the background for a long time is generally an application that the user does not operate for a certain period of time, and the memory of the part of the application can be released, so as to be provided to a more necessary application, thereby improving the effective utilization of the memory.
  • FIG. 1 is a schematic diagram of memory recovery provided by the present application.
  • FIG. 3 is a flowchart of a memory recycling method according to Embodiment 2 of the present application.
  • FIG. 5 is a schematic structural diagram of a memory recovery device 50 according to an embodiment of the present application.
  • FIG. 6 is a schematic structural diagram of user equipment 60 according to an embodiment of the present disclosure.
  • FIG. 7 is a schematic structural diagram of a terminal device 700 according to the present application.
  • FIG. 8 is a schematic structural diagram of a terminal 800 according to an embodiment of the present application.
  • the memory recovery diagram provided by the present application is shown.
  • This application performs memory recovery by running a memory reclamation policy in user mode and through a memory recovery interface provided by kernel mode.
  • the application Application, App
  • the running application is used by the user to use the information and memory occupation information, select the application that is reclaimed memory from the currently running application, and perform memory recovery by calling the kernel state to provide the user state memory recycling interface.
  • the present application actively performs memory recovery by monitoring information and memory usage information used by the user in the user state monitoring application, thereby speeding up the memory recovery frequency and ensuring memory recovery when the application is frequently used by the user and the memory usage is large. Timeliness.
  • a flowchart of a memory recycling method provided in Embodiment 1 of the present application performs the following steps in a user mode:
  • S201 Monitor information and memory occupation information used by the user installed in the terminal by the user.
  • the memory occupation information may include a memory size occupied by the application runtime, and the information used by the application to be used by the user may include a frequency of use of the application by the user, a usage period, a duration of use, and the like.
  • the monitoring process can be used to monitor the running status of each application in the terminal system and the memory size occupied by the application in the user mode.
  • the running status of the application can be used to determine the frequency and time of the application. Segment, length of use, etc.
  • the user's use period of the application may refer to a period of time during which the user uses the application within a preset plurality of time periods. It can also refer to the actual time period from when the user starts operating the application to ending the operation of the application.
  • monitoring the running status of each application in the terminal system may include monitoring the status of the application startup, the status of the application being closed, the status of the application switching from the background to the foreground interface, and the status of switching from the foreground interface to the background.
  • the monitoring process can be queried through the query interface provided by the proc file system to obtain the above running state of the application.
  • the manner in which the information used by the user operation is used may be different for different applications.
  • the time when the application is started or switched to the front-end interface may be used as the time when the user starts to operate the application, and the time when the application is closed or switched to the background operation is used as the user.
  • the application can be launched for applications such as downloading software that do not require the user to always operate in the foreground interface.
  • the time is the time when the user starts operating the application, and the time when the application is closed is taken as the time when the user ends the operation of the application. According to the statistics of the time when the user starts operating the application and the time when the application is finished, the frequency of use of the application, the period of use, and the duration of use can be determined.
  • S202 Determine whether the memory recovery condition is currently satisfied based on at least one of information and memory occupation information used by the user according to the application installed in the terminal. If yes, go to S203, otherwise return to S201.
  • the condition for triggering memory recovery in the user state may be set according to actual needs.
  • the memory recovery time interval may be determined according to the information used by the user operation and the memory occupation information installed in the terminal, according to the preset memory recovery time. Interval triggers memory reclamation to achieve a planned recovery of memory, keeping the free memory available in the terminal at a better level.
  • the preset memory recovery interval may be one or more. For example, if the frequency and memory usage of the application for the whole day are relatively stable, only one memory collection interval may be set. Alternatively, if the user only concentrates on using the application within one time period and the frequency of using the application is relatively stable, it is possible to set only the memory collection time interval in this time period, and no memory recovery in other time periods.
  • the memory recovery may be triggered (that is, the memory recovery is triggered according to the memory usage information of the application installed in the terminal), and when an application is started or switched to the foreground interface, According to the memory usage information of the application and the size of the free memory in the system, the memory is recovered (that is, the memory is recovered according to the information used by the user and the memory usage information is triggered by the user), and the length of time that the application stays in the background in the terminal is exceeded.
  • the memory is triggered for a long time (that is, the memory is triggered according to the information used by the user to operate the memory).
  • S203 Determine, according to information and memory occupation information used by the user that the currently running application in the terminal is operated by the user, determine an application to be reclaimed from the currently running application of the terminal, and recover the memory provided by calling the kernel state.
  • the interface performs memory reclamation.
  • the application installed in the terminal in S201 and S202 includes an application currently running in the terminal in S203, and the terminal is installed in addition to the currently running application in the terminal in S203.
  • the app also includes apps that are currently off.
  • the kernel state memory recycling program in the user state through the memory recovery interface provided by the kernel state, the kernel state memory recycling program is called for memory recovery, and the memory recovery interface can be implemented based on a system call, a linux procfs file system, or a linux sysfs file system. .
  • the existing memory recovery management of the kernel state is implemented based on the LRU algorithm, which divides the memory occupied by the application into anonymous pages (such as memory allocated by dynamic memory allocation (malloc) function) and file pages (such as reading and writing).
  • the memory allocated during the file is divided into two categories, and the recently used ones are stored in a linked list according to the LRU algorithm, and the linked list is shrunk each time it is recycled, and a part of the memory page (mainly the page cache) is recovered.
  • the underlying function of kernel state for memory reclamation is try_to_free_pages(). This application exposes this function interface to user mode calls. In the user state, based on the memory reclaiming strategy provided by this application, memory recovery is achieved by calling this function interface.
  • the information collected by the user in the terminal is used to calculate the information used by the user and the memory occupation information, and the memory collection time interval is determined, and the memory is collected based on the determined memory recovery time interval.
  • a flowchart of a memory recycling method provided in Embodiment 2 of the present application performs the following steps in a user mode:
  • S301 Monitor information and memory occupation information used by the user installed in the terminal by the user.
  • the user monitors the running status of each application in the terminal system in real time, and collects information such as the frequency of use of the application, the usage time period, and the like, the information used by the user, and the memory size occupied by the application runtime. Occupy information.
  • S302 Determine a memory collection time interval according to the information used by the user and the memory occupation information of the application installed in the terminal.
  • the memory collection time interval may be determined according to the information used by the user operation and the memory occupation information of each application obtained in S301.
  • the memory collection interval can be one or more. For example, if the frequency and memory usage of the application are consistent throughout the day, only one memory collection interval can be set. If the user uses it at different times of the day, Different frequencies can be used, and different memory recovery intervals can be used in different time periods in a day. For example, the memory recovery frequency can be accelerated in a period of time when the application is frequently used and the amount of memory occupied is large, and can be used in an application. Reduce the frequency of memory recovery in a small number of times and a small amount of memory.
  • a preset time period may be determined, and information and memory occupation information used by the user to be installed in the terminal during each preset time period are determined; according to each preset During the time period, the application installed in the terminal is used by the user to operate the information and the memory occupation information to determine the memory recovery time interval in each preset time period.
  • the information used by the operation and the memory usage information For example, during the time period from 17:00 to 23:00, the user uses the application most frequently, and the application occupies the largest memory.
  • the memory recovery interval of the time period can be used. Set to 0.5h; during the time period of 9:00-17:00, the user uses the frequency of the application to be centered, and the occupied memory size is also centered.
  • the memory recovery interval of the time period can be set to 1h; at 23: 00-9:00 During this time period, the user has the lowest frequency of application and the smallest memory size.
  • the memory recovery interval of this time period can be set to 3h.
  • the frequency is obviously higher than the frequency of application on weekdays.
  • the memory recovery interval between -17:00, 17:00-23:00, 23:00-9:00 is halved, that is, it will be in the time period from 17:00 to 23:00.
  • the memory reclamation interval is set to 0.25h, and the memory reclamation interval will be set to 0.5h during the time period from 9:00 to 17:00, and the memory recovery time will be in the period from 23:00 to 9:00.
  • the interval is set to 1.5h.
  • S303 If it is determined that the memory recovery is currently required according to the memory collection time interval, determining, according to information and memory occupation information used by the user that the currently running application in the terminal is used, determining from an application currently running by the terminal.
  • the application that will be reclaimed memory in order to protect The user's normal use of the application, the application currently being used by the user is not considered for memory recovery, and the application that the user is using may include a foreground application, and may also include an application running in the background, such as file downloading.
  • S304 Perform memory recovery by calling a memory recycling interface provided by the kernel state.
  • the probability that the application is not used by the user at the current time is not used for the application currently running in the terminal and not used by the user.
  • the application's memory can be reclaimed, so that the application is selected in turn for memory reclamation until the termination condition of the memory reclamation is satisfied.
  • the application that is currently running in the terminal and not used by the user may be selected according to the priority order of the pre-stored application of the reclaimed memory, to determine whether the current time is The high probability usage time period of the selected application (ie, the time period during which the application is used by the user operation is high), and the high probability usage time period of the application is determined based on the information used by the user to be operated by the user (such as the user) If the application is used between 12:00 and 13:00 every day for 5 consecutive days, the high probability running time period of the application is 12:00 to 13:00; if not, the selected application is determined to be The application that reclaims memory is repeated until the termination condition for memory reclamation is met.
  • the termination condition of the memory recovery may include that the size of the free memory in the system is greater than a second set threshold.
  • the above priority order may be a priority order between different application groups.
  • each application may be grouped according to the frequency of use of each application installed in the terminal, wherein applications in the same group have the same frequency range of use; and applications in each group are determined according to the frequency range of use corresponding to each group.
  • some applications may involve key elements of the operating system within the terminal, such as the User Interface (UI), which can be attributed to group 1, indicating very important applications; for some applications that users often use.
  • UI User Interface
  • Such as WeChat, camera, etc. can be attributed to group2, which is expressed as a generally important application; for other applications that are not commonly used, such as calculators, stocks, etc., such applications can be attributed to group3, indicating that it is not important.
  • the second is to reclaim the memory of the application in group2 and not the memory of the application in group1.
  • the embodiment of the present application further provides an implementation manner of performing memory recovery using multiple memory recovery conditions.
  • FIG. 4 a flowchart of a memory recycling method provided in Embodiment 3 of the present application is performed in a user mode:
  • S401 Monitor information and memory occupation information used by the user installed in the terminal by the user.
  • S402 Determine a memory collection time interval according to the information used by the user operation and the memory occupation information of the application installed in the terminal.
  • the threshold may be a first set threshold, or a second set threshold, or other threshold, such as a certain one between the first set threshold and the second set threshold (the first set threshold is less than the second set threshold) Threshold), you can perform memory reclamation.
  • the number M of applications running in the background is greater than the number N of currently allowed applications running in the background;
  • the number of applications allowed to run in the background may be set according to the size of the free memory in the current system.
  • the length of time that the application stays in the background in the terminal memory is longer than the set duration.
  • S404 Determine, according to information and memory occupation information used by the user that the currently running application in the terminal is operated, an application that is to be reclaimed from the application that is currently running by the terminal and is not used by the user, and invokes the kernel by calling the kernel.
  • the memory recycling interface provided by the state performs memory reclamation.
  • the user-mode daemon of the present application for memory recovery is first started, and then each application is started, and an application running data table is maintained, and the memory usage of the application in the terminal is recorded, and statistics are collected.
  • the high probability runtime period is shown in Table 1 below.
  • the application currently running in the terminal may be selected according to the priority order of the pre-stored application of the reclaimed memory, and Table 1 is checked to determine whether the current time is in the high probability usage time of the selected application. Segment; if not, the selected application is selected as the application of the reclaimed memory, and the memory is reclaimed by calling the memory recycling interface provided by the kernel state for memory recycling until the termination condition of the memory recycling is satisfied.
  • the termination condition of the memory recovery may include: an application in which the amount of free memory in the system is greater than a second set threshold, and the memory required for the currently started application is less than the system free memory, and switching to the foreground interface
  • the required memory is less than the system free memory, the number of applications running in the background is less than or equal to one or more of the number of allowed background running applications.
  • the termination condition of the memory recovery may be that the free memory size in the system is greater than a second set threshold (the second set threshold is greater than the first set threshold), and for condition three, the termination condition of the memory recovery may be Is currently activated The required memory is less than the system free memory; for condition four, the termination condition of the memory recovery may be that the number of running applications in the background is equal to the set number, that is, in S303, the MNs are selected from the applications running in the background. Memory application.
  • S405 Recalling the memory of the application that stays in the background for longer than the set duration by calling the memory recovery interface provided by the kernel state.
  • the present application further provides a memory recovery device and a user equipment corresponding to the memory recovery method. Since the principle of solving the problem between the device and the user equipment is similar to the memory recovery method of the present application, the implementation of the device and the user equipment See the implementation of the method, and the repetition will not be repeated.
  • a schematic structural diagram of a memory recovery device 50 includes:
  • a determining module 51 configured to use information and memory occupation information used by the user in the user state monitoring terminal to be used by the user;
  • the memory recovery module 52 is configured to determine, according to at least one of information and memory usage information used by the user that the application installed in the terminal is currently used, to determine that the memory recovery condition is currently satisfied, according to the currently running application in the terminal.
  • the information used by the user operation and the memory occupation information determine the application to be reclaimed from the application currently running by the terminal, and perform memory recovery by calling the memory recovery interface provided by the kernel state.
  • the application actively performs memory recovery by using an application installed in the user state monitoring terminal by the user to operate and use the memory, thereby speeding up the memory recovery frequency when the application is frequently used by the user and the memory usage is large. To ensure the normal use of memory.
  • the memory recovery module 52 is specifically configured to:
  • the memory recovery time interval is determined according to information used by the user and the memory occupation information used by the application installed in the terminal; when the current time reaches the memory recovery time indicated by the memory recovery time interval, it is determined that the memory recovery condition is currently satisfied.
  • the memory reclamation module 52 first determines the memory reclamation interval according to the rule of the user using the application, and then actively proceeds according to the memory reclamation time indicated by the memory reclamation interval.
  • Line memory recycling which is a planned recovery of memory, can keep the available free memory in the terminal at a better level.
  • the memory collection module 52 is specifically configured to determine a memory collection interval according to the following steps:
  • the memory recovery module 52 is specifically configured to:
  • the memory recovery module 52 is specifically configured to:
  • this method can ensure the normal operation of the newly launched application or the application switched to the front-end interface, thereby improving system performance and improving the user experience.
  • the memory recovery module 52 is specifically configured to:
  • the number of applications allowed to run in the background can be set at intervals according to the current free memory size. Since the application running in the background is usually not the application that the user is using, Limiting the number of applications in this section can avoid excessive invalid use of memory.
  • the memory recovery module 52 is specifically configured to:
  • the priority order of the pre-saved application of the reclaimed memory selecting an application currently running in the terminal that is not used by the user, determining whether the current time is in the high probability usage period of the selected application, and the high probability of the application The usage time period is determined based on the information that the application is used by the user operation; if not, the selected application is determined to be the application of the reclaimed memory, and the memory is reclaimed by calling the memory recovery interface provided by the kernel state; repeating the above steps Until the termination condition for memory reclamation is met.
  • the memory of the application with a lower reclaim priority (this part of the application is usually used by the user) and whose current time is not in the high probability running period is preferred, which can further improve system performance and improve users.
  • this part of the application is usually used by the user
  • whose current time is not in the high probability running period is preferred, which can further improve system performance and improve users.
  • the termination condition of the memory recovery includes one or more of the following conditions:
  • the amount of free memory in the system is greater than a second set threshold
  • the memory required for the currently launched application is less than the system free memory
  • the memory required to switch to the front-end interface is less than the system free memory
  • the number of applications running in the background is less than or equal to the number of applications allowed to run in the background.
  • the memory collection module 52 is specifically configured to set an priority order of the applications of the reclaimed memory according to the following steps:
  • Each application is grouped according to the frequency of use of each application installed in the terminal, wherein applications in the same group have the same frequency range of use;
  • the priority order of the reclaimed memory of the application in each group is determined; wherein the applications in the same group have the same priority order.
  • the memory recovery module 52 is specifically configured to:
  • the memory of the application that stays in the background for longer than the set duration is recovered.
  • the application that stays in the background for a long time is generally an application that the user does not operate for a certain period of time, and can release the memory of the part of the application, so as to provide an application that is more needed, thereby Increased effective utilization of memory.
  • a schematic structural diagram of a user equipment 60 includes a processor 61, a memory 62, and a bus 63.
  • the memory 62 is configured to store execution instructions, including a memory 621 and an external memory 622;
  • the 621 is also referred to as an internal memory for temporarily storing the operation data in the processor 61 and the data exchanged with the external memory 622 such as a hard disk.
  • the processor 61 exchanges data with the external memory 622 through the memory 621 when the user device 60 operates.
  • the processor 61 communicates with the memory 62 via a bus 63 such that the processor 61 executes the following instructions in the user mode:
  • the information of the application installed in the terminal is used by the user and the memory occupation information; and at least one of the information and the memory occupation information used by the user according to the application installed in the terminal determines that the memory recovery condition is currently satisfied, according to the terminal.
  • the information that the currently running application is used by the user and the memory occupation information, determine the application to be reclaimed from the application currently running by the terminal, and perform memory recovery by calling the memory recovery interface provided by the kernel state.
  • the instruction executed by the processor 61 determines that the memory recovery condition is currently met according to the information used by the user and the memory occupation information of the application installed in the terminal, including: being operated by the user according to the application installed in the terminal.
  • the information and memory usage information determine the memory recovery interval; when the current time reaches the memory recovery time indicated by the memory collection interval, it is determined that the memory recovery condition is currently satisfied.
  • determining the memory collection time interval includes:
  • the memory recovery time interval during the time period is determined according to the information used by the user operation and the memory occupation information during the time period in which the application installed in the terminal is used. .
  • the instruction executed by the processor 61 determines, according to the memory occupation information of the application installed in the terminal, that the memory recovery condition is currently met, including: determining that the current memory is satisfied if the idle memory in the system is determined to be less than the first set threshold. Recycling conditions.
  • the instruction executed by the processor 61 determines that the memory recovery condition is currently met according to the information used by the user operation and the memory occupation information, including: if the application is detected to be started or switched to the foreground interface, According to the memory usage information of the application and the size of the free memory in the system, it is determined whether memory recovery is required; if memory recovery is required, it is determined that the memory recovery condition is currently satisfied.
  • the instruction executed by the processor 61 determines that the memory recovery condition is currently met according to the information used by the user installed in the terminal, including: if the number of applications currently running in the background is greater than the set allowed background running The number of applications determines that the memory reclamation condition is currently satisfied.
  • the number of applications allowed to run in the background can be set at intervals according to the current free memory size. Since the application running in the background is usually not the application that the user is using, limiting the number of applications in this part can avoid excessive invalid use of memory.
  • determining an application that is to be reclaimed memory, and performing memory recovery by calling a memory recovery interface provided by the kernel state including: according to a priority order of the application of the pre-saved reclaimed memory, Selecting an application currently running in the terminal that is not used by the user, determining whether the current time is in a high probability usage period of the selected application, and the high probability usage period of the application is determined based on information used by the user to be operated by the user. If not, it is determined that the selected application is an application that is reclaimed memory, and performs memory recovery by calling a memory recovery interface provided by the kernel state; the above steps are repeated until the termination condition of the memory recovery is satisfied.
  • the termination condition of the memory recovery includes one or more of the following conditions:
  • the amount of free memory in the system is greater than a second set threshold
  • the memory required for the currently launched application is less than the system free memory
  • the memory required to switch to the front-end interface is less than the system free memory
  • the number of applications running in the background is less than or equal to the number of applications allowed to run in the background.
  • setting a priority order of the application that is used to reclaim memory includes:
  • Each application is grouped according to the frequency of use of each application installed in the terminal, wherein applications in the same group have the same frequency range of use; according to the frequency range of use corresponding to each group, The priority order of the reclaimed memory of the applications within each group is determined; wherein the applications in the same group have the same priority order.
  • the instruction executed by the processor 61 determines that the memory recovery condition is currently satisfied according to the information used by the user in the application installed by the terminal, and performs memory recovery by calling a memory recovery interface provided by the kernel state, including: It is detected that the duration of the application staying in the background exceeds the set duration, and it is determined that the memory recovery condition is currently satisfied, and the memory recovery interface provided by the kernel state is used to perform the memory of the application that stays in the background for longer than the set duration. Recycling.
  • FIG. 7 illustrates a structure of a terminal device 700 provided by the present application, including: at least one processor 701, at least one network interface 704 or other user interface 703, a memory 705, at least one communication bus 702, and a communication bus 702 for implementing The connection between these components communicates.
  • the memory 705 includes a memory and an external memory, and the memory here is also referred to as an internal memory for temporarily storing the operation data in the processor 701 and data exchanged with an external memory such as a hard disk, and the processor 701 performs data through the memory and the external memory. exchange.
  • the memory 705 stores the following elements, executable modules or data results, or a subset of them, or their extension set:
  • the operating system 7051 which includes various system programs, may have two operating levels of kernel state 7051a and user state 7051b.
  • kernel state When a process executes a system call and is executed in kernel code, it is said to be in the kernel running state, referred to as the kernel state.
  • the executed kernel code uses the kernel stack of the current process, and each process has its own kernel stack.
  • the user mode When the process is executing the user's own code, it is said to be in the user running state, referred to as the user mode.
  • the processor 701 runs in the user code with the lowest privilege level.
  • the application module 7052 includes various applications (referred to as applications).
  • the processor 701 is configured to execute in the user mode by calling a program or an instruction stored in the memory 705:
  • Monitoring information and memory usage information used by the user to be installed in the terminal Monitoring information and memory usage information used by the user to be installed in the terminal; at least one of information and memory usage information used by the user to be installed according to the application installed in the terminal
  • the application that is to be reclaimed memory is determined from the application currently running by the terminal, and is provided by calling the kernel state.
  • the memory reclamation interface performs memory reclamation.
  • the processor 701 is further configured to: determine, according to the information used by the user operation and the memory occupation information, the memory recovery time interval; and reach the memory recovery time interval indicated by the current time. When the memory reclamation time is determined, it is determined that the memory reclamation condition is currently satisfied.
  • the processor 701 is further configured to: respectively determine information and memory occupation information used by the user to be installed in the terminal in each of the preset at least one time period; for the at least one Each time period in the time period is determined according to information and memory occupation information used by the user in the terminal during the time period, and the memory recovery time interval in the time period is determined.
  • the processor 701 is further configured to: if it is determined that the idle memory in the system is less than the first set threshold, determine that the memory recovery condition is currently met.
  • the processor 701 is further configured to: if it is detected that an application is started or switched to the foreground interface, determine whether the need is performed according to the memory occupation information of the application and the size of the free memory in the system. Memory reclamation; if memory reclamation is required, it is determined that the memory reclamation condition is currently satisfied.
  • the processor 701 is further configured to: if the number of applications currently running in the background is greater than the number of allowed running applications in the background, determine that the memory recovery condition is currently satisfied.
  • the number of applications allowed to run in the background can be set at intervals according to the current free memory size. Since the application running in the background is usually not the application that the user is using, limiting the number of applications in this part can avoid excessive invalid use of memory.
  • the processor 701 is further configured to: determine an application to be reclaimed memory, and perform memory recovery by calling a memory recovery interface provided by the kernel state, including: selecting a terminal according to a priority order of the pre-stored application of the reclaimed memory. The user is currently running and the user is not using it.
  • the application determines whether the current time is in a high probability usage period of the selected application, and the high probability usage period of the application is determined based on information that the application is used by the user operation; if not, determining that the selected application is The memory is reclaimed and the memory is reclaimed by calling the memory reclaim interface provided by the kernel state; repeat the above steps until the termination condition of the memory reclamation is satisfied.
  • the termination condition of the memory recovery includes one or more of the following conditions:
  • the amount of free memory in the system is greater than a second set threshold
  • the memory required for the currently launched application is less than the system free memory
  • the memory required to switch to the front-end interface is less than the system free memory
  • the number of applications running in the background is less than or equal to the number of applications allowed to run in the background.
  • the processor 701 is further configured to: group the applications according to the frequency of use of each application installed in the terminal, where the applications in the same group have the same frequency range of use; according to the frequency range of use corresponding to each group, The priority order of the reclaimed memory of the applications within each group is determined; wherein the applications in the same group have the same priority order.
  • the processor 701 is further configured to: if it is detected that the duration of the application staying in the background in the terminal exceeds the set duration, the application that stays in the background for longer than the set duration Memory is recycled.
  • terminal device 700 can also perform the method and the embodiment of FIG. 2 to FIG. 4, and details are not described herein again.
  • the embodiment of the present application relates to a terminal 800 and a memory recycling method.
  • the terminal 800 can be a mobile phone, a tablet computer, a personal digital assistant (PDA), a point of sales (POS), or a vehicle-mounted computer.
  • PDA personal digital assistant
  • POS point of sales
  • vehicle-mounted computer a vehicle-mounted computer.
  • FIG. 8 is a schematic structural diagram of a terminal 800 according to an embodiment of the present application.
  • a terminal 800 of the embodiment of the present application includes: a processor 810, a memory 820, an input unit 830, a power source 850, a radio frequency (RF) circuit 860, and an audio circuit. 870, Wireless Fidelity (WiFi) module 880.
  • the memory 820 includes a memory 821 for temporarily storing the operation data in the processor 810, and data exchanged with the external memory 822 such as a hard disk.
  • the processor 810 exchanges data with the external memory 822 through the memory 821.
  • the memory 821 can be one of a non-volatile memory (NVRAM), a dynamic random access memory (DRAM), a static random access memory (SRAM), a flash memory, and the like; the external memory
  • the 822 can be a hard disk, a CD, a USB disk, a floppy disk, or a tape drive.
  • the processor 810 executes an instruction in the memory 820 in the user mode: monitoring information used by the user operation and memory occupation information in the application installed in the terminal; and at least information and memory occupation information used by the user according to the application installed in the terminal For example, when determining that the memory recovery condition is currently satisfied, according to the information and memory occupation information used by the user currently running in the terminal, the application that is to be reclaimed memory is determined from the application currently running by the terminal, and the kernel is called.
  • the memory recycling interface provided by the state performs memory reclamation.
  • the memory recovery may be triggered by the set memory recovery time interval.
  • the processor 810 may respectively determine that the application installed in the terminal is used by the user during each of the preset at least one time period.
  • the memory reclamation may also be triggered when it is determined that the free memory in the system is less than the first set threshold.
  • the process of the processor 810 performing memory recovery may be: According to the priority order of the pre-saved application of the reclaimed memory, selecting an application currently running in the terminal that is not used by the user, determining whether the current time is in the high probability usage period of the selected application, and the high probability of the application The usage time period is determined based on the information that the application is used by the user operation; if not, the selected application is determined to be the application of the reclaimed memory, and the memory is reclaimed by calling the memory recovery interface provided by the kernel state; repeating the above steps Until the termination condition for memory reclamation is met.
  • the termination condition of the memory recovery may include one or more of the following conditions: the size of the free memory in the system is greater than the second set threshold; the memory required for the currently started application is less than the system free memory; and switching to the foreground interface
  • the memory required by the application is less than the system free memory; the number of applications running in the background is less than or equal to the number of applications allowed to run in the background.
  • each application may be grouped according to the frequency of use of each application installed in the terminal, wherein applications in the same group have the same frequency range of use; and applications in each group are determined according to the frequency range of use corresponding to each group. The order of priority of the reclaimed memory; where the applications in the same group have the same priority order.
  • processor 810 can also perform memory reclamation by calling the memory reclaim interface provided by the kernel state when determining that the memory reclamation condition is currently satisfied.
  • the input unit 830 can be configured to receive input digital or character information and to generate signal inputs related to user settings and function control of the terminal 800.
  • the input unit 830 may include a touch panel 831.
  • the touch panel 831 also referred to as a touch screen, can collect touch operations on or near the user (such as the user's operation on the touch panel 831 or the touch panel 831 by using any suitable object or accessory such as a finger, a stylus, or the like. ), and drive the corresponding connection device according to a preset program.
  • the touch panel 831 can include two parts: a touch detection device and a touch controller.
  • the touch detection device detects the touch orientation of the user, and detects a signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, converts the touch information into contact coordinates, and sends the touch information.
  • the processor 810 is provided and can receive commands from the processor 810 and execute them.
  • the touch panel 831 can be implemented in various types such as resistive, capacitive, infrared, and surface acoustic waves.
  • the input unit 830 may also include other input devices 832, which may include, but are not limited to, physical keyboards, function keys One or more of (such as volume control buttons, switch buttons, etc.), trackball, mouse, joystick, and the like.
  • other input devices 832 may include, but are not limited to, physical keyboards, function keys One or more of (such as volume control buttons, switch buttons, etc.), trackball, mouse, joystick, and the like.
  • the terminal 800 can also include a display unit 840 that can be used to display information entered by the user or information provided to the user and various menu interfaces of the terminal 800.
  • the display unit 840 can include a display panel 841.
  • the display panel 841 can be configured in the form of an LCD (Liquid Crystal Display) or an OLED (Organic Light-Emitting Diode).
  • the touch panel 831 covers the display panel 841 to form a touch display screen.
  • the touch display screen detects a touch operation on or near the touch display screen, the touch display screen transmits to the processor 810 to determine the type of the touch event.
  • Processor 810 provides a corresponding visual output on the touch display based on the type of touch event.
  • the touch display screen includes an application interface display area and a common control display area.
  • the arrangement manner of the application interface display area and the display area of the common control is not limited, and the arrangement manner of the two display areas can be distinguished by up-and-down arrangement, left-right arrangement, and the like.
  • the application interface display area can be used to display the interface of the application. Each interface can contain interface elements such as at least one application's icon and/or widget desktop control.
  • the application interface display area can also be an empty interface that does not contain any content.
  • the common control display area is used to display controls with high usage, such as setting buttons, interface numbers, scroll bars, phone book icons, and the like.
  • the processor 810 is a control center of the terminal 800 that connects various portions of the entire handset using various interfaces and lines, by running or executing software programs and/or modules stored in the memory 821, and by calling in the external memory 822.
  • the internal data performs various functions and processing data of the terminal 800, thereby performing overall monitoring of the terminal 800.
  • embodiments of the present application can be provided as a method, system, or computer program product.
  • the present application can take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment in combination of software and hardware.
  • the application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) including computer usable program code.
  • the computer program instructions can also be stored in a computer readable memory that can direct a computer or other programmable data processing device to operate in a particular manner, such that the instructions stored in the computer readable memory produce an article of manufacture comprising the instruction device.
  • the apparatus implements the functions specified in one or more blocks of a flow or a flow and/or block diagram of the flowchart.
  • These computer program instructions can also be loaded onto a computer or other programmable data processing device such that a series of operational steps are performed on a computer or other programmable device to produce computer-implemented processing for execution on a computer or other programmable device.
  • the instructions provide steps for implementing the functions specified in one or more of the flow or in a block or blocks of a flow diagram.

Abstract

一种内存回收方法及装置,用以解决内存回收不及时、容易导致应用卡顿的问题。该方法包括:监控终端内安装的应用被用户操作使用的信息及内存占用信息(S201);判断是否满足内存回收条件(S202),若是,则根据所述终端内当前正在运行的应用被用户操作使用的信息及内存占用信息,从所述终端当前正在运行的应用中确定将被回收内存的应用,并通过调用内核态提供的内存回收接口执行内存回收(S203)。

Description

一种内存回收方法及装置
本申请要求在2015年12月31日提交中国专利局、申请号为201511032537.7、发明名称为“一种内存回收方法及装置”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及计算机技术领域,尤其涉及一种内存回收方法及装置。
背景技术
出于对生产成本的考虑,终端设备的内存容量往往比较小,大多为1~2G。目前,内核对应用程序申请内存的需求是基于尽量满足的原则,这就导致在手机等终端产品上,消耗比较大的内存的应用(比如照相机)在启动、运行过程中常因申请不到足够的内存(比如有的应用会瞬间申请300MB~500MB内存)而卡顿,甚至导致应用反复退出、重启的现象。
Linux系统的内存回收策略是在内存不足时触发,比如,当有应用被启动或切换到前台界面时,用户态的应用进程会向内核态申请内存,若该应用需要占用的内存大于系统空闲内存,则会触发内存回收,具体通过近期最少使用(Least Recently Used,LRU)算法选取最久最不常用的内存进行回收,除此之外,还可以通过内存压缩、相同页的合并、开展内存碎片整理等进行内存回收。安卓(Android)系统是通过在内核态设置空闲内存等级来在内核态触发内存回收,比如若内存少于n1MB,则杀掉优先级最低的应用进程,若内存再少于n2(n1<n2)MB,则释放掉优先级高一级的应用进程。
上述内存回收策略由于都是在内核态发现可供使用的空闲内存较少时才触发内存回收,从而容易导致系统内利用率较低的内存无法得到及时释放。当发现空闲内存不足时再触发内存回收,就容易导致当前运行的应用由于不能及时申请到所需的内存而出现卡顿。
发明内容
本申请提供一种内存回收方法及装置,用以一定程度上解决内存回收不及时、容易导致应用卡顿的问题。
本申请提供一种内存回收方法,在用户态执行:监控终端内安装的应用被用户操作使用的信息及内存占用信息;若根据终端内安装的应用被用户操作使用的信息及内存占用信息中的至少一种,确定当前满足内存回收条件,则根据终端内当前正在运行的应用被用户操作使用的信息及内存占用信息,从终端当前正在运行的应用中确定将被回收内存的应用,并通过调用内核态提供的内存回收接口执行内存回收。
本申请通过在用户态监控终端内安装的应用被用户操作使用的情况及内存占用情况来主动进行内存回收,从而可以在应用被用户操作使用频繁、内存占用量较大的时候,加快内存回收频率,保证内存的正常使用。
作为一种实施方式,根据所述终端内安装的应用被用户操作使用的信息及内存占用信息,确定当前满足内存回收条件,包括:根据终端内安装的应用被用户操作使用的信息及内存占用信息,确定内存回收时间间隔;在当前时间到达内存回收时间间隔所指示的内存回收时间时,确定当前满足内存回收条件。
在该实施方式下,首先根据用户使用应用的规律确定内存回收时间间隔,然后根据内存回收时间间隔所指示的内存回收时间主动进行内存回收,这种方式对内存进行有计划的回收,可以使终端内可用空闲内存保持在一个较佳的水平。
在上述实施方式中,确定内存回收时间间隔的一种可选方式为:分别确定在预设的至少一个时间段中的每个时间段内所述终端内安装的应用被用户操作使用的信息及内存占用信息;针对所述至少一个时间段中的每个时间段,分别根据在该时间段内所述终端内安装的应用被用户操作使用的信息及内存占用信息,确定在该时间段内的内存回收时间间隔。
由于用户在不同的时间段内操作使用应用的频率不同,采用这种方式可 以在不同的时间段使用不同的内存回收时间间隔,在进一步提高内存回收的及时性的同时,避免因频繁执行不必要的内存回收流程而浪费系统资源。
作为另一种实施方式,根据所述终端内安装的应用的内存占用信息,确定当前满足内存回收条件,包括:若确定系统内空闲内存小于第一设定阈值,则确定当前满足内存回收条件。
采用这种方式,可以一定程度上避免出现内存不足的情况出现。
作为又一种实施方式,根据终端内安装的应用被用户操作使用的信息及内存占用信息,确定当前满足内存回收条件,包括:若监测到有应用被启动或切换到前台界面,则根据该应用的内存占用信息,以及系统内空闲内存大小,判断是否需要进行内存回收;若需要进行内存回收,则确定当前满足内存回收条件。
由于新启动应用或切换到前台界面的应用通常是用户即将使用的应用,采用这种方式可以保证新启动应用或切换到前台界面的应用的正常运行,从而提升系统性能,提高用户体验。
作为再一种实施方式,根据终端内安装的应用被用户操作使用的信息,确定当前满足内存回收条件,包括:若当前在后台运行的应用的个数大于设置的允许后台运行应用的个数,则确定当前满足内存回收条件。
进一步地,这里可以每隔一段时间根据当前空闲内存大小来设置允许后台运行应用的个数。由于后台运行的应用通常不是用户正在操作使用的应用,限制这部分应用的个数,可以避免对内存的过多无效占用。
在上述实施方式中,确定将被回收内存的应用,并通过调用内核态提供的内存回收接口进行内存回收的一种可选方式为:根据预先保存的被回收内存的应用的优先级顺序,选择终端内当前正在运行的、用户没有在操作使用的应用,确定当前时间是否位于选择的应用的高概率使用时间段,该应用的高概率使用时间段为基于该应用被用户操作使用的信息确定的;若不是,则确定选择的所述应用为被回收内存的应用,并通过调用内核态提供的内存回收接口进行内存回收;重复上述步骤,直到满足内存回收的终止条件。
采用这种方式,优先选择回收优先级较低(这部分应用通常是用户不常使用的应用)的、且当前时间不在其高概率运行时间段的应用的内存,可以进一步提高系统性能,提升用户体验。
上述实施方式中,内存回收的终止条件可以包括以下条件中的一种或多种:
系统内空闲内存大小大于第二设定阈值;
当前启动的应用所需的内存小于系统空闲内存;
切换到前台界面的应用所需的内存小于系统空闲内存;
后台运行应用的个数小于或等于设置的允许后台运行应用的个数。
进一步地,可以根据以下步骤设置被回收内存的应用的优先级顺序:
按照终端内安装各个应用的使用频率,对各个应用进行分组,其中,同组内的应用具有相同的使用频率范围;根据每个分组对应的使用频率范围,确定各个分组内的应用被回收内存的优先级顺序;其中,同组内的应用具有相同的优先级顺序。
作为又一种实施方式,根据所述终端内安装的应用被用户操作使用的信息,确定当前满足内存回收条件,通过调用内核态提供的内存回收接口执行内存回收,包括:若监测到终端内存在应用在后台停留的时间长度超过设定时长,则确定当前满足内存回收条件,通过调用内核态提供的内存回收接口对在后台停留的时间长度超过设定时长的应用的内存进行回收。
这里,在后台停留时间较长的应用一般是用户当前一段时间不再操作的应用,可以释放掉这部分应用的内存,以便提供给更有需要的应用,从而提高了对内存的有效利用率。
本申请还提供一种内存回收装置,包括:
确定模块,用于在用户态监控终端内安装的应用被用户操作使用的信息及内存占用信息;
内存回收模块,用于若根据所述终端内安装的应用被用户操作使用的信息及内存占用信息中的至少一种,确定当前满足内存回收条件,则根据所述 终端内当前正在运行的应用被用户操作使用的信息及内存占用信息,从所述终端当前正在运行的应用中确定将被回收内存的应用,并通过调用内核态提供的内存回收接口执行内存回收。
本申请通过在用户态监控终端内安装的应用被用户操作使用的情况及内存占用情况来主动进行内存回收,从而可以在应用被用户操作使用频繁、内存占用量较大的时候,加快内存回收频率,保证内存的正常使用。
作为一种实施方式,内存回收模块具体用于:
根据终端内安装的应用被用户操作使用的信息及内存占用信息,确定内存回收时间间隔;在当前时间到达所述内存回收时间间隔所指示的内存回收时间时,确定当前满足内存回收条件。
在该实施方式下,首先根据用户使用应用的规律确定内存回收时间间隔,然后根据内存回收时间间隔所指示的内存回收时间主动进行内存回收,这种方式对内存进行有计划的回收,可以使终端内可用空闲内存保持在一个较佳的水平。
在上述实施方式中,内存回收模块确定内存回收时间间隔的一种可选方式为:分别确定在预设的至少一个时间段中的每个时间段内所述终端内安装的应用被用户操作使用的信息及内存占用信息;针对所述至少一个时间段中的每个时间段,分别根据在该时间段内所述终端内安装的应用被用户操作使用的信息及内存占用信息,确定在该时间段内的内存回收时间间隔。
由于用户在不同的时间段内操作使用应用的频率不同,采用这种方式可以在不同的时间段使用不同的内存回收时间间隔,在进一步提高内存回收的及时性的同时,避免因频繁执行不必要的内存回收流程而浪费系统资源。
作为另一种实施方式,内存回收模块具体用于:若确定系统内空闲内存小于第一设定阈值,则确定当前满足内存回收条件。
采用这种方式,可以避免出现内存不足的情况出现。
作为又一种实施方式,内存回收模块具体用于:若监测到有应用被启动或切换到前台界面,则根据该应用的内存占用信息,以及系统内空闲内存大 小,判断是否需要进行内存回收;若需要进行内存回收,则确定当前满足内存回收条件。
由于新启动应用或切换到前台界面的应用通常是用户即将使用的应用,采用这种方式可以保证新启动应用或切换到前台界面的应用的正常运行,从而提升系统性能,也提高了用户体验。
作为再一种实施方式,内存回收模块具体用于:若当前在后台运行的应用的个数大于设置的允许后台运行应用的个数,则确定当前满足内存回收条件。
进一步地,这里可以每隔一段时间根据当前空闲内存大小来设置允许后台运行应用的个数。由于后台运行的应用通常不是用户正在操作使用的应用,限制这部分应用的个数,可以避免对内存的过多无效占用。
在上述实施方式中,内存回收模块确定将被回收内存的应用,并通过调用内核态提供的内存回收接口进行内存回收的一种可选方式为:根据预先保存的被回收内存的应用的优先级顺序,选择终端内当前正在运行的、用户没有在操作使用的应用,确定当前时间是否位于选择的应用的高概率使用时间段,该应用的高概率使用时间段为基于该应用被用户操作使用的信息确定的;若不是,则确定选择的所述应用为被回收内存的应用,并通过调用内核态提供的内存回收接口进行内存回收;重复上述步骤,直到满足内存回收的终止条件。
采用这种方式,优先选择回收优先级较低(这部分应用通常是用户不常使用的应用)的、且当前时间不在其高概率运行时间段的应用的内存,可以进一步提高系统性能,提升用户体验。
上述实施方式中,内存回收的终止条件可以包括以下条件中的一种或多种:
系统内空闲内存大小大于第二设定阈值;
当前启动的应用所需的内存小于系统空闲内存;
切换到前台界面的应用所需的内存小于系统空闲内存;
后台运行应用的个数小于或等于设置的允许后台运行应用的个数。
进一步地,内存回收模块可以具体用于根据以下步骤设置被回收内存的应用的优先级顺序:按照终端内安装各个应用的使用频率,对各个应用进行分组,其中,同组内的应用具有相同的使用频率范围;根据每个分组对应的使用频率范围,确定各个分组内的应用被回收内存的优先级顺序;其中,同组内的应用具有相同的优先级顺序。
作为又一种实施方式,内存回收模块具体用于:若监测到终端内存在应用在后台停留的时间长度超过设定时长,则确定当前满足内存回收条件,通过调用内核态提供的内存回收接口对在后台停留的时间长度超过设定时长的应用的内存进行回收。
本申请提供一种用户设备,该用户设备包括处理器、存储器、和总线;存储器用于存储执行指令,包括内存和外部存储器;这里的内存也称内存储器,用于暂时存放处理器中的运算数据,以及与硬盘等外部存储器交换的数据,处理器通过内存与外部存储器进行数据交换,当用户设备运行时,处理器与存储器之间通过总线通信,使得处理器在用户态执行以下指令:
监控终端内安装的应用被用户操作使用的信息及内存占用信息;在根据终端内安装的应用被用户操作使用的信息及内存占用信息中的至少一种,确定当前满足内存回收条件时,根据终端内当前正在运行的应用被用户操作使用的信息及内存占用信息,从终端当前正在运行的应用中确定将被回收内存的应用,并通过调用内核态提供的内存回收接口执行内存回收。
本申请通过在用户态监控终端内安装的应用被用户操作使用的情况及内存占用情况来主动进行内存回收,从而可以在应用被用户操作使用频繁、内存占用量较大的时候,加快内存回收频率,保证内存的正常使用。
作为一种实施方式,处理器执行的指令中,根据所述终端内安装的应用被用户操作使用的信息及内存占用信息,确定当前满足内存回收条件,包括:根据终端内安装的应用被用户操作使用的信息及内存占用信息,确定内存回收时间间隔;在当前时间到达内存回收时间间隔所指示的内存回收时间时, 确定当前满足内存回收条件。
在该实施方式下,首先根据用户使用应用的规律确定内存回收时间间隔,然后根据内存回收时间间隔所指示的内存回收时间主动进行内存回收,这种方式对内存进行有计划的回收,可以使终端内可用空闲内存保持在一个较佳的水平。
在上述实施方式中,处理器执行的指令中,确定内存回收时间间隔的一种可选方式为:
分别确定在预设的至少一个时间段中的每个时间段内所述终端内安装的应用被用户操作使用的信息及内存占用信息;针对所述至少一个时间段中的每个时间段,分别根据在该时间段内所述终端内安装的应用被用户操作使用的信息及内存占用信息,确定在该时间段内的内存回收时间间隔。
由于用户在不同的时间段内操作使用应用的频率不同,采用这种方式可以在不同的时间段使用不同的内存回收时间间隔,在进一步提高内存回收的及时性的同时,避免因频繁执行不必要的内存回收流程而浪费系统资源。
作为另一种实施方式,处理器执行的指令中,根据终端内安装的应用的内存占用信息,确定当前满足内存回收条件,包括:若确定系统内空闲内存小于第一设定阈值,则确定当前满足内存回收条件。
采用这种方式,可以避免出现内存不足的情况出现。
作为又一种实施方式,处理器执行的指令中,根据终端内安装的应用被用户操作使用的信息及内存占用信息,确定当前满足内存回收条件,包括:若监测到有应用被启动或切换到前台界面,则根据该应用的内存占用信息,以及系统内空闲内存大小,判断是否需要进行内存回收;若需要进行内存回收,则确定当前满足内存回收条件。
由于新启动应用或切换到前台界面的应用通常是用户即将使用的应用,采用这种方式可以保证新启动应用或切换到前台界面的应用的正常运行,从而提升系统性能,也提高了用户体验。
作为再一种实施方式,处理器执行的指令中,根据终端内安装的应用被 用户操作使用的信息,确定当前满足内存回收条件,包括:若当前在后台运行的应用的个数大于设置的允许后台运行应用的个数,则确定当前满足内存回收条件。
进一步地,这里可以每隔一段时间根据当前空闲内存大小来设置允许后台运行应用的个数。由于后台运行的应用通常不是用户正在操作使用的应用,限制这部分应用的个数,可以避免对内存的过多无效占用。
在上述实施方式中,处理器执行的指令中,确定将被回收内存的应用,并通过调用内核态提供的内存回收接口进行内存回收的一种可选方式为:根据预先保存的被回收内存的应用的优先级顺序,选择终端内当前正在运行的、用户没有在操作使用的应用,确定当前时间是否位于选择的应用的高概率使用时间段,该应用的高概率使用时间段为基于该应用被用户操作使用的信息确定的;若不是,则确定选择的所述应用为被回收内存的应用,并通过调用内核态提供的内存回收接口进行内存回收;重复上述步骤,直到满足内存回收的终止条件。
采用这种方式,优先选择回收优先级较低(这部分应用通常是用户不常使用的应用)的、且当前时间不在其高概率运行时间段的应用的内存,可以进一步提高系统性能,提升用户体验。
上述实施方式中,内存回收的终止条件可以包括以下条件中的一种或多种:
系统内空闲内存大小大于第二设定阈值;
当前启动的应用所需的内存小于系统空闲内存;
切换到前台界面的应用所需的内存小于系统空闲内存;
后台运行应用的个数小于或等于设置的允许后台运行应用的个数。
进一步地,处理器执行的指令中,设置被回收内存的应用的优先级顺序的一种可选方式为:
按照终端内安装各个应用的使用频率,对各个应用进行分组,其中,同组内的应用具有相同的使用频率范围;根据每个分组对应的使用频率范围, 确定各个分组内的应用被回收内存的优先级顺序;其中,同组内的应用具有相同的优先级顺序。
作为又一种实施方式,处理器执行的指令中,根据所述终端内安装的应用被用户操作使用的信息,确定当前满足内存回收条件,通过调用内核态提供的内存回收接口执行内存回收,包括:若监测到终端内存在应用在后台停留的时间长度超过设定时长,则确定当前满足内存回收条件,通过调用内核态提供的内存回收接口对在后台停留的时间长度超过设定时长的应用的内存进行回收。
这里,在后台停留时间较长的应用一般是用户当前一段时间不再操作的应用,可以释放掉这部分应用的内存,以便提供给更有需要的应用,从而提高了对内存的有效利用率。
附图说明
图1为本申请提供的内存回收示意图;
图2为本申请实施例一提供的内存回收方法流程图;
图3为本申请实施例二提供的内存回收方法流程图;
图4为本申请实施例三提供的内存回收方法流程图;
图5为本申请实施例提供的内存回收装置50结构示意图;
图6为本申请实施例提供的用户设备60结构示意图;
图7为本申请提供的一种终端设备700的结构示意图;
图8为本申请实施例终端800的结构示意图。
具体实施方式
如图1所示,为本申请提供的内存回收示意图。本申请通过在用户态运行内存回收策略,并通过内核态提供的内存回收接口进行内存回收。具体地,通过监测终端内安装的应用(Application,App)被用户操作使用的信息及内存占用信息来触发内存回收,在满足内存回收条件后,根据终端内当前正在 运行的应用被用户操作使用的信息及内存占用信息,从当前正在运行的应用中选取被回收内存的应用,并通过调用内核态提供给用户态的内存回收接口进行内存回收。本申请通过在用户态监控应用被用户操作使用的信息及内存占用信息主动进行内存回收,从而可以在应用被用户操作使用频繁、内存占用量较大的时候,加快内存回收频率,保证内存回收的及时性。
下面结合说明书附图对本申请实施例作进一步详细描述。
实施例一
如图2所示,为本申请实施例一提供的内存回收方法流程图,在用户态执行以下步骤:
S201:监控终端内安装的应用被用户操作使用的信息及内存占用信息。
这里,所述内存占用信息可以包括应用运行时占用的内存大小,应用被用户操作使用的信息可以包括用户对应用的使用频率、使用时间段、使用时长等。
在具体实施中,可以在用户态使用监控进程实时监控终端系统内各个应用的运行状态及应用运行时占用的内存大小,通过监控得到的应用的运行状态可以确定用户对应用的使用频率、使用时间段、使用时长等。这里,用户对应用的使用时间段可以是指在预设的多个时间段内,用户使用了该应用的时间段。也可以是指从用户开始操作应用到结束操作应用的实际时间段。
这里,监控终端系统内各个应用的运行状态可以包括监控应用启动的状态、应用关闭的状态、应用从后台切换到前台界面的状态、及从前台界面切换到后台的状态等。监控进程具体可以通过proc文件系统提供的查询接口来查询得到应用的上述运行状态。
在具体实施中,针对不同的应用,统计应用被用户操作使用的信息的方式可以不同。比如,针对微信、日历等需要用户在前台界面操作的应用,可以将应用被启动或者切换到前台界面的时间作为用户开始操作该应用的时间,将应用被关闭或者切换到后台运行的时间作为用户结束操作该应用的时间。针对下载软件等无需用户始终在前台界面操作的应用,可以将应用被启动的 时间作为用户开始操作该应用的时间,将应用被关闭的时间作为用户结束操作该应用的时间。根据统计的用户开始操作应用的时间及结束操作应用的时间,可以确定用户对该应用的使用频率、使用时间段及使用时长等。
S202:基于根据所述终端内安装的应用被用户操作使用的信息及内存占用信息中的至少一种,判断当前是否满足内存回收条件,若满足,则进入S203,否则返回S201。
在具体实施中,可以根据实际需要设置在用户态触发内存回收的条件,比如可以根据终端内安装的应用被用户操作使用的信息及内存占用信息确定内存回收时间间隔,按照预设的内存回收时间间隔触发内存回收,实现对内存进行有计划的回收,使终端内可用空闲内存保持在一个较佳的水平。这里,预设的内存回收时间间隔可以为一个,也可以为多个,比如,若用户全天使用应用的频率及内存占用量都比较稳定,可以只设置一个内存回收时间间隔。或者,若用户全天只集中在一个时间段内使用应用,且使用应用的频率比较稳定,则可以只设置在这一个时间段内的内存回收时间间隔,在其它时间段不进行内存回收。若用户在一天内的不同时间段使用应用的频率区别较大,则可以在一天内的不同时间段使用不同的内存回收时间间隔。除此之外,还可以设置系统内空闲内存小于一定阈值时触发内存回收(即根据终端内安装的应用的内存占用信息触发内存回收)、在监测到有应用被启动或切换到前台界面时,根据该应用的内存占用信息以及系统内空闲内存大小触发内存回收(即根据应用被用户操作使用的信息及内存占用信息触发内存回收)、在监测到终端内存在应用在后台停留的时间长度超过设定时长时触发内存回收(即根据应用被用户操作使用的信息触发内存回收)等。
S203:根据所述终端内当前正在运行的应用被用户操作使用的信息及内存占用信息,从所述终端当前正在运行的应用中确定将被回收内存的应用,并通过调用内核态提供的内存回收接口执行内存回收。
这里,S201及S202中的终端内安装的应用包括S203中的终端内当前正在运行的应用,除S203中的终端内当前正在运行的应用之外,终端内安装的 应用还包括当前处于关闭状态的应用。
在具体实施中,在用户态通过内核态提供的内存回收接口,调用内核态的内存回收程序进行内存回收,该内存回收接口可以基于系统调用、linux procfs文件系统、或linux sysfs文件系统等来实现。
在linux系统中,内核态现有的内存回收管理是基于LRU算法实现的,它将应用占用的内存分成匿名页(比如通过动态内存分配(malloc)函数分配的内存)和文件页(比如读写文件时分配的内存)两大类,并根据LRU算法将最近不常使用的内存放到一个链表中,每次回收时收缩该链表,回收一部分内存页面(主要是页面缓存(page cache))。内核态用于内存回收的底层函数是try_to_free_pages(),本申请将这个函数接口暴露给用户态调用,在用户态基于本申请提供的内存回收策略,通过调用这个函数接口实现内存回收。
实施例二
下面,介绍本申请的一种优选的实施方式:通过统计所述终端内安装的应用被用户操作使用的信息及内存占用信息,确定内存回收时间间隔,基于确定的内存回收时间间隔进行内存回收。
如图3所示,为本申请实施例二提供的内存回收方法流程图,在用户态执行以下步骤:
S301:监控终端内安装的应用被用户操作使用的信息及内存占用信息。
在具体实施中,通过在用户态实时监测终端系统内各个应用的运行状态,统计用户对应用的使用频率、使用时间段等应用被用户操作使用的信息,以及应用运行时占用的内存大小等内存占用信息。
S302:根据所述终端内安装的应用被用户操作使用的信息及内存占用信息,确定内存回收时间间隔。
这里,可以根据在S301统计得到的各个应用被用户操作使用的信息及内存占用信息,确定内存回收时间间隔。该内存回收时间间隔可以为一个,也可以为多个,比如,若用户全天使用应用的频率及内存占用量都比较一致,则可以只设置一个内存回收时间间隔。若用户在一天内的不同时间段使用应 用的频率不同,则可以在一天内的不同时间段使用不同的内存回收时间间隔,比如可以在应用使用频繁、占用的内存量较大的时间段内加快内存回收频率,相反,可以在应用使用次数较少,占用的内存量较小的时间段内减少内存回收频率。
在具体实施中,可以依经验,预设几个时间段,确定在每个预设的时间段内,终端内安装的应用被用户操作使用的信息及内存占用信息;根据在每个预设的时间段内,终端内安装的应用被用户操作使用的信息及内存占用信息,确定在每个预设的时间段内的内存回收时间间隔。
比如,以一天为粒度,预设9:00-17:00、17:00-23:00、23:00-9:00这几个时间段,分别统计在这几个时间段内应用被用户操作使用的信息及内存占用信息,比如,在17:00-23:00这个时间段内,用户对应用的使用最为频繁,应用占用的内存大小也最大,可以将该时间段的内存回收时间间隔设为0.5h;在9:00-17:00这个时间段内,用户对应用的使用频次居中,占用的内存大小也居中,可以将该时间段的内存回收时间间隔设为1h;在23:00-9:00这个时间段内,用户对应用的使用频次最低,占用的内存大小也最小,可以将该时间段的内存回收时间间隔设为3h。再比如,还可以考虑在一周时间内的工作日和非工作日对应用使用情况的不同,分别为工作日和非工作日设置不同的内存回收时间间隔;比如,用户在周六、日使用应用的频率明显比工作日使用应用的频率频繁,则可以在周一~周五仍使用上述内存回收时间间隔,在周六、日加快内存回收频率,比如,在周六、日分别将在9:00-17:00、17:00-23:00、23:00-9:00这几个时间段内的内存回收时间间隔减半,也即,将在17:00-23:00这个时间段内的内存回收时间间隔设为0.25h,将在9:00-17:00这个时间段内的内存回收时间间隔设为0.5h,将在23:00-9:00这个时间段内的内存回收时间间隔设为1.5h。
S303:若根据所述内存回收时间间隔确定当前需要进行内存回收,则根据所述终端内当前正在运行的应用被用户操作使用的信息及内存占用信息,从所述终端当前正在运行的应用中确定将被回收内存的应用。这里,为了保 证用户对应用的正常使用,用户当前正在使用的应用不被考虑进行内存回收,用户正在使用的应用可以包括前台应用,还可以包括如文件下载等在后台运行的应用。
S304:通过调用内核态提供的内存回收接口执行内存回收。
在具体实施中,根据确定的内存回收时间间隔,当达到内存回收时间时,针对终端内当前正在运行的、用户没在操作使用的应用,若当前时间也不在统计的该应用被用户使用的概率较大的时间范围内,则可以回收该应用的内存,这样,依次选择应用进行内存回收,直到满足内存回收的终止条件。
作为一种实施方式,在确定当前需要进行内存回收后,可以按照预先保存的被回收内存的应用的优先级顺序,选择终端内当前正在运行的、用户没有在操作使用的应用,确定当前时间是否位于选择的应用的高概率使用时间段(也即应用被用户操作使用的概率较高的时间段),该应用的高概率使用时间段为基于该应用被用户操作使用的信息确定的(比如用户在连续5天内的每天中午12:00~13:00之间使用该应用,则12:00~13:00即为该应用的高概率运行时间段);若不是,则确定选择的应用为被回收内存的应用,如此重复,直到满足内存回收的终止条件。这里,所述内存回收的终止条件可以包括指系统内空闲内存大小大于第二设定阈值。
上述优先级顺序可以是不同应用分组之间的优先级顺序。具体地,可以按照终端内安装各个应用的使用频率,对各个应用进行分组,其中,同组内的应用具有相同的使用频率范围;根据每个分组对应的使用频率范围,确定各个分组内的应用被回收内存的优先级顺序;其中,同组内的应用具有相同的优先级顺序。比如,某些应用可能涉及终端内操作系统的关键要素,如用户界面(User Interface,UI),可以将这类应用归于组(group)1,表示非常重要的应用;对于一些用户经常使用的应用,如微信、相机等,可以将这类应用归于group2,表示为一般重要的应用;对于另一些不常使用的应用,如计算器、股票等,可以将这类应用归于group3,表示不重要的应用;设置group3的内存回收优先级>group2的内存回收优先级>group1的内存回收优先级,在 内存回收时,优先考虑回收group3中的应用的内存,次要考虑回收group2中的应用的内存,不回收group1中的应用的内存。
实施例三
为了进一步优化内存回收策略,保证内存回收的及时性和合理性,本申请实施例进一步给出了使用多种内存回收条件执行内存回收的实施方式。
如图4所示,为本申请实施例三提供的内存回收方法流程图,在用户态执行:
S401:监控终端内安装的应用被用户操作使用的信息及内存占用信息。
S402:根据所述终端内安装的应用被用户操作使用的信息及内存占用信息,确定内存回收时间间隔。
S403:当满足以下条件一~四中的任意一个或多个时,触发S404的内存回收流程,当满足条件五时,触发S405的内存回收流程:
一、根据所述内存回收时间间隔确定当前需要进行内存回收;
在具体实施中,还可以结合系统内空闲内存判断当前是否需要进行内存回收,也即在当前到达内存回收时间间隔指示的内存回收时间时,若系统内空闲内存小于某一阈值(该阈值可以是下述第一设定阈值、或第二设定阈值、或其它阈值,比如位于第一设定阈值和第二设定阈值之间(第一设定阈值小于第二设定阈值)的某一阈值),则可以进行内存回收。
二、监测到系统内空闲内存小于第一设定阈值;
三、当监测到有应用被启动或切换到前台界面时,根据该应用的内存占用信息,以及系统内空闲内存大小,确定当前需要进行内存回收;
这里,当新启动或切换到前台界面的应用需要的内存大小大于系统内空闲内存时,立即触发内存回收。
四、在后台运行的应用的个数M大于当前设置的允许后台运行应用的个数N;
在具体实施中,可以根据当前系统内空闲内存的大小,设置允许后台运行应用的个数。
五、监测到终端内存在应用在后台停留的时间长度超过设定时长。
需要说明的是,对于上述条件二~五,本领域技术人员根据实际需要可以只选择执行其中的部分条件。
S404:根据终端内当前正在运行的应用被用户操作使用的信息及内存占用信息,从所述终端当前正在运行的、用户没有在操作使用的应用中确定将被回收内存的应用,并通过调用内核态提供的内存回收接口执行内存回收。
在具体实施中,终端系统启动后,首先启动本申请用于内存回收的用户态的守护进程,然后启动各个应用,并维护一张应用运行数据表,记录终端内应用的内存占用情况,及统计的高概率运行时间段,如下表一所示。
应用 占用的内存 高概率运行时间段
App1 x1KB T1-T2
App2 x2KB T3-T4
App3 x3KB T5-T6
App4 x4KB T7-T8
…… …… ……
表一
若确定当前需要进行内存回收,则可以按照预先保存的被回收内存的应用的优先级顺序,选择终端内当前正在运行的应用,查看表一,判断当前时间是否位于选择的应用的高概率使用时间段;若不是,则将选择的该应用选取为被回收内存的应用,并通过调用内核态提供的用于内存回收的内存回收接口进行内存回收,直到满足内存回收的终止条件。这里,基于条件一~四的不同,上述内存回收的终止条件可以包括:系统内空闲内存大小大于第二设定阈值、当前启动的应用所需的内存小于系统空闲内存、切换到前台界面的应用所需的内存小于系统空闲内存、后台运行应用的个数小于或等于设置的允许后台运行应用的个数中的一种或多种。比如,针对条件一、二,内存回收的终止条件可以是系统内空闲内存大小大于第二设定阈值(第二设定阈值大于第一设定阈值),针对条件三,内存回收的终止条件可以是当前启动的应 用所需的内存小于系统空闲内存;针对条件四,内存回收的终止条件可以是后台运行应用的个数等于设置的个数,也即在S303中,从后台运行的应用中选取M-N个被回收内存的应用。
S405:通过调用内核态提供的内存回收接口,对在后台停留的时间长度超过设定时长的应用的内存进行回收。
基于同一发明构思,本申请还提供了与内存回收方法对应的内存回收装置及用户设备,由于该装置及用户设备解决问题的原理与本申请的内存回收方法相似,因此该装置及用户设备的实施可以参见方法的实施,重复之处不再赘述。
实施例四
如图5所示,为本申请实施例提供的内存回收装置50结构示意图,包括:
确定模块51,用于在用户态监控终端内安装的应用被用户操作使用的信息及内存占用信息;
内存回收模块52,用于若根据所述终端内安装的应用被用户操作使用的信息及内存占用信息中的至少一种,确定当前满足内存回收条件,则根据所述终端内当前正在运行的应用被用户操作使用的信息及内存占用信息,从所述终端当前正在运行的应用中确定将被回收内存的应用,并通过调用内核态提供的内存回收接口执行内存回收。
本申请通过在用户态监控终端内安装的应用被用户操作使用的情况及内存占用情况来主动进行内存回收,从而可以在应用被用户操作使用频繁、内存占用量较大的时候,加快内存回收频率,保证内存的正常使用。
可选地,所述内存回收模块52具体用于:
根据所述终端内安装的应用被用户操作使用的信息及内存占用信息,确定内存回收时间间隔;在当前时间到达所述内存回收时间间隔所指示的内存回收时间时,确定当前满足内存回收条件。
在该实施方式下,内存回收模块52首先根据用户使用应用的规律确定内存回收时间间隔,然后根据内存回收时间间隔所指示的内存回收时间主动进 行内存回收,这种方式对内存进行有计划的回收,可以使终端内可用空闲内存保持在一个较佳的水平。
可选地,所述内存回收模块52具体用于根据以下步骤确定内存回收时间间隔:
分别确定在预设的至少一个时间段中的每个时间段内所述终端内安装的应用被用户操作使用的信息及内存占用信息;针对所述至少一个时间段中的每个时间段,分别根据在该时间段内所述终端内安装的应用被用户操作使用的信息及内存占用信息,确定在该时间段内的内存回收时间间隔。
由于用户在不同的时间段内操作使用应用的频率不同,采用这种方式可以在不同的时间段使用不同的内存回收时间间隔,在进一步提高内存回收的及时性的同时,避免因频繁执行不必要的内存回收流程而浪费系统资源。
可选地,所述内存回收模块52具体用于:
若确定系统内空闲内存小于第一设定阈值,则确定当前满足内存回收条件。
采用这种方式,可以一定程度上避免出现内存不足的情况出现。
可选地,所述内存回收模块52具体用于:
若监测到有应用被启动或切换到前台界面,则根据该应用的内存占用信息,以及系统内空闲内存大小,判断是否需要进行内存回收;若需要进行内存回收,则确定当前满足内存回收条件。
由于新启动应用或切换到前台界面的应用通常是用户即将使用的应用,采用这种方式可以保证新启动应用或切换到前台界面的应用的正常运行,从而提升系统性能,提高用户体验。
可选地,所述内存回收模块52具体用于:
若当前在后台运行的应用的个数大于设置的允许后台运行应用的个数,则确定当前满足内存回收条件。
进一步地,这里可以每隔一段时间根据当前空闲内存大小来设置允许后台运行应用的个数。由于后台运行的应用通常不是用户正在操作使用的应用, 限制这部分应用的个数,可以避免对内存的过多无效占用。
可选地,所述内存回收模块52具体用于:
根据预先保存的被回收内存的应用的优先级顺序,选择终端内当前正在运行的、用户没有在操作使用的应用,确定当前时间是否位于选择的应用的高概率使用时间段,该应用的高概率使用时间段为基于该应用被用户操作使用的信息确定的;若不是,则确定选择的所述应用为被回收内存的应用,并通过调用内核态提供的内存回收接口进行内存回收;重复上述步骤,直到满足内存回收的终止条件。
采用这种方式,优先选择回收优先级较低(这部分应用通常是用户不常使用的应用)的、且当前时间不在其高概率运行时间段的应用的内存,可以进一步提高系统性能,提升用户体验。
可选地,所述内存回收的终止条件包括以下条件中的一种或多种:
系统内空闲内存大小大于第二设定阈值;
当前启动的应用所需的内存小于系统空闲内存;
切换到前台界面的应用所需的内存小于系统空闲内存;
后台运行应用的个数小于或等于设置的允许后台运行应用的个数。
可选地,所述内存回收模块52具体用于根据以下步骤设置被回收内存的应用的优先级顺序:
按照终端内安装各个应用的使用频率,对各个应用进行分组,其中,同组内的应用具有相同的使用频率范围;
根据每个分组对应的使用频率范围,确定各个分组内的应用被回收内存的优先级顺序;其中,同组内的应用具有相同的优先级顺序。
可选地,所述内存回收模块52具体用于:
若监测到终端内存在应用在后台停留的时间长度超过设定时长,则对在后台停留的时间长度超过设定时长的应用的内存进行回收。
这里,在后台停留时间较长的应用一般是用户当前一段时间不再操作的应用,可以释放掉这部分应用的内存,以便提供给更有需要的应用,从而提 高了对内存的有效利用率。
实施例五
如图6所示,为本申请实施例提供的用户设备60结构示意图,包括处理器61、存储器62、和总线63;存储器62用于存储执行指令,包括内存621和外部存储器622;这里的内存621也称内存储器,用于暂时存放处理器61中的运算数据,以及与硬盘等外部存储器622交换的数据,处理器61通过内存621与外部存储器622进行数据交换,当所述用户设备60运行时,所述处理器61与所述存储器62之间通过总线63通信,使得所述处理器61在用户态执行以下指令:
监控终端内安装的应用被用户操作使用的信息及内存占用信息;在根据终端内安装的应用被用户操作使用的信息及内存占用信息中的至少一种,确定当前满足内存回收条件时,根据终端内当前正在运行的应用被用户操作使用的信息及内存占用信息,从终端当前正在运行的应用中确定将被回收内存的应用,并通过调用内核态提供的内存回收接口执行内存回收。
可选地,处理器61执行的指令中,根据所述终端内安装的应用被用户操作使用的信息及内存占用信息,确定当前满足内存回收条件,包括:根据终端内安装的应用被用户操作使用的信息及内存占用信息,确定内存回收时间间隔;在当前时间到达内存回收时间间隔所指示的内存回收时间时,确定当前满足内存回收条件。
可选地,处理器61执行的指令中,确定内存回收时间间隔包括:
分别确定在预设的至少一个时间段中的每个时间段内所述终端内安装的应用被用户操作使用的信息及内存占用信息;针对所述至少一个时间段中的每个时间段,分别根据在该时间段内所述终端内安装的应用被用户操作使用的信息及内存占用信息,确定在该时间段内的内存回收时间间隔。。
可选地,处理器61执行的指令中,根据终端内安装的应用的内存占用信息,确定当前满足内存回收条件,包括:若确定系统内空闲内存小于第一设定阈值,则确定当前满足内存回收条件。
可选地,处理器61执行的指令中,根据终端内安装的应用被用户操作使用的信息及内存占用信息,确定当前满足内存回收条件,包括:若监测到有应用被启动或切换到前台界面,则根据该应用的内存占用信息,以及系统内空闲内存大小,判断是否需要进行内存回收;若需要进行内存回收,则确定当前满足内存回收条件。
可选地,处理器61执行的指令中,根据终端内安装的应用被用户操作使用的信息,确定当前满足内存回收条件,包括:若当前在后台运行的应用的个数大于设置的允许后台运行应用的个数,则确定当前满足内存回收条件。
进一步地,这里可以每隔一段时间根据当前空闲内存大小来设置允许后台运行应用的个数。由于后台运行的应用通常不是用户正在操作使用的应用,限制这部分应用的个数,可以避免对内存的过多无效占用。
可选地,处理器61执行的指令中,确定将被回收内存的应用,并通过调用内核态提供的内存回收接口进行内存回收,包括:根据预先保存的被回收内存的应用的优先级顺序,选择终端内当前正在运行的、用户没有在操作使用的应用,确定当前时间是否位于选择的应用的高概率使用时间段,该应用的高概率使用时间段为基于该应用被用户操作使用的信息确定的;若不是,则确定选择的所述应用为被回收内存的应用,并通过调用内核态提供的内存回收接口进行内存回收;重复上述步骤,直到满足内存回收的终止条件。
可选地,所述内存回收的终止条件包括以下条件中的一种或多种:
系统内空闲内存大小大于第二设定阈值;
当前启动的应用所需的内存小于系统空闲内存;
切换到前台界面的应用所需的内存小于系统空闲内存;
后台运行应用的个数小于或等于设置的允许后台运行应用的个数。
可选地,处理器61执行的指令中,设置被回收内存的应用的优先级顺序,包括:
按照终端内安装各个应用的使用频率,对各个应用进行分组,其中,同组内的应用具有相同的使用频率范围;根据每个分组对应的使用频率范围, 确定各个分组内的应用被回收内存的优先级顺序;其中,同组内的应用具有相同的优先级顺序。
可选地,处理器61执行的指令中,根据所述终端内安装的应用被用户操作使用的信息,确定当前满足内存回收条件,通过调用内核态提供的内存回收接口执行内存回收,包括:若监测到终端内存在应用在后台停留的时间长度超过设定时长,则确定当前满足内存回收条件,通过调用内核态提供的内存回收接口对在后台停留的时间长度超过设定时长的应用的内存进行回收。
实施例六
图7描述了本申请提供的一种终端设备700的结构,包括:至少一个处理器701、至少一个网络接口704或者其它用户接口703、存储器705、至少一个通信总线702,通信总线702用于实现这些组件之间的连接通信。这里,存储器705包括内存和外部存储器,这里的内存也称内存储器,用于暂时存放处理器701中的运算数据,以及与硬盘等外部存储器交换的数据,处理器701通过内存与外部存储器进行数据交换。
存储器705中存储了如下的元素,可执行模块或者数据结果,或者他们的子集,或者他们的扩展集:
操作系统7051,包含各种系统程序,可以具有内核态7051a和用户态7051b两种运行级别。当一个进程执行系统调用而陷入内核代码中执行时,称其处于内核运行态,简称内核态。当进程处于内核态时,执行的内核代码会使用当前进程的内核栈,每个进程都有自己的内核栈。当进程在执行用户自己的代码时,称其处于用户运行态,简称用户态,此时处理器701在特权级最低的用户代码中运行。
应用程序模块7052,包含各种应用程序(简称应用)。
在本申请实施例中,通过调用存储器705存储的程序或指令,处理器701用于在用户态执行:
监控终端内安装的应用被用户操作使用的信息及内存占用信息;在根据终端内安装的应用被用户操作使用的信息及内存占用信息中的至少一种,确 定当前满足内存回收条件时,根据终端内当前正在运行的应用被用户操作使用的信息及内存占用信息,从终端当前正在运行的应用中确定将被回收内存的应用,并通过调用内核态提供的内存回收接口执行内存回收。
可选地,作为一个实施例,处理器701还用于:根据终端内安装的应用被用户操作使用的信息及内存占用信息,确定内存回收时间间隔;在当前时间到达内存回收时间间隔所指示的内存回收时间时,确定当前满足内存回收条件。
进一步地,处理器701还用于:分别确定在预设的至少一个时间段中的每个时间段内所述终端内安装的应用被用户操作使用的信息及内存占用信息;针对所述至少一个时间段中的每个时间段,分别根据在该时间段内所述终端内安装的应用被用户操作使用的信息及内存占用信息,确定在该时间段内的内存回收时间间隔。
可选地,作为另一个实施例,处理器701还用于:若确定系统内空闲内存小于第一设定阈值,则确定当前满足内存回收条件。
可选地,作为又一个实施例,处理器701还用于:若监测到有应用被启动或切换到前台界面,则根据该应用的内存占用信息,以及系统内空闲内存大小,判断是否需要进行内存回收;若需要进行内存回收,则确定当前满足内存回收条件。
可选地,作为再一个实施例,处理器701还用于:若当前在后台运行的应用的个数大于设置的允许后台运行应用的个数,则确定当前满足内存回收条件。
进一步地,这里可以每隔一段时间根据当前空闲内存大小来设置允许后台运行应用的个数。由于后台运行的应用通常不是用户正在操作使用的应用,限制这部分应用的个数,可以避免对内存的过多无效占用。
进一步地,处理器701还用于:确定将被回收内存的应用,并通过调用内核态提供的内存回收接口进行内存回收,包括:根据预先保存的被回收内存的应用的优先级顺序,选择终端内当前正在运行的、用户没有在操作使用 的应用,确定当前时间是否位于选择的应用的高概率使用时间段,该应用的高概率使用时间段为基于该应用被用户操作使用的信息确定的;若不是,则确定选择的所述应用为被回收内存的应用,并通过调用内核态提供的内存回收接口进行内存回收;重复上述步骤,直到满足内存回收的终止条件。
所述内存回收的终止条件包括以下条件中的一种或多种:
系统内空闲内存大小大于第二设定阈值;
当前启动的应用所需的内存小于系统空闲内存;
切换到前台界面的应用所需的内存小于系统空闲内存;
后台运行应用的个数小于或等于设置的允许后台运行应用的个数。
进一步地,处理器701还用于:按照终端内安装各个应用的使用频率,对各个应用进行分组,其中,同组内的应用具有相同的使用频率范围;根据每个分组对应的使用频率范围,确定各个分组内的应用被回收内存的优先级顺序;其中,同组内的应用具有相同的优先级顺序。
可选地,作为再一个实施例,处理器701还用于:若监测到终端内存在应用在后台停留的时间长度超过设定时长,则对在后台停留的时间长度超过设定时长的应用的内存进行回收。
另外,终端设备700还可执行图2~4的方法及实施例,本申请实施例在此不再赘述。
可见,采用上述方案后,可以在应用被用户操作使用频繁、内存占用量较大的时候,加快内存回收频率,保证内存的正常使用。
实施例七
本申请实施例涉及一种终端800及内存回收方法,该终端800可以为手机、平板电脑、个人数字助理(Personal Digital Assistant,PDA)、销售终端(Point of Sales,POS)、或车载电脑等。
图8示出的是本申请实施例终端800的结构示意图。
参考图8,本申请实施例的一种终端800,包括:处理器810、存储器820、输入单元830、电源850、射频(Radio Frequency,RF)电路860、音频电路 870、无线保真(WiFi)模块880。
其中,存储器820包括内存821和外部存储器822,内存821用于暂时存放处理器810中的运算数据,以及与硬盘等外部存储器822交换的数据,处理器810通过内存821与外部存储器822进行数据交换。内存821可以为非易失存储器(Non-Volatile Random Access Memory,NVRAM)、动态随机存储器(Dynamic Random Access Memory,DRAM)、静态随机存储器(Static RAM,SRAM)、Flash闪存等其中之一;外部存储器822可以为硬盘、光盘、USB盘、软盘或磁带机等。
处理器810在用户态执行存储器820中的指令:监控终端内安装的应用被用户操作使用的信息及内存占用信息;在根据终端内安装的应用被用户操作使用的信息及内存占用信息中的至少一种,确定当前满足内存回收条件时,根据终端内当前正在运行的应用被用户操作使用的信息及内存占用信息,从终端当前正在运行的应用中确定将被回收内存的应用,并通过调用内核态提供的内存回收接口执行内存回收。内存回收可以是由设置的内存回收时间间隔所触发的,具体地,处理器810可以分别确定在预设的至少一个时间段中的每个时间段内所述终端内安装的应用被用户操作使用的信息及内存占用信息;针对所述至少一个时间段中的每个时间段,分别根据在该时间段内所述终端内安装的应用被用户操作使用的信息及内存占用信息,确定在该时间段内的内存回收时间间隔。可选地,还可以在确定系统内空闲内存小于第一设定阈值时,触发内存回收。还可以在监测到有应用被启动或切换到前台界面时,根据该应用的内存占用信息,以及系统内空闲内存大小,判断是否需要进行内存回收;若需要进行内存回收,则触发内存回收。还可以在当前在后台运行的应用的个数大于设置的允许后台运行应用的个数时,触发内存回收条件。进一步地,这里可以每隔一段时间根据当前空闲内存大小来设置允许后台运行应用的个数。由于后台运行的应用通常不是用户正在操作使用的应用,限制这部分应用的个数,可以避免对内存的过多无效占用。
可选地,基于上述触发条件,处理器810执行内存回收的过程可以为: 根据预先保存的被回收内存的应用的优先级顺序,选择终端内当前正在运行的、用户没有在操作使用的应用,确定当前时间是否位于选择的应用的高概率使用时间段,该应用的高概率使用时间段为基于该应用被用户操作使用的信息确定的;若不是,则确定选择的所述应用为被回收内存的应用,并通过调用内核态提供的内存回收接口进行内存回收;重复上述步骤,直到满足内存回收的终止条件。进一步地,内存回收的终止条件可以包括如下条件中的一种或多种:系统内空闲内存大小大于第二设定阈值;当前启动的应用所需的内存小于系统空闲内存;切换到前台界面的应用所需的内存小于系统空闲内存;后台运行应用的个数小于或等于设置的允许后台运行应用的个数。进一步地,可以按照终端内安装各个应用的使用频率,对各个应用进行分组,其中,同组内的应用具有相同的使用频率范围;根据每个分组对应的使用频率范围,确定各个分组内的应用被回收内存的优先级顺序;其中,同组内的应用具有相同的优先级顺序。
除此之外,处理器810还可以在确定当前满足内存回收条件时,通过调用内核态提供的内存回收接口执行内存回收。
输入单元830可用于接收输入的数字或字符信息,以及产生与终端800的用户设置以及功能控制有关的信号输入。具体地,本申请实施例中,输入单元830可以包括触控面板831。触控面板831,也称为触摸屏,可收集用户在其上或附近的触摸操作(比如用户使用手指、触笔等任何适合的物体或附件在触控面板831上或在触控面板831的操作),并根据预先设定的程式驱动相应的连接装置。可选的,触控面板831可包括触摸检测装置和触摸控制器两个部分。其中,触摸检测装置检测用户的触摸方位,并检测触摸操作带来的信号,将信号传送给触摸控制器;触摸控制器从触摸检测装置上接收触摸信息,并将它转换成触点坐标,再送给该处理器810,并能接收处理器810发来的命令并加以执行。此外,可以采用电阻式、电容式、红外线以及表面声波等多种类型实现触控面板831。除了触控面板831,输入单元830还可以包括其他输入设备832,其他输入设备832可以包括但不限于物理键盘、功能键 (比如音量控制按键、开关按键等)、轨迹球、鼠标、操作杆等中的一种或多种。
该终端800还可以包括显示单元840,该显示单元840可用于显示由用户输入的信息或提供给用户的信息以及终端800的各种菜单界面。该显示单元840可包括显示面板841,可选的,可以采用LCD(Liquid Crystal Display,液晶显示器)或OLED(Organic Light-Emitting Diode,有机发光二极管)等形式来配置显示面板841。
本申请实施例中,触控面板831覆盖显示面板841,形成触摸显示屏,当该触摸显示屏检测到在其上或附近的触摸操作后,传送给处理器810以确定触摸事件的类型,随后处理器810根据触摸事件的类型在触摸显示屏上提供相应的视觉输出。
本申请实施例中,触摸显示屏包括应用程序界面显示区及常用控件显示区。该应用程序界面显示区及该常用控件显示区的排列方式并不限定,可以为上下排列、左右排列等可以区分两个显示区的排列方式。该应用程序界面显示区可以用于显示应用程序的界面。每一个界面可以包含至少一个应用程序的图标和/或widget桌面控件等界面元素。该应用程序界面显示区也可以为不包含任何内容的空界面。该常用控件显示区用于显示使用率较高的控件,例如,设置按钮、界面编号、滚动条、电话本图标等应用程序图标等。
该处理器810是终端800的控制中心,利用各种接口和线路连接整个手机的各个部分,通过运行或执行存储在该内存821内的软件程序和/或模块,以及调用存储在该外部存储器822内的数据,执行终端800的各种功能和处理数据,从而对终端800进行整体监控。
本领域内的技术人员应明白,本申请的实施例可提供为方法、系统、或计算机程序产品。因此,本申请可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本申请可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。
本申请是参照根据本申请实施例的方法、装置(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。
尽管已描述了本申请的优选实施例,但本领域内的技术人员一旦得知了基本创造性概念,则可对这些实施例作出另外的变更和修改。所以,所附权利要求意欲解释为包括优选实施例以及落入本申请范围的所有变更和修改。
显然,本领域的技术人员可以对本申请进行各种改动和变型而不脱离本申请的精神和范围。这样,倘若本申请的这些修改和变型属于本申请权利要求及其等同技术的范围之内,则本申请也意图包含这些改动和变型在内。

Claims (20)

  1. 一种内存回收方法,其特征在于,在用户态执行以下步骤:
    监控终端内安装的应用被用户操作使用的信息及内存占用信息;
    若根据所述终端内安装的应用被用户操作使用的信息及内存占用信息中的至少一种,确定当前满足内存回收条件,则
    根据所述终端内当前正在运行的应用被用户操作使用的信息及内存占用信息,从所述终端当前正在运行的应用中确定将被回收内存的应用,并通过调用内核态提供的内存回收接口执行内存回收。
  2. 如权利要求1所述的方法,其特征在于,根据所述终端内安装的应用被用户操作使用的信息及内存占用信息,确定当前满足内存回收条件,包括:
    根据所述终端内安装的应用被用户操作使用的信息及内存占用信息,确定内存回收时间间隔;
    在当前时间到达所述内存回收时间间隔所指示的内存回收时间时,确定当前满足内存回收条件。
  3. 如权利要求2所述的方法,其特征在于,所述根据所述终端内安装的应用被用户操作使用的信息及内存占用信息,确定内存回收时间间隔,包括:
    分别确定在预设的至少一个时间段中的每个时间段内所述终端内安装的应用被用户操作使用的信息及内存占用信息;
    针对所述至少一个时间段中的每个时间段,分别根据在该时间段内所述终端内安装的应用被用户操作使用的信息及内存占用信息,确定在该时间段内的内存回收时间间隔。
  4. 如权利要求1所述的方法,其特征在于,所述根据所述终端内安装的应用的内存占用信息,确定当前满足内存回收条件,包括:
    若确定系统内空闲内存小于第一设定阈值,则确定当前满足内存回收条件。
  5. 如权利要求1所述的方法,其特征在于,所述根据所述终端内安装的 应用被用户操作使用的信息及内存占用信息,确定当前满足内存回收条件,包括:
    若监测到有应用被启动或切换到前台界面,则根据该应用的内存占用信息,以及系统内空闲内存大小,判断是否需要进行内存回收;
    若需要进行内存回收,则确定当前满足内存回收条件。
  6. 如权利要求1所述的方法,其特征在于,所述根据所述终端内安装的应用被用户操作使用的信息,确定当前满足内存回收条件,包括:
    若当前在后台运行的应用的个数大于设置的允许后台运行应用的个数,则确定当前满足内存回收条件。
  7. 如权利要求2~6任一所述的方法,其特征在于,所述确定将被回收内存的应用,并通过调用内核态提供的内存回收接口进行内存回收,包括:
    根据预先保存的被回收内存的应用的优先级顺序,选择终端内当前正在运行的、用户没有在操作使用的应用,确定当前时间是否位于选择的应用的高概率使用时间段,该应用的高概率使用时间段为基于该应用被用户操作使用的信息确定的;若不是,则确定选择的所述应用为被回收内存的应用,并通过调用内核态提供的内存回收接口进行内存回收;
    重复上述步骤,直到满足内存回收的终止条件。
  8. 如权利要求7所述的方法,其特征在于,所述内存回收的终止条件包括以下条件中的一种或多种:
    系统内空闲内存大小大于第二设定阈值;
    当前启动的应用所需的内存小于系统空闲内存;
    切换到前台界面的应用所需的内存小于系统空闲内存;
    后台运行应用的个数小于或等于设置的允许后台运行应用的个数。
  9. 如权利要求7或8所述的方法,其特征在于,根据以下步骤设置被回收内存的应用的优先级顺序:
    按照终端内安装各个应用的使用频率,对各个应用进行分组,其中,同组内的应用具有相同的使用频率范围;
    根据每个分组对应的使用频率范围,确定各个分组内的应用被回收内存的优先级顺序;其中,同组内的应用具有相同的优先级顺序。
  10. 如权利要求1所述的方法,其特征在于,所述根据所述终端内安装的应用被用户操作使用的信息,确定当前满足内存回收条件,通过调用内核态提供的内存回收接口执行内存回收,包括:
    若监测到终端内存在应用在后台停留的时间长度超过设定时长,则确定当前满足内存回收条件,通过调用内核态提供的内存回收接口对在后台停留的时间长度超过设定时长的应用的内存进行回收。
  11. 一种内存回收装置,其特征在于,该装置包括:
    确定模块,用于在用户态监控终端内安装的应用被用户操作使用的信息及内存占用信息;
    内存回收模块,用于若根据所述终端内安装的应用被用户操作使用的信息及内存占用信息中的至少一种,确定当前满足内存回收条件,则根据所述终端内当前正在运行的应用被用户操作使用的信息及内存占用信息,从所述终端当前正在运行的应用中确定将被回收内存的应用,并通过调用内核态提供的内存回收接口执行内存回收。
  12. 如权利要求11所述的装置,其特征在于,所述内存回收模块具体用于:
    根据所述终端内安装的应用被用户操作使用的信息及内存占用信息,确定内存回收时间间隔;在当前时间到达所述内存回收时间间隔所指示的内存回收时间时,确定当前满足内存回收条件。
  13. 如权利要求12所述的装置,其特征在于,所述内存回收模块具体用于根据以下步骤确定内存回收时间间隔:
    分别确定在预设的至少一个时间段中的每个时间段内所述终端内安装的应用被用户操作使用的信息及内存占用信息;针对所述至少一个时间段中的每个时间段,分别根据在该时间段内所述终端内安装的应用被用户操作使用的信息及内存占用信息,确定在该时间段内的内存回收时间间隔。
  14. 如权利要求11所述的装置,其特征在于,所述内存回收模块具体用于:
    若确定系统内空闲内存小于第一设定阈值,则确定当前满足内存回收条件。
  15. 如权利要求11所述的装置,其特征在于,所述内存回收模块具体用于:
    若监测到有应用被启动或切换到前台界面,则根据该应用的内存占用信息,以及系统内空闲内存大小,判断是否需要进行内存回收;若需要进行内存回收,则确定当前满足内存回收条件。
  16. 如权利要求11所述的装置,其特征在于,所述内存回收模块具体用于:
    若当前在后台运行的应用的个数大于设置的允许后台运行应用的个数,则确定当前满足内存回收条件。
  17. 如权利要求12~16任一所述的装置,其特征在于,所述内存回收模块具体用于根据以下步骤进行内存回收:
    根据预先保存的被回收内存的应用的优先级顺序,选择终端内当前正在运行的、用户没有在操作使用的应用,确定当前时间是否位于选择的应用的高概率使用时间段,该应用的高概率使用时间段为基于该应用被用户操作使用的信息确定的;若不是,则确定选择的所述应用为被回收内存的应用,并通过调用内核态提供的内存回收接口进行内存回收;重复上述步骤,直到满足内存回收的终止条件。
  18. 如权利要求17所述的装置,其特征在于,所述内存回收的终止条件包括以下条件中的一种或多种:
    系统内空闲内存大小大于第二设定阈值;
    当前启动的应用所需的内存小于系统空闲内存;
    切换到前台界面的应用所需的内存小于系统空闲内存;
    后台运行应用的个数小于或等于设置的允许后台运行应用的个数。
  19. 如权利要求17或18所述的装置,其特征在于,所述内存回收模块具体用于根据以下步骤设置被回收内存的应用的优先级顺序:
    按照终端内安装各个应用的使用频率,对各个应用进行分组,其中,同组内的应用具有相同的使用频率范围;
    根据每个分组对应的使用频率范围,确定各个分组内的应用被回收内存的优先级顺序;其中,同组内的应用具有相同的优先级顺序。
  20. 如权利要求11所述的装置,其特征在于,所述内存回收模块具体用于:
    若监测到终端内存在应用在后台停留的时间长度超过设定时长,则确定当前满足内存回收条件,通过调用内核态提供的内存回收接口对在后台停留的时间长度超过设定时长的应用的内存进行回收。
PCT/CN2016/111557 2015-12-31 2016-12-22 一种内存回收方法及装置 WO2017114288A1 (zh)

Priority Applications (5)

Application Number Priority Date Filing Date Title
EP16881077.8A EP3388946B1 (en) 2015-12-31 2016-12-22 Memory collection method and device
KR1020187020861A KR20180097674A (ko) 2015-12-31 2016-12-22 메모리 리클레임 방법 및 장치
BR112018013524-0A BR112018013524B1 (pt) 2015-12-31 2016-12-22 Método de recuperação de memória, aparelho, sistema de computador, dispositivo de armazenamento e meio de armazenamento legível por computador
KR1020207027212A KR102206364B1 (ko) 2015-12-31 2016-12-22 메모리 리클레임 방법 및 장치
US16/023,126 US11023372B2 (en) 2015-12-31 2018-06-29 Application memory reclaim method and apparatus

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201511032537.7 2015-12-31
CN201511032537.7A CN105701025B (zh) 2015-12-31 2015-12-31 一种内存回收方法及装置

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US16/023,126 Continuation US11023372B2 (en) 2015-12-31 2018-06-29 Application memory reclaim method and apparatus

Publications (1)

Publication Number Publication Date
WO2017114288A1 true WO2017114288A1 (zh) 2017-07-06

Family

ID=56226841

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2016/111557 WO2017114288A1 (zh) 2015-12-31 2016-12-22 一种内存回收方法及装置

Country Status (5)

Country Link
US (1) US11023372B2 (zh)
EP (1) EP3388946B1 (zh)
KR (2) KR20180097674A (zh)
CN (1) CN105701025B (zh)
WO (1) WO2017114288A1 (zh)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP3506106A1 (en) * 2017-12-29 2019-07-03 Guangdong Oppo Mobile Telecommunications Corp., Ltd Method for processing application, electronic device, and computer-readable storage medium
WO2019128431A1 (en) * 2017-12-29 2019-07-04 Guangdong Oppo Mobile Telecommunications Corp., Ltd. Memory processing method and device and storage medium
CN110018902A (zh) * 2018-01-10 2019-07-16 广东欧珀移动通信有限公司 内存处理方法和装置、电子设备、计算机可读存储介质
CN110018900A (zh) * 2018-01-10 2019-07-16 广东欧珀移动通信有限公司 内存处理方法和装置、电子设备、计算机可读存储介质

Families Citing this family (57)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105701025B (zh) * 2015-12-31 2019-07-23 华为技术有限公司 一种内存回收方法及装置
CN106201717A (zh) * 2016-07-01 2016-12-07 珠海市魅族科技有限公司 一种管理系统内存的方法及终端
CN107766128B (zh) 2016-08-17 2021-01-29 华为技术有限公司 一种启动应用的方法及装置
CN107220076B (zh) 2016-09-27 2018-10-30 华为技术有限公司 一种内存回收方法及装置
CN107885666B (zh) * 2016-09-28 2021-07-20 华为技术有限公司 一种内存管理方法和装置
CN106484472B (zh) 2016-09-29 2021-06-15 华为技术有限公司 一种内存回收方法及终端
CN106502740B (zh) * 2016-10-31 2019-08-06 北京小米移动软件有限公司 应用安装方法和装置
CN106803860B (zh) * 2017-01-23 2020-12-29 努比亚技术有限公司 一种终端应用的存储处理方法和装置
CN106843450A (zh) * 2017-01-23 2017-06-13 努比亚技术有限公司 一种终端应用的存储处理方法和装置
CN106844032A (zh) * 2017-01-23 2017-06-13 努比亚技术有限公司 一种终端应用的存储处理方法和装置
CN106951327B (zh) * 2017-03-23 2018-11-30 维沃移动通信有限公司 一种应用程序对系统影响的检测方法及移动终端
CN107168791A (zh) * 2017-04-13 2017-09-15 北京安云世纪科技有限公司 亮屏状态下的终端内存优化方法、装置及移动终端
CN107249074A (zh) * 2017-05-16 2017-10-13 努比亚技术有限公司 应用程序快速启动方法、移动终端及计算机可读存储介质
CN109271247A (zh) * 2017-07-12 2019-01-25 珠海市魅族科技有限公司 内存优化方法、装置、计算机装置以及存储介质
CN108228341B (zh) * 2017-08-07 2021-03-02 珠海市魅族科技有限公司 内存回收方法及装置、终端设备及计算机可读存储介质
CN107395744A (zh) * 2017-08-18 2017-11-24 广东欧珀移动通信有限公司 数据同步方法、移动终端以及存储介质
CN108228343B (zh) * 2017-08-21 2020-11-17 珠海市魅族科技有限公司 内存回收方法及装置、计算机装置及计算机可读存储介质
CN107704876B (zh) * 2017-09-30 2020-09-08 Oppo广东移动通信有限公司 应用控制方法、装置、存储介质以及电子设备
CN109600409B (zh) * 2017-09-30 2022-08-19 华为终端有限公司 应用的资源管理方法及终端
CN109669733A (zh) * 2017-10-12 2019-04-23 腾讯科技(深圳)有限公司 一种终端设备内存管理的方法及装置
CN107844342B (zh) * 2017-11-21 2021-07-09 Oppo广东移动通信有限公司 应用程序保活的管控方法、装置及存储介质和移动终端
CN108052388A (zh) * 2017-11-24 2018-05-18 武汉斗鱼网络科技有限公司 一种Android中内存回收方法及装置
CN107807857B (zh) * 2017-11-29 2021-05-21 努比亚技术有限公司 清理运行内存的方法、设备及计算机可存储介质
CN108279975B (zh) * 2017-12-11 2022-01-14 努比亚技术有限公司 一种内存控制方法、移动终端、数据交互方法及服务器
CN110018901B (zh) * 2018-01-10 2021-08-03 Oppo广东移动通信有限公司 内存回收方法、装置、计算机设备和计算机可读存储介质
CN110018899B (zh) * 2018-01-10 2021-09-07 华为技术有限公司 回收内存的方法及装置
CN110032321B (zh) * 2018-01-12 2024-02-20 Oppo广东移动通信有限公司 应用程序处理方法和装置、电子设备、计算机可读存储介质
CN108600840B (zh) * 2018-03-29 2020-07-10 深圳市九洲电器有限公司 机顶盒功耗控制方法及系统
CN108563506A (zh) * 2018-04-11 2018-09-21 青岛海信移动通信技术股份有限公司 移动终端的内存回收方法及装置
CN110377527B (zh) * 2018-04-13 2023-09-22 华为技术有限公司 一种内存管理的方法以及相关设备
CN108932163A (zh) * 2018-06-15 2018-12-04 奇酷互联网络科技(深圳)有限公司 内存管理方法、装置、可读存储介质及终端
KR20200027204A (ko) * 2018-09-04 2020-03-12 삼성전자주식회사 전자장치 및 그 제어방법
CN109857556B (zh) * 2019-01-15 2021-01-08 Oppo广东移动通信有限公司 内存回收方法及装置、存储介质和电子设备
CN110096357A (zh) * 2019-03-29 2019-08-06 北京奇安信科技有限公司 一种分布式系统的内存资源清理方法及装置
CN110083450A (zh) * 2019-04-09 2019-08-02 Oppo广东移动通信有限公司 内存回收方法、装置、电子设备及存储介质
US11327809B2 (en) 2019-06-19 2022-05-10 International Business Machines Corporation Virtual machine memory removal increment selection
CN112328316B (zh) * 2019-08-02 2023-01-24 Tcl科技集团股份有限公司 一种app优化方法、移动终端及存储介质
CN112445606A (zh) * 2019-08-30 2021-03-05 华为技术有限公司 内存回收方法及装置
CN110673955B (zh) * 2019-09-20 2022-07-12 北京字节跳动网络技术有限公司 优化内存的方法、装置、系统、终端和存储介质
CN110727607B (zh) * 2019-09-27 2022-08-12 Oppo广东移动通信有限公司 内存回收方法、装置以及电子设备
CN110727606A (zh) * 2019-09-27 2020-01-24 Oppo(重庆)智能科技有限公司 内存回收方法、装置以及电子设备
CN110795239A (zh) * 2019-10-15 2020-02-14 浙江口碑网络技术有限公司 应用内存泄露的检测方法及装置
CN111045779B (zh) * 2019-11-01 2024-03-01 福建天泉教育科技有限公司 系统内存回收配置方法、存储介质
CN111078406B (zh) * 2019-12-10 2023-01-10 Oppo(重庆)智能科技有限公司 内存管理方法、装置、存储介质及电子设备
CN111258921B (zh) * 2020-01-14 2024-01-26 Oppo广东移动通信有限公司 垃圾内存回收方法及装置、电子设备、存储介质
CN111262737B (zh) * 2020-01-16 2023-11-28 圆山电子科技(深圳)有限公司 一种端口配置管理方法、装置、存储介质及终端
CN113590500A (zh) * 2020-04-30 2021-11-02 华为技术有限公司 一种内存管理方法及终端设备
CN111679914B (zh) * 2020-06-12 2023-06-27 北京字节跳动网络技术有限公司 一种内存管理方法、系统、计算机设备及存储介质
CN111756922A (zh) * 2020-06-15 2020-10-09 北京智明星通科技股份有限公司 一种手机游戏的运行方法、系统及游戏终端
CN111782294A (zh) * 2020-06-28 2020-10-16 珠海豹趣科技有限公司 一种应用程序的运行方法、装置、电子设备及存储介质
KR20220038987A (ko) * 2020-09-21 2022-03-29 삼성전자주식회사 전자장치 및 그 제어방법
CN114443277A (zh) * 2020-10-31 2022-05-06 华为终端有限公司 内存管理方法、装置、电子设备以及计算机可读存储介质
US11442832B2 (en) * 2020-11-24 2022-09-13 Hewlett Packard Enterprise Development Lp Managing synchronized reboot of a system
CN112817759B (zh) * 2021-01-26 2023-06-16 广州欢网科技有限责任公司 Tv视频应用内存占用优化方法、装置和电视终端
CN113886060B (zh) * 2021-05-28 2022-09-23 荣耀终端有限公司 压缩内存的方法和装置
WO2023048454A1 (en) * 2021-09-21 2023-03-30 Samsung Electronics Co., Ltd. Method and electronic device for managing memory
CN117130947A (zh) * 2023-01-31 2023-11-28 荣耀终端有限公司 一种内存管理方法及电子设备

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060074872A1 (en) * 2004-09-30 2006-04-06 International Business Machines Corporation Adaptive database buffer memory management using dynamic SQL statement cache statistics
CN102799471A (zh) * 2012-05-25 2012-11-28 上海斐讯数据通信技术有限公司 操作系统的进程回收方法及系统
CN103324500A (zh) * 2013-05-06 2013-09-25 广州市动景计算机科技有限公司 一种回收内存的方法及装置
CN104111873A (zh) * 2013-04-22 2014-10-22 深圳富泰宏精密工业有限公司 内存释放方法及系统
CN105701025A (zh) * 2015-12-31 2016-06-22 华为技术有限公司 一种内存回收方法及装置

Family Cites Families (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7412694B2 (en) * 2003-09-18 2008-08-12 International Business Machines Corporation Detecting program phases with periodic call-stack sampling during garbage collection
CN1770125A (zh) * 2004-11-04 2006-05-10 华为技术有限公司 一种分配内存的方法
CN101833512A (zh) 2010-04-22 2010-09-15 中兴通讯股份有限公司 一种内存回收方法及其装置
DE112011103979T5 (de) * 2010-11-30 2013-08-29 International Business Machines Corporation Computerprogramm und System für ein Verfahren zur Optimierung der Speicherverwaltung einer auf einer virtuellen Maschine ausgeführten Anwendung
CN103246568A (zh) * 2013-04-16 2013-08-14 深圳桑菲消费通信有限公司 一种通过手机设置应用优先级的方法和装置
US20150095603A1 (en) 2013-09-30 2015-04-02 Samsung Electronics Co., Ltd. Method and device for clearing process in electronic device
CN103544063B (zh) * 2013-09-30 2017-02-08 三星电子(中国)研发中心 应用于安卓平台的进程清除方法和装置
CN104050035B (zh) * 2014-05-14 2018-05-25 小米科技有限责任公司 应用程序的处理方法及装置
US9690685B2 (en) * 2014-05-30 2017-06-27 Apple Inc. Performance management based on resource consumption
US10642663B2 (en) * 2014-09-10 2020-05-05 Oracle International Corporation Coordinated garbage collection in distributed systems
CN104298612A (zh) * 2014-09-30 2015-01-21 北京金山安全软件有限公司 移动终端中清理内存的方法、装置和移动终端
US9940040B2 (en) * 2015-08-26 2018-04-10 Toshiba Memory Corporation Systems, solid-state mass storage devices, and methods for host-assisted garbage collection

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060074872A1 (en) * 2004-09-30 2006-04-06 International Business Machines Corporation Adaptive database buffer memory management using dynamic SQL statement cache statistics
CN102799471A (zh) * 2012-05-25 2012-11-28 上海斐讯数据通信技术有限公司 操作系统的进程回收方法及系统
CN104111873A (zh) * 2013-04-22 2014-10-22 深圳富泰宏精密工业有限公司 内存释放方法及系统
CN103324500A (zh) * 2013-05-06 2013-09-25 广州市动景计算机科技有限公司 一种回收内存的方法及装置
CN105701025A (zh) * 2015-12-31 2016-06-22 华为技术有限公司 一种内存回收方法及装置

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP3506106A1 (en) * 2017-12-29 2019-07-03 Guangdong Oppo Mobile Telecommunications Corp., Ltd Method for processing application, electronic device, and computer-readable storage medium
WO2019128431A1 (en) * 2017-12-29 2019-07-04 Guangdong Oppo Mobile Telecommunications Corp., Ltd. Memory processing method and device and storage medium
US10698837B2 (en) 2017-12-29 2020-06-30 Guangdong Oppo Mobile Telecommunications Corp., Ltd Memory processing method and device and storage medium
US11144477B2 (en) 2017-12-29 2021-10-12 Guangdong Oppo Mobile Telecommunications Corp., Ltd. Method for processing reclaimable memory pages, electronic device, and computer-readable storage medium
CN110018902A (zh) * 2018-01-10 2019-07-16 广东欧珀移动通信有限公司 内存处理方法和装置、电子设备、计算机可读存储介质
CN110018900A (zh) * 2018-01-10 2019-07-16 广东欧珀移动通信有限公司 内存处理方法和装置、电子设备、计算机可读存储介质
CN110018900B (zh) * 2018-01-10 2023-01-24 Oppo广东移动通信有限公司 内存处理方法和装置、电子设备、计算机可读存储介质

Also Published As

Publication number Publication date
KR20200111295A (ko) 2020-09-28
EP3388946A4 (en) 2018-12-26
CN105701025A (zh) 2016-06-22
EP3388946B1 (en) 2022-04-06
EP3388946A1 (en) 2018-10-17
KR102206364B1 (ko) 2021-01-21
BR112018013524A2 (pt) 2018-12-11
US20180307600A1 (en) 2018-10-25
KR20180097674A (ko) 2018-08-31
CN105701025B (zh) 2019-07-23
US11023372B2 (en) 2021-06-01

Similar Documents

Publication Publication Date Title
WO2017114288A1 (zh) 一种内存回收方法及装置
US11099900B2 (en) Memory reclamation method and apparatus
EP3506105B1 (en) Method and device for processing a memory and storage medium
EP3508974B1 (en) Method and terminal for allocating system resource to application
EP3506114B1 (en) Memory processing method and device and storage medium
EP3506106B1 (en) Method for processing application, electronic device, and computer-readable storage medium
US11474831B2 (en) Application startup control method and control device
CN110764906B (zh) 内存回收处理方法、装置、电子设备以及存储介质
CN110018900B (zh) 内存处理方法和装置、电子设备、计算机可读存储介质
CN110018902B (zh) 内存处理方法和装置、电子设备、计算机可读存储介质
US20190205160A1 (en) Application Process Management Method And Terminal Device
WO2019128542A1 (zh) 应用处理方法、电子设备、计算机可读存储介质
CN110955614B (zh) 文件缓存的回收方法、装置、存储介质及终端
CN108038050B (zh) 性能调整方法、装置、存储介质及电子设备
CN113032290A (zh) 闪存配置方法、装置、电子设备和存储介质
CN110007968B (zh) 信息处理方法、装置、计算机设备和计算机可读存储介质
BR112018013524B1 (pt) Método de recuperação de memória, aparelho, sistema de computador, dispositivo de armazenamento e meio de armazenamento legível por computador

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: 16881077

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

REG Reference to national code

Ref country code: BR

Ref legal event code: B01A

Ref document number: 112018013524

Country of ref document: BR

WWE Wipo information: entry into national phase

Ref document number: 2016881077

Country of ref document: EP

ENP Entry into the national phase

Ref document number: 20187020861

Country of ref document: KR

Kind code of ref document: A

WWE Wipo information: entry into national phase

Ref document number: 1020187020861

Country of ref document: KR

ENP Entry into the national phase

Ref document number: 2016881077

Country of ref document: EP

Effective date: 20180711

ENP Entry into the national phase

Ref document number: 112018013524

Country of ref document: BR

Kind code of ref document: A2

Effective date: 20180629