WO2019137258A1 - Memory processing method, electronic device and computer readable storage medium - Google Patents
Memory processing method, electronic device and computer readable storage medium Download PDFInfo
- Publication number
- WO2019137258A1 WO2019137258A1 PCT/CN2018/125326 CN2018125326W WO2019137258A1 WO 2019137258 A1 WO2019137258 A1 WO 2019137258A1 CN 2018125326 W CN2018125326 W CN 2018125326W WO 2019137258 A1 WO2019137258 A1 WO 2019137258A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- application
- memory
- memory page
- duration
- idle
- Prior art date
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F12/00—Accessing, addressing or allocating within memory systems or architectures
- G06F12/02—Addressing or allocation; Relocation
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F12/00—Accessing, addressing or allocating within memory systems or architectures
- G06F12/02—Addressing or allocation; Relocation
- G06F12/0223—User address space allocation, e.g. contiguous or non contiguous base addressing
- G06F12/023—Free address space management
- G06F12/0253—Garbage collection, i.e. reclamation of unreferenced memory
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/48—Program initiating; Program switching, e.g. by interrupt
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/48—Program initiating; Program switching, e.g. by interrupt
- G06F9/4806—Task transfer initiation or dispatching
- G06F9/4843—Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
- G06F9/485—Task life-cycle, e.g. stopping, restarting, resuming execution
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/48—Program initiating; Program switching, e.g. by interrupt
- G06F9/4806—Task transfer initiation or dispatching
- G06F9/4843—Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
- G06F9/4881—Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/50—Allocation of resources, e.g. of the central processing unit [CPU]
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/50—Allocation of resources, e.g. of the central processing unit [CPU]
- G06F9/5005—Allocation of resources, e.g. of the central processing unit [CPU] to service a request
- G06F9/5011—Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
- G06F9/5016—Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals the resource being the memory
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/50—Allocation of resources, e.g. of the central processing unit [CPU]
- G06F9/5005—Allocation of resources, e.g. of the central processing unit [CPU] to service a request
- G06F9/5011—Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
- G06F9/5022—Mechanisms to release resources
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/50—Allocation of resources, e.g. of the central processing unit [CPU]
- G06F9/5005—Allocation of resources, e.g. of the central processing unit [CPU] to service a request
- G06F9/5027—Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
- G06F9/5038—Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals considering the execution order of a plurality of tasks, e.g. taking priority or time dependency constraints into consideration
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F2209/00—Indexing scheme relating to G06F9/00
- G06F2209/48—Indexing scheme relating to G06F9/48
- G06F2209/482—Application
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F2209/00—Indexing scheme relating to G06F9/00
- G06F2209/50—Indexing scheme relating to G06F9/50
- G06F2209/5021—Priority
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F2209/00—Indexing scheme relating to G06F9/00
- G06F2209/50—Indexing scheme relating to G06F9/50
- G06F2209/504—Resource capping
Definitions
- the present application relates to the field of data processing, and in particular, to a memory processing method, an electronic device, and a computer readable storage medium.
- an in-memory processing method and apparatus an electronic device, and a computer-readable storage medium are provided, which can reduce the impact on the operation of an application of a reclaimed memory while improving the operational efficiency of the foreground application.
- An in-memory processing method includes: acquiring a reclaimable memory page occupied by an application to be processed; obtaining a dependency ratio of the to-be-processed application to be relied upon by the foreground application; and acquiring the to-be-processed application for each of the retrievable memory pages
- the idle time length is determined according to the idle duration of the each recyclable memory page and the dependency ratio; and the memory page whose idle duration exceeds the duration threshold is selected from the reclaimable memory page for recycling.
- An electronic device includes a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor performs the following operations:
- a memory page whose idle time exceeds the duration threshold is selected from the recyclable memory page for recycling.
- a computer readable storage medium having stored thereon a computer program, the computer program being executed by a processor to:
- a memory page whose idle time exceeds the duration threshold is selected from the recyclable memory page for recycling.
- the memory processing method, the electronic device, and the computer readable storage medium provided by the embodiment of the present application obtain the recyclable memory page occupied by the application to be processed and the idle duration thereof, and obtain the dependency ratio of the to-be-processed application that is dependent on the foreground application, and then The duration threshold is determined according to the idle duration and the dependency ratio, and the memory page whose idle duration exceeds the duration threshold is recovered, because the recovered object is a reclaimable memory page, and not all the recyclable memory pages are necessarily recovered.
- the memory page whose idle time exceeds the corresponding duration threshold is selected for recycling, thereby further reducing the operational impact of the application to be processed and the foreground application.
- the reclaimed memory pages can be released for use by other applications, ensuring minimal negative impact on each application as the entire system memory becomes larger, improving memory usage efficiency, and maintaining the recycling of the application memory to be processed. Balance between operations.
- FIG. 1 is a schematic diagram showing the internal structure of an electronic device in an embodiment.
- FIG. 2 is a partial block diagram of a system in an electronic device in an embodiment.
- FIG. 3 is a flow chart of a memory processing method in one embodiment.
- FIG. 4 is a flow diagram of determining a duration threshold based on the idle duration and dependency ratio of each recyclable memory page in one embodiment.
- Figure 5A is a schematic diagram of a recovery ratio curve for an unrelated application in one embodiment.
- Figure 5B is a schematic diagram of the recovery ratio curve for a linear application in one embodiment.
- Figure 5C is a schematic diagram of a recovery ratio curve for a non-linear application in one embodiment.
- FIG. 6 is a flow chart of a memory processing method in another embodiment.
- Figure 7 is a block diagram showing the structure of an internal memory processing device in an embodiment.
- Figure 8 is a block diagram showing a portion of the structure of a handset in an embodiment.
- an internal structure diagram of an electronic device includes a processor, memory, and display screen connected by a system bus.
- the processor is used to provide computing and control capabilities to support the operation of the entire electronic device.
- the memory is used to store data, programs, and/or instruction codes, etc., and the memory stores at least one computer program, which can be executed by the processor to implement the memory processing method applicable to the electronic device provided in the embodiments of the present application.
- the memory may include a non-volatile storage medium such as a magnetic disk, an optical disk, a read-only memory (ROM), or a random storage memory (Random-Access-Memory, RAM).
- the memory includes a non-volatile storage medium and an internal memory.
- Non-volatile storage media stores operating systems, databases, and computer programs.
- the database stores data related to implementing an in-memory processing method provided by the above various embodiments, such as storing a name of each application and a memory page allocated for each application.
- the computer program can be executed by a processor for implementing an in-memory processing method provided by various embodiments of the present application.
- the internal memory provides a cached operating environment for operating systems, databases, and computer programs in non-volatile storage media.
- the display screen can be a touch screen, such as a capacitive screen or an electronic screen, for displaying interface display information of the foreground application, and can also be used for detecting a touch operation acting on the display screen, and generating corresponding instructions, such as performing front and back applications. Switch instructions, etc.
- the structure shown in FIG. 1 is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the electronic device to which the solution of the present application is applied.
- the specific electronic device may be It includes more or fewer components than those shown in the figures, or some components are combined, or have different component arrangements.
- the electronic device further includes a network interface connected through a system bus, and the network interface may be an Ethernet card or a wireless network card, etc., for communicating with an external electronic device, for example, for communicating with a server.
- the network interface may be an Ethernet card or a wireless network card, etc.
- the external electronic device for example, for communicating with a server.
- a partial architectural diagram of an electronic device is provided.
- the architecture of the electronic device includes a JAVA spatial layer 210, a local framework layer 220, and a kernel space layer 230.
- the JAVA spatial layer 210 may include a freeze management application 212.
- the electronic device may implement a freeze policy for each application through the freeze management application 212, and perform freezing and thawing management operations on the related applications of the background power consumption.
- the resource priority and restriction management module 222 and the platform freeze management module 224 are included in the local framework layer 220.
- the electronic device can maintain different applications in different priorities and different resource organizations through the resource priority and limit management module 222, and adjust the resource group of the application according to the requirements of the upper layer to achieve optimized performance and save power. effect.
- the electronic device can allocate the tasks that can be frozen in the background to the frozen layer corresponding to the preset different levels according to the length of the entering freeze time through the platform freeze management module 224.
- the frozen layer can include three, respectively: the CPU Limit sleep mode, CPU freeze sleep mode, process deep freeze mode.
- the CPU restricts the sleep mode to limit the CPU resources occupied by the related processes, so that the related processes occupy less CPU resources, and the free CPU resources are tilted to other unfrozen processes, thereby limiting the occupation of CPU resources.
- the kernel space layer 230 includes a UID management module 231, a Cgroup module 232, a Binder management module 233, a process memory recovery module 234, and a freeze timeout exit module 235.
- the UID management module 231 is configured to implement an application-based User Identifier (UID) to manage resources of a third-party application or freeze. Compared with the Process Identifier (PID) for process management and control, it is easier to uniformly manage the resources of a user's application through UID.
- the Cgroup module 232 is used to provide a complete set of Central Processing Unit (CPU), CPUSET, memory, input/output (I/O), and Net related resource restriction mechanisms.
- the Binder management module 233 is used to implement the priority control of the background binder communication.
- the interface module of the local framework layer 220 includes a binder interface developed to the upper layer, and the upper layer framework or application sends a resource restriction or frozen instruction to the resource priority and restriction management module 222 and the platform freeze management module 224 through the provided binder interface.
- the process memory recovery module 234 is configured to implement the process deep freeze mode, so that when a third-party application is in a frozen state for a long time, the file area of the process is mainly released, thereby saving the memory module and speeding up the application next time. The speed at startup.
- the freeze timeout exit module 235 is configured to resolve an exception generated by the freeze timeout scenario.
- an in-memory processing method is provided. This embodiment is applied to the electronic device shown in FIG. 1 as an example for description.
- the method includes:
- the pending application indicates that an application that needs to recycle memory is needed.
- the memory also known as random access memory, RAM
- the background application is an application running in the background; correspondingly, the application running in the foreground is the foreground application.
- the operation of an application (APP) is usually reflected by the operation of multiple related processes.
- a process is a running activity of a program on a computer on a data set. It is the basic unit for resource allocation and scheduling, and is the basis of the operating system structure.
- the process involved in the foreground application runtime is the foreground process
- the process involved in the background application runtime is the background process.
- the application needs to occupy memory space in the running state to store data during the running process.
- the memory space occupied by different applications in different running states may not be the same.
- the memory page is the unit that the operating system manages the memory.
- the memory size of the memory page set by different electronic devices is not necessarily the same. For example, the memory space in the electronic device is divided into 100000 memory pages, and the memory page occupied by the to-be-processed application is the memory page 100 to the memory page 200, and the memory page 130 to the memory page 200 are recyclable memory pages.
- the electronic device may pre-record all memory pages occupied by the application to be processed and obtain retrievable memory pages from the all memory pages.
- Recyclable memory pages represent memory pages that can be recycled and that have no impact on the operation of the application and other applications after they are recycled.
- the electronic device can record, among the memory pages, which memory pages are recyclable memory pages, which memory pages are non-recyclable memory pages, and obtain recyclable memory pages occupied by the to-be-processed application according to the record information. .
- Operation 304 Obtain a proportion of dependencies that the to-be-processed application is dependent on by the foreground application.
- a dependency representation indicates that an application needs to utilize data from one or more applications in order to successfully implement the relationship to the execution of that application.
- A depends on application B, or application B is dependent on application A. Application A needs to utilize the data of application B to implement the execution of application A.
- application A is the dependent application. It can be understood that the dependent application may also be the first application, and the second application may be a background application.
- the electronic device can detect from the background application collection to query whether there is a background application that is dependent on the foreground application.
- the dependency ratio reflects the degree of dependency of the application to which the dependent application is dependent. The greater the degree of dependency, the greater the dependency ratio.
- the electronic device can record the proportion of each application's dependence on other applications and read the proportion of dependencies that the pending application is applied by the foreground among the many dependent ratios recorded.
- the dependency ratio is zero when the pending application is not dependent on the foreground application.
- Operation 306 Acquire an idle duration of the to-be-processed application for each recyclable memory page.
- the idle duration of the memory page indicates that after the system allocates a memory page for the pending application, the data stored in the memory page is not used after being used most recently.
- the duration of the state The electronic device updates the idle time of each memory page in real time according to the data usage of each memory page, and obtains the free record of each recyclable memory page of the latest record when the memory page occupied by the application to be processed is ready for recycling. duration.
- the allocation, reclaim, release, etc. of the memory page is initiated recently, or the usage of the cache in the processor is queried, it is determined that the data of the corresponding memory page is used. And will generate the data usage time of the most recent time on the memory page of the system time in the corresponding situation. The difference between the current time and the latest time is the idle time of the corresponding memory page.
- the electronic device can create a corresponding timestamp for each memory page that records the most recent usage time of the data in the corresponding memory page.
- the activity level of the corresponding memory page may be updated, and the update time is recorded in the timestamp.
- the system periodically checks the usage of the processor cache, determines that the data in the current cache is the currently used data, and updates the timestamp of the memory page involved, and records the update time in the timestamp.
- the latest updated update time can be replaced with the last update time to reduce the resource consumption of the update time.
- Operation 308 determining a duration threshold based on the idle duration and the dependency ratio of each recyclable memory page.
- the duration threshold represents the critical value used to decide whether to recycle the recyclable memory page.
- the duration threshold can be determined according to the idle duration of each recyclable memory page and the proportion of dependencies of the foreground application to be processed. The idle duration is different or the dependency ratio is different, and the determined duration threshold is not necessarily the same.
- the electronic device may calculate a weighted average of the idle duration of all recyclable memory pages, or may also select an idle duration from the idle duration of all of the recyclable memory pages, the selected idle duration or calculation
- the weighted average value is used as the reference duration, and the correspondence between the different reference durations, the dependency ratios, and the duration thresholds is set, and the duration threshold corresponding to the reference duration and the dependency ratio is obtained according to the correspondence.
- the idle duration of all the recyclable memory pages occupied by the to-be-processed application the idle duration that is close to the median or is sorted at a certain location may be selected, and the selected idle duration is used as the reference duration.
- the duration threshold is positively correlated with the dependency ratio and the reference duration. The larger the reference duration, and/or the greater the dependency ratio, the larger the corresponding duration threshold.
- a memory page whose idle time exceeds a duration threshold is selected from the reclaimable memory page for recycling.
- the electronic device may select, from the recyclable memory page occupied by the to-be-processed application, a memory page whose idle time exceeds the duration threshold according to the determined duration threshold to release the recyclable memory page of the duration threshold for the foreground. Used by applications or other applications to improve the overall processing efficiency of the system.
- the electronic device may use the process memory recovery module 234 to recover the memory page from the recyclable memory page according to the duration threshold, release the memory that is not used for a long time, improve the memory usage efficiency, and enable the memory page to be reclaimed. After that, the impact on the pending application is also small.
- the stored data in the recovered memory may be stored in a non-volatile storage medium or other external storage medium of the electronic device, such as a flash memory that can store the stored data in the recovered memory to the electronic device. Or a built-in non-volatile storage medium such as a hard disk.
- the recyclable memory page has 100 pages, and the corresponding idle time is between 5 seconds and 15 minutes respectively.
- the determined duration threshold is 5 minutes
- the idle time can be recovered from the 100 pages of the memory page.
- the 5 minute memory page releases the reclaimed memory page, so that the free memory page of the electronic device is correspondingly increased, and can be used by the foreground application or other background applications.
- the memory processing method is configured to obtain a reclaimable memory page occupied by the application to be processed and an idle duration thereof, and obtain a dependency ratio of the to-be-processed application that is dependent on the foreground application, and then determine a duration threshold according to the idle duration and the dependency ratio, and Reclaiming a memory page whose idle time exceeds the duration threshold, because the object being reclaimed is a reclaimable memory page, and it is not necessarily all the recyclable memory pages are reclaimed, but the idle time of each recyclable memory page and
- the pending application depends on the proportion of dependencies that the foreground application depends on, and the memory pages whose idle time exceeds the corresponding duration threshold are selected for recycling, thereby further reducing the operational impact of the application to be processed and the foreground application, and the reclaimed memory pages can be released for use by other applications. To ensure that the negative impact of each application is minimized, the memory usage efficiency is improved, and the balance between the recycling and operation of the application memory to be processed is maintained.
- operation 304 includes detecting whether data stored in each recyclable memory page is dependent on the foreground application; determining, based on the detection result, a dependency ratio of the application to be processed that is dependent on the foreground application.
- the detection results include that the memory page is not dependent on the foreground application or is dependent on the foreground application.
- the electronic device may detect, for each recyclable memory page allocated for the application to be processed, whether the data stored in the corresponding memory page is used by the foreground application within a preset time period, and if yes, determine that the memory page is used by the foreground The application depends.
- the foreground application it is detected whether it uses data stored in the recyclable memory page allocated for the application to be processed within a preset time period, and determines that the used memory page is dependent on the foreground application.
- the preset time period may be a preset time period of the current time, that is, the latest time period, and the duration of the latest time period is a preset duration, and the preset duration may be any set according to an empirical value.
- the appropriate length of time is, for example, 10 minutes, or half an hour.
- the preset time period may also be a time period in which the foreground application is currently running in the foreground. For example, if the foreground application is running in the foreground from 10:35:20 to the current time, the current time period is 10:35:20 to the current time.
- the dependency ratio may be the ratio of the total number of dependencies of the reclaimable memory pages on which the foreground application depends and the total number of memory pages received by the client.
- operation 310 includes selecting, from the reclaimable memory page, a memory page that has an idle duration that exceeds a duration threshold and is not dependent on the foreground application for recycling.
- the electronic device can further eliminate the memory page that is depended by the foreground application, and select a memory page whose idle time exceeds the duration threshold from the reclaimable memory page that is not dependent on the foreground application, and collect the selected memory page.
- the memory page that is relied upon by the foreground application is prevented from being recycled and affects the foreground application.
- operation 306 includes: obtaining an update time of a timestamp record for each recyclable memory page, and calculating an idle duration corresponding to the recyclable memory page based on the update time.
- the electronic device can create a timestamp for each memory page by using the resource priority and limit management module 222 described above, the timestamp is used to record the corresponding update time, and the update time indicates the time when the corresponding memory page is recently used.
- the update time of the timestamp record can be updated.
- the allocation, reclaim, release, etc. of the memory page is initiated, or when the usage of the cache in the processor is queried, it is determined that the data of the corresponding memory page is used, and The system time in the corresponding situation is generated as the update time.
- the idle time of the corresponding memory page can be calculated according to the update time recorded by the time stamp and the current system time. The difference between the current time and the most recent time is the idle time for the corresponding memory page.
- the update time of each recyclable memory page is recorded, and the idle time is determined according to the update time, which can effectively be compatible with different processors, and improves the versatility of memory recycling.
- operation 306 includes: obtaining an update time for each recyclable memory page recorded by the most recently unused LRU management unit, and calculating an idle duration corresponding to the recyclable memory page based on the update time.
- LRU Least Recently Used
- the LRU management unit can record each memory address and the update time of the memory address.
- the processor stores the corresponding memory address and update time in the LRU management unit.
- the memory recovery mechanism is started, the memory page corresponding to each memory address can be obtained according to the correspondence between the memory address and the memory page, and the update time of the corresponding memory page can be read from the LRU management unit. Wherein, whenever the allocation, reclaim, release, etc. of the memory page is initiated, or when the usage of the cache in the processor is queried, it is determined that the data of the corresponding memory page is used, and The system time in the corresponding situation is generated as the update time.
- an interrupt information may be generated and the operating system may be notified, and the operating system may clear the data after reading the data of the LRU management unit, so that the LRU management unit can restart the work, and store each memory address and its Corresponding update time and other information.
- the usage of each memory can be accurately tracked, the accuracy of detecting the update time of the memory page is improved, and the convenience of memory recovery is also improved.
- operation 308 includes: calculating an average idle duration of the to-be-processed application for the reclaimable memory page according to the idle duration of each recyclable memory page; determining a duration threshold based on the average idle duration and the dependency ratio.
- the average idle duration is the average of the elapsed duration of each memory page in the reclaimable memory page occupied by the application to be processed.
- the electronic device can call the corresponding calculation unit to calculate according to the occupied duration of each memory page to calculate the average idle duration.
- the calculated average idle duration is used as the reference duration, and the duration threshold is determined according to the reference duration and the dependency ratio.
- the calculation efficiency of the duration threshold can be improved, and the calculation is simple, thereby correspondingly improving the efficiency of memory recovery.
- operation 308 includes:
- the secondary startup time is the length of time that the reclaimed memory page occupied by the application to be processed is reclaimed after being recycled.
- the corresponding relationship indicates the corresponding secondary startup time after reclaiming different proportions of recyclable memory in the memory occupied by the application.
- the correspondence may be a comparison table between the corresponding recovery ratio and the secondary startup time, or a recovery ratio curve.
- the curve is the corresponding secondary start time under different recovery ratios. According to the correspondence, the appropriate recycling ratio is selected with reference to different secondary startup durations as the recovery ratio of the recyclable memory pages occupied by the application.
- Operation 404 determining the number of reclaimed memory pages according to a correspondence between the dependency ratio and the reclaimable memory page and the recycling ratio and the secondary startup duration.
- the electronic device can set a corresponding startup time threshold, and when the secondary startup time reaches the startup time threshold, the corresponding ratio is used as a reference ratio to the recyclable memory page.
- the startup duration threshold may be a preset experience value, and the startup duration thresholds of different applications may not be the same.
- the corresponding startup duration threshold may be determined according to the normal startup duration of the corresponding application, and the normal startup duration may be 1.5 times or 2 times.
- the duration is used as the threshold for the start time.
- the reference scale represents a reference to the memory page recycling ratio. Based on the determined reference ratio, combined with the dependency ratio and the total number of reclaimable memory pages, determine the amount of recycling for recyclable memory pages.
- the amount of recycling is the amount of recycling to the memory page, which is a positive integer.
- the correspondence between the recovery ratio and the secondary startup duration is not necessarily the same for applications of different application types.
- the application type is a type set according to the operational impact of the application to be processed after the memory is reclaimed.
- Application types include irrelevant classes, linear classes, and nonlinear classes.
- the irrelevant class indicates that after the reclaimable memory of the application to be processed is recycled, no matter how much it is recycled, it has no significant effect on the corresponding application.
- the linear class indicates that as the recovery ratio of recyclable memory increases, the secondary startup time of the corresponding application also increases, and the relationship between the secondary startup time and the recovery ratio is linear or nearly linear.
- Non-linear classes represent other types that are neither extraneous nor nonlinear.
- the ratio of the second startup time corresponding to different recovery ratios is smaller than the preset ratio range.
- the near linearity indicates that the difference between the second recovery time and the second startup time when the different recovery ratios are fitted according to the corresponding approximate slope does not exceed the error within the preset range.
- the recovery ratio curves of the applications of the irrelevant class, the linear class, and the nonlinear class in one embodiment.
- the abscissa in the recovery ratio curve represents the recovery ratio
- the ordinate represents the secondary startup time in the corresponding recovery ratio.
- the irrelevant class recovery ratio curve reflects that the corresponding application in the recyclable memory page after the recovery according to different recycling ratios, the corresponding secondary startup time has no change or little change.
- the recovery ratio curve of the linear type has no change or small change in the corresponding recovery ratio
- the recovery ratio curve of the nonlinear type has a large slope, and the slope of some places is relatively small.
- the recovery ratio corresponding to the minimum slope can be selected as the recovery ratio of the recyclable memory page, that is, as the above reference ratio.
- the electronic device reclaims the corresponding secondary startup time according to different recycling ratios, sets the application type to which the application belongs, and sets a reference ratio corresponding to the application type.
- the corresponding amount of recycling is determined based on the recyclable memory page, the dependency ratio, and the reference ratio. Further, according to the reference ratio and the dependency ratio, the recycling ratio of the recyclable memory page occupied by the application to be processed may be determined, and the determined recycling ratio may be multiplied by the total number of recyclable memory pages, and the calculated product is used as the recycling quantity.
- an integer approximate to the product may be selected.
- the nearest integer may be determined as a number of rounds according to rounding, or the corresponding method may be determined according to a truncation method or a carry method.
- An integer is used as the recycle quantity.
- the example of determining the recoverable quantity by rounding is taken as an example. For example, when there are 100 pages of recyclable memory pages, if the recycling ratio is 30.5% and the product is 30.5, 31 pages can be recovered from the 100-page recyclable memory page. If the recycling ratio is 21.2%, then Recycling 21 pages.
- the idle time length of the Kth largest is selected from the idle time of each recyclable memory page according to the quantity of the collection, and the selected idle time length is used as the duration threshold.
- the number of idle periods exceeding the Kth largest is the number of collections
- K is a natural number that does not exceed the number of collections.
- the electronic device can sort the idle time of each recyclable memory page from large to small, and select the idle time of the Kth largest, and use the idle duration as the duration threshold.
- the number of idle periods exceeding the Kth largest is the amount of the collection. Understandably, K is a natural number that does not exceed the amount recovered.
- the total number of recyclable memory pages is 100.
- the 51st free idle duration can be selected from the idle duration of the 100 recyclable memory pages.
- the idle duration is used as the duration threshold, and 50 reclaimed memory pages whose idle duration exceeds the 51st largest idle duration are selected for recovery.
- operation 302 includes querying all memory pages of memory occupied by the application to be processed; and obtaining recyclable memory pages from all memory pages.
- the electronic device can record the memory pages of the memory occupied by different applications in real time, and further record in real time whether the memory pages can be recycled for each occupied memory page. For example, when there is data in a certain memory page being used by another application or the application to be processed, it is determined that the memory page is a non-recyclable memory page, and when the data recorded in the occupied memory page is in no application. When the usage state, or the duration of the non-application use state exceeds the preset duration, the memory page is determined to be a reclaimable memory page.
- all the memory pages occupied by the occupied information can be queried from the pre-recorded information, and according to the recorded usage status of each memory page, it is determined whether it is a recyclable memory page, and then all the recyclable memory is obtained. page.
- querying all memory pages of the memory occupied by the application to be processed includes: traversing a memory mapped file of the to-be-processed application; and querying all memory pages occupied by the to-be-processed application through the memory mapped file.
- Memory-Mapped Files are mappings from one file to one memory.
- the electronic device establishes a corresponding memory mapping file for the to-be-processed application, and the memory mapping file stores a memory page occupied by the corresponding application, by traversing the memory mapping file corresponding to the to-be-processed application, and traversing from each
- the memory map file is used to read the memory page occupied by the to-be-processed application, so that all the memory pages occupied by the to-be-processed application can be obtained, and the query efficiency and the comprehensiveness of the query of the memory page occupied by the application to be processed are improved.
- the reclaimable memory page is obtained from all of the memory pages, including: removing the memory page carrying the occupied mark from all the memory pages; and obtaining the recyclable memory page from the rejected memory page.
- the electronic device can detect whether each of the queried memory pages carries an occupation mark or is occupied by multiple applications, for all the memory pages occupied by the queried application.
- the occupancy mark indicates that the data stored in the corresponding memory page is being used by the application to be processed, or the data therein is indispensable data in the process of the pending application being kept in normal operation, and when the data is deleted, The pending application may not be able to run normally, or it may need to repeatedly occupy a new memory page to store corresponding data.
- the electronic device may set an occupancy flag on the memory page storing the data to indicate the corresponding Memory pages cannot be recycled.
- the memory page occupied by the application to be processed, the data stored therein may also be used by other applications, that is, multiple applications are using the data in the memory page, and the memory page may also be set to occupy the mark. , so that the electronic device also culls it to indicate that it is not recycled from the memory page.
- the reserved memory page is a recyclable memory page from which the electronic device can perform memory reclamation.
- the electronic device may invoke the resource priority and restriction management module 222 as shown in FIG. 2 to traverse the memory mapped file of the to-be-processed application; query all memory pages occupied by the to-be-processed application through the memory-mapped file, and
- the resource priority and limit management module 222 detects whether each memory page is a reclaimable memory page, sets a corresponding occupation mark for the non-recyclable memory page, and records whether each memory page is occupied by multiple applications, and queries from the query. All memory pages are excluded from carrying memory tags and/or memory pages occupied by multiple applications; retrievable memory pages are obtained from the rejected memory pages.
- the method further includes: determining that the to-be-processed application is dependent on the foreground application when there is a communication mechanism or a synchronization mechanism between the to-be-processed application and the foreground application.
- socket communication when there is socket communication, binder communication, memory sharing or lock waiting between the to-be-processed application and the foreground application, it is determined that there is a communication mechanism between the background process and the foreground application.
- the electronic device can set a detection mechanism for the Binder communication between the foreground application and the background process in the Binder driver, and call the detection mechanism set in the Binder driver to detect the background process that the Binder communication exists with the foreground application, and the detection will be detected.
- the background process is determined to be a background process that is dependent on the foreground application.
- the electronic device can detect individual lock resources, including thread locks, file handles, signals, and the like. For each lock resource, it can be detected whether a lock wait occurs, that is, the lock resource waits. When it is detected that a lock wait is generated, it may be further detected whether the behavior of the occurrence of the wait occurs on the foreground application. If so, all the background processes waiting for the lock resource are traversed, and the detected background processes waiting on the lock resource are all determined to be background processes that are depended by the foreground application.
- the electronic device may set a lock resource monitoring module and a priority adjustment module in a kernel space of the operating system, and embed the lock resource monitoring module into the kernel's native waiting interface.
- the lock resource monitoring module detecting thread locks, file handles, signals, etc. lock various lock resources, whether a wait occurs, whether the waiting behavior occurs in the foreground application, and if it occurs on the foreground task, it will detect The message is sent to the priority adjustment module.
- the priority adjustment Through the priority adjustment, all the background threads waiting for the lock resource are traversed, and these background processes are determined as the background processes that are depended by the foreground application.
- the to-be-processed application with the synchronization mechanism is a background process that is dependent on the foreground application.
- the electronic device can also detect the background process in the background process set by calling the futex system call, whether there is a background process having a synchronization mechanism with the foreground application, and determine the background process with the synchronization mechanism as the background process that is depended by the foreground application.
- the user mode synchronization mechanism can be implemented by calling the futex system call.
- the user state refers to the non-privileged state.
- Synchronization mechanisms include semaphores, mutex locks, and more.
- the detected background process having the communication mechanism and/or the synchronization mechanism with the foreground application is determined to be a background process dependent on the foreground application, which can be improved.
- the efficiency of detection of pending applications that are relied upon by the foreground application is determined to be a background process dependent on the foreground application, which can be improved.
- FIG. 6 another memory processing method is provided, the method comprising:
- Operation 602 traverse the memory mapped file of the to-be-processed application; query all memory pages occupied by the to-be-processed application through the memory-mapped file.
- the electronic device may trigger a memory reclamation mechanism when detecting that the memory usage of the system exceeds a preset ratio or receiving a memory reclamation instruction triggered by a user operation, and from all running applications. Identify the application that needs to be recycled, and the determined application is the pending application.
- the electronic device may trigger a memory reclamation mechanism for the application after detecting that an application is switched from the foreground to the background and the platform freeze management module 224 sets the application to the process deep freeze mode.
- the electronic device can traverse the memory mapping file of the to-be-processed application by using the resource priority and restriction management module 222, and query the memory page occupied by the application to be processed from each memory mapping file traversed, so that the memory can be queried. All memory pages occupied by the pending application.
- a second traversal can be performed, and the second traversal is used to detect whether each of the queried memory pages is a recyclable memory page, and when the memory page carrying the occupied mark is detected, the memory is determined.
- the page is a non-recyclable memory page, and the memory page is culled.
- the memory page obtained after the second traversal is a recyclable memory page, and the electronic device can select a memory page from all the recyclable memory pages for recycling. Through the second traversal, the comprehensiveness of the detection of recyclable memory pages can be improved.
- Operation 606 Detect whether data stored in each recyclable memory page is dependent on the foreground application; and determine, according to the detection result, a proportion of dependencies that the to-be-processed application is dependent on by the foreground application.
- the to-be-processed application when there is a communication mechanism or a synchronization mechanism between the to-be-processed application and the foreground application, it is determined that the to-be-processed application is dependent on the foreground application, and detecting which reclaimable memory pages are specifically dependent on the foreground application, according to the detection
- the result determines the dependency ratio.
- the detection results include that the memory page is not dependent on the foreground application or is dependent on the foreground application.
- the dependency ratio can be the ratio of the total number of dependencies of the reclaimable memory pages that the foreground application depends on to the total number of pages that the client receives. When the pending application is not dependent on the foreground application, the dependency ratio is zero.
- a corresponding dependency identifier may be set for the memory page, so that according to the dependency identifier, it is known which specific applications the corresponding memory page is dependent on. Further, according to whether each recyclable memory page is set with a corresponding dependency identifier, and whether the dependency identifier is represented by the foreground application, the proportion of dependencies that the to-be-processed application is dependent on by the foreground application can be calculated.
- the validity of the corresponding dependency identifier may be determined according to the preset time period, and when the preset dependency period is within the corresponding preset time period, the set dependency identifier is kept valid, when the preset time period is outside, The set dependency ID can be canceled. By setting the dependency identifier, the efficiency of calculating the dependency ratio can be improved.
- Operation 608 obtaining the idle duration of the unprocessable memory page of the to-be-processed application.
- the update time of the timestamp record of each recyclable memory page may be obtained, and the idle duration of the corresponding recyclable memory page is calculated according to the update time.
- the update time of each recyclable memory page recorded by the most recently unused LRU management unit may also be obtained, and the idle duration corresponding to the recyclable memory page is calculated according to the update time.
- Operation 610 determining a duration threshold based on the idle duration and the dependency ratio of each recyclable memory page.
- the average idle duration of the to-be-processed application for the reclaimable memory page is calculated according to the idle duration of each recyclable memory page; and the duration threshold is determined according to the average idle duration and the dependency ratio.
- the correspondence between the recovery ratio corresponding to the application to be processed and the secondary startup duration may be obtained, and the amount of recovery of the memory page may be determined according to the dependency ratio and the correspondence relationship;
- the idle duration of the Kth largest is selected from the idle duration of the recyclable memory page, and the selected idle duration is taken as the duration threshold;
- the number of idle durations exceeding the Kth largest is the recovered quantity, and K is the natural number that does not exceed the collected quantity.
- a memory page whose idle time exceeds a duration threshold and is not dependent on the foreground application is selected from the reclaimable memory page for recycling.
- the Kth largest idle time may be selected from the memory pages not depended by the foreground application as the duration threshold.
- the number of idle times exceeding the Kth largest is the number of recycles. That is to say, only the idle time is sorted and selected in the memory pages that are not dependent on the foreground application. The impact on the foreground application can be further reduced by reclaiming memory pages that are not dependent on the foreground application.
- an in-memory processing device includes a memory page acquisition module 702, a dependency determination module 704, a duration determination module 706, and a memory recovery module 708.
- the memory page obtaining module 702 is configured to obtain a reclaimable memory page occupied by the to-be-processed application;
- the dependency determining module 704 is configured to obtain a dependency ratio of the to-be-processed application that is dependent on the foreground application;
- the duration determining module 706 is configured to obtain the to-be-processed application pair.
- the idle time of each recyclable memory page; the duration threshold is determined according to the idle duration and the dependency ratio of each recyclable memory page; the memory reclamation module 708 is configured to select a memory page whose idle time exceeds the duration threshold from the reclaimable memory page for recycling .
- the memory page obtaining module 702 is further configured to query all memory pages of the memory occupied by the application to be processed; the memory page carrying the occupied mark is removed from all the memory pages; and the reclaimable memory page is retrievable Memory page.
- the memory page obtaining module 702 is further configured to traverse a memory mapped file of the to-be-processed application; and query all memory pages occupied by the to-be-processed application through the memory mapped file.
- the dependency determination module 704 is further configured to detect whether data stored in each recyclable memory page is dependent on the foreground application; determining, according to the detection result, a dependency ratio of the to-be-processed application being dependent on the foreground application; the detection result includes the memory page Not dependent on the foreground application or dependent on the foreground application.
- the memory reclamation module 708 is configured to select, from the reclaimable memory page, a memory page whose idle time exceeds a duration threshold and is not dependent on the foreground application for recycling.
- the duration determining module 706 is further configured to obtain an update time of the time stamp record of each recyclable memory page, and calculate an idle duration corresponding to the recyclable memory page according to the update time.
- the duration determining module 706 is further configured to obtain an update time of each recyclable memory page recorded by the most recently unused LRU management unit, and calculate an idle duration corresponding to the recyclable memory page according to the update time.
- the duration determining module 706 is further configured to calculate an average idle duration of the to-be-processed application for the reclaimable memory page according to the idle duration of each recyclable memory page; and determine a duration threshold according to the average idle duration and the dependency ratio.
- the duration determining module 706 is further configured to obtain a correspondence between a recycling ratio corresponding to the to-be-processed application and a secondary startup duration; the secondary startup duration refers to that the reclaimable memory page occupied by the to-be-processed application is recycled. The time taken to start again after the corresponding recovery ratio; determine the amount of memory page reclaimed according to the dependence ratio and the correspondence between the recyclable memory page and the recycling ratio and the secondary startup time; The idle time length of the Kth page is selected as the idle time length of the memory page, and the selected idle time length is used as the duration threshold; the number of idle time exceeding the Kth largest is the recovery quantity, and K is the natural number not exceeding the recovery quantity.
- the dependency determination module 704 is further configured to determine that the to-be-processed application is dependent on the foreground application when there is a communication mechanism or a synchronization mechanism between the to-be-processed application and the foreground application.
- the memory processing device obtains a reclaimable memory page occupied by the application to be processed and an idle duration thereof, and obtains a dependency ratio of the to-be-processed application that is dependent on the foreground application, and then determines a duration threshold according to the idle duration and the dependency ratio, and Reclaiming a memory page whose idle time exceeds the duration threshold, because the object being reclaimed is a reclaimable memory page, and it is not necessarily all the recyclable memory pages are reclaimed, but the idle time of each recyclable memory page and
- the pending application depends on the proportion of dependencies that the foreground application depends on, and the memory pages whose idle time exceeds the corresponding duration threshold are selected for recycling, thereby further reducing the operational impact of the application to be processed and the foreground application, and the reclaimed memory pages can be released for use by other applications. To ensure that the negative impact of each application is minimized, the memory usage efficiency is improved, and the balance between the recycling and operation of the application memory to be processed is maintained.
- each module in the above memory processing device is for illustrative purposes only. In other embodiments, the memory processing device may be divided into different modules as needed to complete all or part of the functions of the memory processing device.
- Each of the above-described memory processing devices may be implemented in whole or in part by software, hardware, and combinations thereof.
- Each of the above modules may be embedded in or independent of the processor in the electronic device, or may be stored in a memory in the electronic device in a software format, so that the processor calls to perform operations corresponding to the above modules.
- each module in the memory processing device may be in the form of a computer program.
- the computer program can run on an electronic device such as a terminal or a server.
- the program module of the computer program can be stored on a memory of the electronic device.
- the computer program is executed by the processor, the operation of the memory processing method described in the embodiment of the present application is implemented.
- an electronic device including a memory, a processor, and a computer program stored on the memory and executable on the processor, the memory processing provided by the above embodiments being implemented when the processor executes the computer program The operation of the method.
- a computer readable storage medium having stored thereon a computer program for performing memory processing as described in various embodiments of the present application when executed by a processor The operation of the method.
- a computer program product comprising instructions, when executed on a computer, causes the computer to perform the memory processing methods described in various embodiments of the present application.
- the embodiment of the present application also provides a computer device. As shown in FIG. 8 , for the convenience of description, only the parts related to the embodiments of the present application are shown. For details that are not disclosed, refer to the method part of the embodiment of the present application.
- the computer device may be any terminal device including a mobile phone, a tablet computer, a PDA (Personal Digital Assistant), a POS (Point of Sales), a vehicle-mounted computer, a wearable device, and the like, taking a computer device as a mobile phone as an example. :
- FIG. 8 is a block diagram showing a part of a structure of a mobile phone related to a computer device according to an embodiment of the present application.
- the mobile phone includes: a radio frequency (RF) circuit 810, a memory 820, an input unit 830, a display unit 840, a sensor 850, an audio circuit 860, a wireless fidelity (WiFi) module 870, and a processor 880. And power supply 890 and other components.
- RF radio frequency
- the RF circuit 810 can be used for receiving and transmitting information during the transmission or reception of information, and can receive and send the downlink information of the base station, and then send the uplink data to the base station.
- RF circuits include, but are not limited to, an antenna, at least one amplifier, a transceiver, a coupler, a Low Noise Amplifier (LNA), a duplexer, and the like.
- LNA Low Noise Amplifier
- RF circuitry 810 can also communicate with the network and other devices via wireless communication.
- the above wireless communication may use any communication standard or protocol, including but not limited to Global System of Mobile communication (GSM), General Packet Radio Service (GPRS), Code Division Multiple Access (Code Division). Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Long Term Evolution (LTE), e-mail, Short Messaging Service (SMS), and the like.
- GSM Global System of Mobile communication
- GPRS General Packet Radio Service
- CDMA Code Division Multiple Access
- the memory 820 can be used to store software programs and modules, and the processor 880 executes various functional applications and data processing of the mobile phone by running software programs and modules stored in the memory 820.
- the memory 820 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function (such as an application of a sound playing function, an application of an image playing function, etc.);
- the data storage area can store data (such as audio data, address book, etc.) created according to the use of the mobile phone.
- memory 820 can include high speed random access memory, and can also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid state storage device.
- the input unit 830 can be configured to receive input numeric or character information and to generate key signal inputs related to user settings and function control of the handset 800.
- the input unit 830 may include a touch panel 831 and other input devices 832.
- the touch panel 831 also referred to as a touch screen, can collect touch operations on or near the user (such as the user using a finger, a stylus, or the like on the touch panel 831 or near the touch panel 831. Operation) and drive the corresponding connection device according to a preset program.
- the touch panel 831 can include two portions of 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 880 is provided and can receive commands from the processor 880 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.
- other input devices 832 may include, but are not limited to, one or more of a physical keyboard, function keys (such as volume control buttons, switch buttons, etc.).
- the display unit 840 can be used to display information input by the user or information provided to the user as well as various menus of the mobile phone.
- the display unit 840 can include a display panel 841.
- the display panel 841 can be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), or the like.
- the touch panel 831 can cover the display panel 841. When the touch panel 831 detects a touch operation thereon or nearby, the touch panel 831 transmits to the processor 880 to determine the type of the touch event, and then the processor 880 is The type of touch event provides a corresponding visual output on display panel 841.
- the touch panel 831 and the display panel 841 are two independent components to implement the input and input functions of the mobile phone, in some embodiments, the touch panel 831 can be integrated with the display panel 841. Realize the input and output functions of the phone.
- the handset 800 can also include at least one type of sensor 850, such as a light sensor, motion sensor, and other sensors.
- the light sensor may include an ambient light sensor and a proximity sensor, wherein the ambient light sensor may adjust the brightness of the display panel 841 according to the brightness of the ambient light, and the proximity sensor may close the display panel 841 and/or when the mobile phone moves to the ear. Or backlight.
- the motion sensor may include an acceleration sensor, and the acceleration sensor can detect the magnitude of the acceleration in each direction, and the magnitude and direction of the gravity can be detected at rest, and can be used to identify the gesture of the mobile phone (such as horizontal and vertical screen switching), and vibration recognition related functions (such as Pedometer, tapping, etc.; in addition, the phone can also be equipped with gyroscopes, barometers, hygrometers, thermometers, infrared sensors and other sensors.
- the acceleration sensor can detect the magnitude of the acceleration in each direction, and the magnitude and direction of the gravity can be detected at rest, and can be used to identify the gesture of the mobile phone (such as horizontal and vertical screen switching), and vibration recognition related functions (such as Pedometer, tapping, etc.; in addition, the phone can also be equipped with gyroscopes, barometers, hygrometers, thermometers, infrared sensors and other sensors.
- Audio circuitry 860, speaker 861, and microphone 862 can provide an audio interface between the user and the handset.
- the audio circuit 860 can transmit the converted electrical data of the received audio data to the speaker 861 for conversion to the sound signal output by the speaker 861; on the other hand, the microphone 862 converts the collected sound signal into an electrical signal by the audio circuit 860. After receiving, it is converted into audio data, and then processed by the audio data output processor 880, sent to another mobile phone via the RF circuit 810, or outputted to the memory 820 for subsequent processing.
- WiFi is a short-range wireless transmission technology
- the mobile phone can help users to send and receive emails, browse web pages, and access streaming media through the WiFi module 870, which provides users with wireless broadband Internet access.
- FIG. 8 shows the WiFi module 870, it can be understood that it does not belong to the essential configuration of the mobile phone 800 and can be omitted as needed.
- the processor 880 is the control center of the handset, and connects various portions of the entire handset using various interfaces and lines, by executing or executing software programs and/or modules stored in the memory 820, and invoking data stored in the memory 820, executing The phone's various functions and processing data, so that the overall monitoring of the phone.
- processor 880 can include one or more processing units.
- the processor 880 can integrate an application processor and a modem, wherein the application processor primarily processes an operating system, a user interface, an application, etc.; the modem primarily processes wireless communications. It will be appreciated that the above modems may also not be integrated into the processor 880.
- the processor 880 can integrate an application processor and a baseband processor, and the baseband processor and other peripheral chips can form a modem.
- the mobile phone 800 also includes a power source 890 (such as a battery) that supplies power to various components.
- the power source can be logically coupled to the processor 880 through a power management system to manage functions such as charging, discharging, and power management through the power management system.
- the handset 800 can also include a camera, a Bluetooth module, and the like.
- the processor included in the mobile phone implements the memory processing method described above when executing a computer program stored in the memory.
- Non-volatile memory can include read only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory.
- Volatile memory can include random access memory (RAM), which acts as an external cache.
- RAM is available in a variety of forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchronization.
- SRAM static RAM
- DRAM dynamic RAM
- SDRAM synchronous DRAM
- DDR SDRAM dual data rate SDRAM
- ESDRAM enhanced SDRAM
- SLDRAM Link (Synchlink) DRAM
- SLDRAM Memory Bus
- Rambus Direct RAM
- RDRAM Direct Memory Bus Dynamic RAM
- RDRAM Memory Bus Dynamic RAM
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Software Systems (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Memory System (AREA)
- Debugging And Monitoring (AREA)
Abstract
Provided is a memory processing method, comprising: obtaining the recyclable memory page occupied by an application to be processed; obtaining the dependency proportion of the application to be processed on which a foreground application depends; obtaining the idle duration of the application to be processed for each recyclable memory page; determining the duration threshold according to the idle duration and the dependency proportion of each recyclable memory page; selecting from the recyclable memory pages the memory page having the idle duration longer than the duration threshold for recycling.
Description
本申请要求于2018年01月10日提交中国专利局、申请号为2018100232172、发明名称为“内存处理方法和装置、电子设备、计算机可读存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims priority to Chinese Patent Application No. 2018100232172, entitled "Memory Processing Method and Apparatus, Electronic Device, Computer Readable Storage Medium", filed on January 10, 2018, the entire contents of which are hereby incorporated by reference. This is incorporated herein by reference.
本申请涉及数据处理领域,特别是涉及一种内存处理方法、电子设备及计算机可读存储介质。The present application relates to the field of data processing, and in particular, to a memory processing method, an electronic device, and a computer readable storage medium.
电子设备上安装的应用在运行时,需要占用一定的内存。内存是一个应用在运行过程中数据的主要存储介质。由于电子设备上的内存容量有限,当后台应用占据的内存过多时,会影响前台应用的运行效率。因而需要对内存进行回收,以提高前台应用的运行效率。Applications installed on electronic devices require a certain amount of memory when they are running. Memory is the primary storage medium for data that is applied during the run. Due to the limited memory capacity on the electronic device, when the background application occupies too much memory, it will affect the operating efficiency of the foreground application. Therefore, the memory needs to be recycled to improve the operating efficiency of the foreground application.
传统对内存处理方法是将处于后台运行的单个应用占据的内存全部回收。然而,将单个应用使用的内存完全回收后将导致该应用下次启动和执行过程中需要将几乎所有被回收的内存重新加载回来,导致被回收内存的应用的运行速度显著降低。The traditional approach to memory processing is to reclaim all of the memory occupied by a single application running in the background. However, completely reclaiming the memory used by a single application will cause the application to reload almost all of the reclaimed memory during the next startup and execution, resulting in a significantly slower running of the application that is reclaiming memory.
发明内容Summary of the invention
根据本申请的各种实施例提供一种内存处理方法和装置、电子设备及计算机可读存储介质,可以在提高前台应用的运行效率的同时,降低对被回收内存的应用的运行的影响。According to various embodiments of the present application, an in-memory processing method and apparatus, an electronic device, and a computer-readable storage medium are provided, which can reduce the impact on the operation of an application of a reclaimed memory while improving the operational efficiency of the foreground application.
一种内存处理方法,包括:获取待处理应用所占用的可回收内存页;获取所述待处理应用被前台应用依赖的依赖比例;获取所述待处理应用对每个所述可回收内存页的空闲时长;根据所述每个所述可回收内存页的空闲时长和所述依赖比例确定时长阈值;从所述可回收内存页中选取空闲时长超过所述时长阈值的内存页进行回收。An in-memory processing method includes: acquiring a reclaimable memory page occupied by an application to be processed; obtaining a dependency ratio of the to-be-processed application to be relied upon by the foreground application; and acquiring the to-be-processed application for each of the retrievable memory pages The idle time length is determined according to the idle duration of the each recyclable memory page and the dependency ratio; and the memory page whose idle duration exceeds the duration threshold is selected from the reclaimable memory page for recycling.
一种电子设备,包括存储器及处理器,所述存储器中储存有计算机程序,所述计算机程序被所述处理器执行时,使得所述处理器实现如下操作:An electronic device includes a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor performs the following operations:
获取待处理应用所占用的可回收内存页;Get the reclaimable memory page occupied by the pending application;
获取所述待处理应用被前台应用依赖的依赖比例;Obtaining a proportion of dependencies that the to-be-processed application is dependent on by the foreground application;
获取所述待处理应用对每个所述可回收内存页的空闲时长;Obtaining an idle duration of the to-be-processed application for each of the recyclable memory pages;
根据所述每个所述可回收内存页的空闲时长和所述依赖比例确定时长阈值;及Determining a duration threshold according to the idle duration of each of the recyclable memory pages and the dependency ratio; and
从所述可回收内存页中选取空闲时长超过所述时长阈值的内存页进行回收。A memory page whose idle time exceeds the duration threshold is selected from the recyclable memory page for recycling.
一种计算机可读存储介质,其上存储有计算机程序,所述计算机程序被处理器执行时实现如下操作:A computer readable storage medium having stored thereon a computer program, the computer program being executed by a processor to:
获取待处理应用所占用的可回收内存页;Get the reclaimable memory page occupied by the pending application;
获取所述待处理应用被前台应用依赖的依赖比例;Obtaining a proportion of dependencies that the to-be-processed application is dependent on by the foreground application;
获取所述待处理应用对每个所述可回收内存页的空闲时长;Obtaining an idle duration of the to-be-processed application for each of the recyclable memory pages;
根据所述每个所述可回收内存页的空闲时长和所述依赖比例确定时长阈值;及Determining a duration threshold according to the idle duration of each of the recyclable memory pages and the dependency ratio; and
从所述可回收内存页中选取空闲时长超过所述时长阈值的内存页进行回收。A memory page whose idle time exceeds the duration threshold is selected from the recyclable memory page for recycling.
本申请实施例提供的内存处理方法、电子设备及计算机可读存储介质,通过获取待处理应用所占用的可回收内存页及其空闲时长,并获取待处理应用被前台应用依赖的依赖比例,然后根据该空闲时长和依赖比例来确定时长阈值,并对空闲时长超过时长阈值的内存页进行回收,由于回收的对象是可回收内存页,且并非一定是对所有可回收内存页均进行回收,而是按照与每个可回收内存页的空闲时长以及待处理应用被前台应用依赖的依赖比例,选取空闲时长超过相应的时长阈值的内存页进行回收,进一步降低了对待处理应用和前台应用的运行影响,且回收的内存页可释放出来供其它应用使用,保证在整个系统内存变大的情况下, 对每个应用的负面影响最小,又提高了内存使用效率,保持了对待处理应用内存的回收与运行之间的平衡性。The memory processing method, the electronic device, and the computer readable storage medium provided by the embodiment of the present application obtain the recyclable memory page occupied by the application to be processed and the idle duration thereof, and obtain the dependency ratio of the to-be-processed application that is dependent on the foreground application, and then The duration threshold is determined according to the idle duration and the dependency ratio, and the memory page whose idle duration exceeds the duration threshold is recovered, because the recovered object is a reclaimable memory page, and not all the recyclable memory pages are necessarily recovered. According to the ratio of the idle time of each recyclable memory page and the dependency ratio of the to-be-processed application to the foreground application, the memory page whose idle time exceeds the corresponding duration threshold is selected for recycling, thereby further reducing the operational impact of the application to be processed and the foreground application. The reclaimed memory pages can be released for use by other applications, ensuring minimal negative impact on each application as the entire system memory becomes larger, improving memory usage efficiency, and maintaining the recycling of the application memory to be processed. Balance between operations.
本申请的一个或多个实施例的细节在下面的附图和描述中提出。本申请的其它特征、目的和优点将从说明书、附图以及权利要求书变得明显。Details of one or more embodiments of the present application are set forth in the accompanying drawings and description below. Other features, objects, and advantages of the invention will be apparent from the description and appended claims.
为了更清楚地说明本申请实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings to be used in the embodiments or the prior art description will be briefly described below. Obviously, the drawings in the following description are only It is a certain embodiment of the present application, and other drawings can be obtained according to the drawings without any creative work for those skilled in the art.
图1为一个实施例中电子设备的内部结构示意图。FIG. 1 is a schematic diagram showing the internal structure of an electronic device in an embodiment.
图2为一个实施例中电子设备中的系统的部分框架示意图。2 is a partial block diagram of a system in an electronic device in an embodiment.
图3为一个实施例中内存处理方法的流程图。3 is a flow chart of a memory processing method in one embodiment.
图4为一个实施例中根据每个可回收内存页的空闲时长和依赖比例确定时长阈值的流程图。4 is a flow diagram of determining a duration threshold based on the idle duration and dependency ratio of each recyclable memory page in one embodiment.
图5A为一个实施例中无关类应用的回收比例曲线示意图。Figure 5A is a schematic diagram of a recovery ratio curve for an unrelated application in one embodiment.
图5B为一个实施例中线性类应用的回收比例曲线示意图。Figure 5B is a schematic diagram of the recovery ratio curve for a linear application in one embodiment.
图5C为一个实施例中非线性类应用的回收比例曲线示意图。Figure 5C is a schematic diagram of a recovery ratio curve for a non-linear application in one embodiment.
图6为另一个实施例中内存处理方法的流程图。6 is a flow chart of a memory processing method in another embodiment.
图7为一个实施例中内存处理装置的结构框图。Figure 7 is a block diagram showing the structure of an internal memory processing device in an embodiment.
图8为一个实施例中手机的部分结构的框图。Figure 8 is a block diagram showing a portion of the structure of a handset in an embodiment.
为了使本申请的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本申请进行进一步详细说明。应当理解,此处所描述的具体实施例仅仅用以解释本申请,并不用于限定本申请。In order to make the objects, technical solutions, and advantages of the present application more comprehensible, the present application will be further described in detail below with reference to the accompanying drawings and embodiments. It is understood that the specific embodiments described herein are merely illustrative of the application and are not intended to be limiting.
在一个实施例中,如图1所示,提供了一种电子设备的内部结构示意图。该电子设备包括通过系统总线连接的处理器、存储器和显示屏。其中,该处理器用于提供计算和控制能力,支撑整个电子设备的运行。存储器用于存储数据、程序、和/或指令代码等,存储器上存储至少一个计算机程序,该计算机程序可被处理器执行,以实现本申请实施例中提供的适用于电子设备的内存处理方法。存储器可包括磁碟、光盘、只读存储记忆体(Read-Only Memory,ROM)等非易失性存储介质,或随机存储记忆体(Random-Access-Memory,RAM)等。例如,在一个实施例中,存储器包括非易失性存储介质及内存储器。非易失性存储介质存储有操作系统、数据库和计算机程序。该数据库中存储有用于实现以上各个实施例所提供的一种内存处理方法相关的数据,比如可存储有每个应用的名称以及为每个应用分配的内存页等信息。该计算机程序可被处理器所执行,以用于实现本申请各个实施例所提供的一种内存处理方法。内存储器为非易失性存储介质中的操作系统、数据库和计算机程序提供高速缓存的运行环境。显示屏可以是触摸屏,比如为电容屏或电子屏,用于显示前台应用的界面展示信息,还可以被用于检测作用于该显示屏的触摸操作,生成相应的指令,比如进行前后台应用的切换指令等。In one embodiment, as shown in FIG. 1, an internal structure diagram of an electronic device is provided. The electronic device includes a processor, memory, and display screen connected by a system bus. The processor is used to provide computing and control capabilities to support the operation of the entire electronic device. The memory is used to store data, programs, and/or instruction codes, etc., and the memory stores at least one computer program, which can be executed by the processor to implement the memory processing method applicable to the electronic device provided in the embodiments of the present application. The memory may include a non-volatile storage medium such as a magnetic disk, an optical disk, a read-only memory (ROM), or a random storage memory (Random-Access-Memory, RAM). For example, in one embodiment, the memory includes a non-volatile storage medium and an internal memory. Non-volatile storage media stores operating systems, databases, and computer programs. The database stores data related to implementing an in-memory processing method provided by the above various embodiments, such as storing a name of each application and a memory page allocated for each application. The computer program can be executed by a processor for implementing an in-memory processing method provided by various embodiments of the present application. The internal memory provides a cached operating environment for operating systems, databases, and computer programs in non-volatile storage media. The display screen can be a touch screen, such as a capacitive screen or an electronic screen, for displaying interface display information of the foreground application, and can also be used for detecting a touch operation acting on the display screen, and generating corresponding instructions, such as performing front and back applications. Switch instructions, etc.
本领域技术人员可以理解,图1中示出的结构,仅仅是与本申请方案相关的部分结构的框图,并不构成对本申请方案所应用于其上的电子设备的限定,具体的电子设备可以包括比图中所示更多或更少的部件,或者组合某些部件,或者具有不同的部件布置。如该电子设备还包括通过系统总线连接的网络接口,网络接口可以是以太网卡或无线网卡等,用于与外部的电子设备进行通信,比如可用于同服务器进行通信。再比如该电子设备上并不存在通过系统总线连接的显示器,或者可连接外部显示设备。A person skilled in the art can understand that the structure shown in FIG. 1 is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the electronic device to which the solution of the present application is applied. The specific electronic device may be It includes more or fewer components than those shown in the figures, or some components are combined, or have different component arrangements. For example, the electronic device further includes a network interface connected through a system bus, and the network interface may be an Ethernet card or a wireless network card, etc., for communicating with an external electronic device, for example, for communicating with a server. For example, there is no display connected through the system bus on the electronic device, or an external display device can be connected.
在一个实施例中,如图2所示,提供了一种电子设备的部分架构图。其中,该电子设备的架构系统中包括JAVA空间层210、本地框架层220以及内核(Kernel)空间层230。JAVA空间层210上可包含冻结管理应用212,电子设备可通过该冻结管理应用212来实现对各个应用的冻结策略,对后台耗电的相关应用做冻结和解冻等管理操作。本地框架层220中包含资源优先级和限制管理模块222和平台冻结管理模块224。电子设备可通过资源优先级和限制管理模块222实时维护不同的应用处于不同优先级和不同资源的组织中,并根据上层的需求来调整应用程序的资源组别从而达到优化性能,节省功耗的作用。电子设备可通过平台冻结管理模块224将后台可以冻结的任务按照进入冻结时间的长短,分配到对应预设的不同层次的冻结层,可选地,该冻结层可包括三个,分别是:CPU限制睡眠模式、CPU冻结睡眠模式、进程深度冻结模式。其中,CPU限制睡眠模式是指对相关进程所占用的CPU资源进行限制,使相关进程占用较少的CPU资源,将空余的CPU资源向其它未被冻结的进程倾斜,限制了对CPU资源的占用,也相应限制了进程对网络资源以及I/O接口资源的占用;CPU冻结睡眠模式是指禁止相关进程使用CPU,而保留对内存的占用,当禁止使用CPU资源时,相应的网络资源以及I/O接口资源也被禁止使用;进程深度冻结模式是指除禁止使用CPU资源之外,进一步对相关进程所占用的内存资源进行回收,回收的内存可供其它进程使用。内核空间层230中包括UID管理模块231、Cgroup模块232、Binder管控模块233、进程内存回收模块234以及冻结超时退出模块235。其中,UID管理模块231用于实现基于应用的用户身份标识(User Identifier,UID)来管理第三方应用的资源或进行冻结。相比较于基于进程身份标识(Process Identifier,PID)来进行进程管控,通过UID更便于统一管理一个用户的应用的资源。Cgroup模块232用于提供一套完善的中央处理器(Central Processing Unit,CPU)、CPUSET、内存(memory)、输入/输出(input/output,I/O)和Net相关的资源限制机制。Binder管控模块233用于实现后台binder通信的优先级的控制。其中,本地框架层220的接口模块包含开发给上层的binder接口,上层的框架或者应用通过提供的binder接口来发送资源限制或者冻结的指令给资源优先级和限制管理模块222和平台冻结管理模块224。进程内存回收模块234用于实现进程深度冻结模式,这样能当某个第三方应用长期处于冻结状态的时候,会主要释放掉进程的文件区,从而达到节省内存的模块,也加快该应用在下次启动时的速度。冻结超时退出模块235用于解决出现冻结超时场景产生的异常。通过上述的架构,可实现本申请各个实施例中的内存处理方法。In one embodiment, as shown in FIG. 2, a partial architectural diagram of an electronic device is provided. The architecture of the electronic device includes a JAVA spatial layer 210, a local framework layer 220, and a kernel space layer 230. The JAVA spatial layer 210 may include a freeze management application 212. The electronic device may implement a freeze policy for each application through the freeze management application 212, and perform freezing and thawing management operations on the related applications of the background power consumption. The resource priority and restriction management module 222 and the platform freeze management module 224 are included in the local framework layer 220. The electronic device can maintain different applications in different priorities and different resource organizations through the resource priority and limit management module 222, and adjust the resource group of the application according to the requirements of the upper layer to achieve optimized performance and save power. effect. The electronic device can allocate the tasks that can be frozen in the background to the frozen layer corresponding to the preset different levels according to the length of the entering freeze time through the platform freeze management module 224. Optionally, the frozen layer can include three, respectively: the CPU Limit sleep mode, CPU freeze sleep mode, process deep freeze mode. The CPU restricts the sleep mode to limit the CPU resources occupied by the related processes, so that the related processes occupy less CPU resources, and the free CPU resources are tilted to other unfrozen processes, thereby limiting the occupation of CPU resources. It also limits the occupation of network resources and I/O interface resources by the process; CPU freeze sleep mode refers to prohibiting related processes from using the CPU, while preserving the occupation of memory, when prohibiting the use of CPU resources, the corresponding network resources and I The /O interface resource is also forbidden; the process deep freeze mode means that in addition to prohibiting the use of CPU resources, the memory resources occupied by the related processes are further recovered, and the recovered memory can be used by other processes. The kernel space layer 230 includes a UID management module 231, a Cgroup module 232, a Binder management module 233, a process memory recovery module 234, and a freeze timeout exit module 235. The UID management module 231 is configured to implement an application-based User Identifier (UID) to manage resources of a third-party application or freeze. Compared with the Process Identifier (PID) for process management and control, it is easier to uniformly manage the resources of a user's application through UID. The Cgroup module 232 is used to provide a complete set of Central Processing Unit (CPU), CPUSET, memory, input/output (I/O), and Net related resource restriction mechanisms. The Binder management module 233 is used to implement the priority control of the background binder communication. The interface module of the local framework layer 220 includes a binder interface developed to the upper layer, and the upper layer framework or application sends a resource restriction or frozen instruction to the resource priority and restriction management module 222 and the platform freeze management module 224 through the provided binder interface. . The process memory recovery module 234 is configured to implement the process deep freeze mode, so that when a third-party application is in a frozen state for a long time, the file area of the process is mainly released, thereby saving the memory module and speeding up the application next time. The speed at startup. The freeze timeout exit module 235 is configured to resolve an exception generated by the freeze timeout scenario. Through the above architecture, the memory processing method in various embodiments of the present application can be implemented.
在一个实施例中,如图3所示,提供了一种内存处理方法,本实施例以该方法应用于如图1所示的电子设备为例进行说明。该方法包括:In an embodiment, as shown in FIG. 3, an in-memory processing method is provided. This embodiment is applied to the electronic device shown in FIG. 1 as an example for description. The method includes:
操作302,获取待处理应用所占用的可回收内存页。In operation 302, a reclaimable memory page occupied by the application to be processed is obtained.
待处理应用表示需要进行对占用内存进行回收的应用。该内存(又称随机存取存储器,random access memory,RAM)表示运行程序时使用的内存(即运行内存),只能临时存储数据,用于与CPU交换高速缓存数据,但是内存本身不能用于长期存储数据。通常的,待处理应用为后台应用。后台应用为处于后台运行的应用;对应地,处于前台运行的应用即为前台应用。一个应用(Application,简称APP)的运行通常是由相关的多个进程的运行而体现的。进程(process)是计算机中的程序关于某数据集合上的一次运行活动,是系统进行资源分配和调度的基本单位,是操作系统结构的基础。前台应用运行时涉及的进程即为前台进程,后台应用运行时涉及的进程即为后台进程。The pending application indicates that an application that needs to recycle memory is needed. The memory (also known as random access memory, RAM) indicates the memory used when running the program (that is, running memory). It can only temporarily store data for exchanging cache data with the CPU, but the memory itself cannot be used. Store data for a long time. Typically, the pending application is a background application. The background application is an application running in the background; correspondingly, the application running in the foreground is the foreground application. The operation of an application (APP) is usually reflected by the operation of multiple related processes. A process is a running activity of a program on a computer on a data set. It is the basic unit for resource allocation and scheduling, and is the basis of the operating system structure. The process involved in the foreground application runtime is the foreground process, and the process involved in the background application runtime is the background process.
应用在运行的状态下需要占用内存空间来存储运行过程中的数据。不同的应用在不同的运行状态占用的内存空间大小不一定相同。内存页是操作系统对内存进行管理的单位,不同的电子设备设置的内存页占据的单位内存大小不一定相同。比如电子设备内的内存空间被划分为100000个内存页,待处理应用占用的内存页为内存页100至内存页200,而其中的内存页130至内存页200为可回收内存页。The application needs to occupy memory space in the running state to store data during the running process. The memory space occupied by different applications in different running states may not be the same. The memory page is the unit that the operating system manages the memory. The memory size of the memory page set by different electronic devices is not necessarily the same. For example, the memory space in the electronic device is divided into 100000 memory pages, and the memory page occupied by the to-be-processed application is the memory page 100 to the memory page 200, and the memory page 130 to the memory page 200 are recyclable memory pages.
在一个实施例中,电子设备可预先记录待处理应用在运行所占用的所有内存页,并从该所有内存页中获取可收回内存页。可回收内存页表示可进行回收,且回收后对待处理应用以及其它应用的运行不造成影响或者造成的影响较小的内存页。In one embodiment, the electronic device may pre-record all memory pages occupied by the application to be processed and obtain retrievable memory pages from the all memory pages. Recyclable memory pages represent memory pages that can be recycled and that have no impact on the operation of the application and other applications after they are recycled.
在一个实施例中,电子设备可记录该所有内存页中,哪些内存页为可回收内存页,哪些内存页为不可回收内存页,并根据该记录信息来获取待处理应用占用的可回收内存页。In an embodiment, the electronic device can record, among the memory pages, which memory pages are recyclable memory pages, which memory pages are non-recyclable memory pages, and obtain recyclable memory pages occupied by the to-be-processed application according to the record information. .
操作304,获取待处理应用被前台应用依赖的依赖比例。Operation 304: Obtain a proportion of dependencies that the to-be-processed application is dependent on by the foreground application.
依赖表示表示一个应用需要利用于另一个或多个应用的数据才能顺利实现对该一个应用的执行的关系。存在依赖关系的两个应用,分别为被依赖的应用和依赖的应用。由于应用的运行通常是由相关的多个进程的运行而体现的,应用之间的依赖也表现为进程之间的依赖。比如应用A中的某一进程a依赖于应用B中的某一进程b,即该进程b被进程a依赖,进程a需要利用进程b的数据才能实现对该进程a的执行,也说明了应用A依赖于应用B,或应用B被应用A依赖,应用A需要利用应用B的数据才能实现对该应用A的执行,此时,应用A即为被依赖的应用。可以理解地,依赖的应用还可能为第一应用,第二应用可能为后台应用。电子设备可从后台应用集合中进行检测,以查询出是否存在被前台应用依赖的后台应用。A dependency representation indicates that an application needs to utilize data from one or more applications in order to successfully implement the relationship to the execution of that application. There are two applications of dependencies, namely the dependent application and the dependent application. Since the operation of an application is usually manifested by the operation of multiple related processes, the dependencies between applications also appear as dependencies between processes. For example, a certain process a in the application A depends on a certain process b in the application B, that is, the process b is dependent on the process a, and the process a needs to utilize the data of the process b to implement the execution of the process a, and also illustrates the application. A depends on application B, or application B is dependent on application A. Application A needs to utilize the data of application B to implement the execution of application A. At this time, application A is the dependent application. It can be understood that the dependent application may also be the first application, and the second application may be a background application. The electronic device can detect from the background application collection to query whether there is a background application that is dependent on the foreground application.
依赖比例反映了被依赖应用被其所依赖的应用的依赖程度,依赖程度越大,则依赖比例也相应越大。在一个实施例中,电子设备可记录每个应用对其它应用的依赖比例,并读取所记录的众多依赖比例之中,待处理应用被前台应用的依赖比例。The dependency ratio reflects the degree of dependency of the application to which the dependent application is dependent. The greater the degree of dependency, the greater the dependency ratio. In one embodiment, the electronic device can record the proportion of each application's dependence on other applications and read the proportion of dependencies that the pending application is applied by the foreground among the many dependent ratios recorded.
在一个实施例中,当待处理应用不被前台应用依赖时,则依赖比例为0。In one embodiment, the dependency ratio is zero when the pending application is not dependent on the foreground application.
操作306,获取待处理应用对每个可回收内存页的空闲时长。Operation 306: Acquire an idle duration of the to-be-processed application for each recyclable memory page.
由于内存页中存储的数据并非一直被应用所使用,对内存页的空闲时长表示系统为该待处理应用分配内存页后,该内存页中存储的数据在最近一次被使用之后,处于未被使用状态的持续时长。电子设备根据每个内存页的数据使用情况,来实时更新每个内存页的空闲时长,当准备进行对待处理应用占用的内存页进行回收时,可获取最新记录的每个可回收内存页的空闲时长。Since the data stored in the memory page is not always used by the application, the idle duration of the memory page indicates that after the system allocates a memory page for the pending application, the data stored in the memory page is not used after being used most recently. The duration of the state. The electronic device updates the idle time of each memory page in real time according to the data usage of each memory page, and obtains the free record of each recyclable memory page of the latest record when the memory page occupied by the application to be processed is ready for recycling. duration.
在一个实施例中,当最近一次发起对内存页的分配、回收、释放等情形,或者对处理器中缓存的使用情况进行查询的情况,均判定对相应涉及到的内存页的数据进行了使用,并将产生对应情形下的系统时间最为最近一次对内存页的数据使用时间,当前时间和该最近时间之差即为对相应内存页的空闲时长。In one embodiment, when the allocation, reclaim, release, etc. of the memory page is initiated recently, or the usage of the cache in the processor is queried, it is determined that the data of the corresponding memory page is used. And will generate the data usage time of the most recent time on the memory page of the system time in the corresponding situation. The difference between the current time and the latest time is the idle time of the corresponding memory page.
在一个实施例中,电子设备可对每个内存页创建对应的时间戳,该时间戳记录对应内存页中的数据在最近一次的使用时间。在操作系统中,每当主动发起对内存的分配、回收、释放等时机,可对相应内存页的活跃度进行更新,并将该更新时间记录在该时间戳中。或者在系统定时检查处理器缓存的使用情况,可判定当前缓存中的数据都为当前使用的数据,并更新所涉及到的内存页的时间戳,将该更新时间记录在该时间戳中。可选地,可将最新记录到的更新时间替换掉上一次的更新时间,以减少更新时间的资源占用。In one embodiment, the electronic device can create a corresponding timestamp for each memory page that records the most recent usage time of the data in the corresponding memory page. In the operating system, whenever the timing of allocation, recycling, release, etc. of the memory is actively initiated, the activity level of the corresponding memory page may be updated, and the update time is recorded in the timestamp. Or the system periodically checks the usage of the processor cache, determines that the data in the current cache is the currently used data, and updates the timestamp of the memory page involved, and records the update time in the timestamp. Optionally, the latest updated update time can be replaced with the last update time to reduce the resource consumption of the update time.
操作308,根据每个可回收内存页的空闲时长和依赖比例确定时长阈值。Operation 308, determining a duration threshold based on the idle duration and the dependency ratio of each recyclable memory page.
时长阈值表示用于决定是否对可回收内存页进行回收的临界数值。时长阈值可根据每个可回收内存页的空闲时长以及前台应用对待处理应用的依赖比例而确定,空闲时长不同或者依赖比例不同,所确定的时长阈值也不一定相同。The duration threshold represents the critical value used to decide whether to recycle the recyclable memory page. The duration threshold can be determined according to the idle duration of each recyclable memory page and the proportion of dependencies of the foreground application to be processed. The idle duration is different or the dependency ratio is different, and the determined duration threshold is not necessarily the same.
在一个实施例中,电子设备可计算所有可回收内存页的空闲时长的加权平均值,或者还可为从该所有可回收内存页的空闲时长中选取一个空闲时长,将选取的空闲时长或者计算出的加权平均值作为参考时长,并设置不同的参考时长、依赖比例与时长阈值之间的对应关系,根据该对应关系获取与该参考时长和依赖比例对应的时长阈值。比如可在该待处理应用占用的所有可回收内存页的空闲时长中,选取处于与中位数相接近的,或者处于排序在某一位置上的空闲时长,将选取的空闲时长作为参考时长。其中,时长阈值与依赖比例和参考时长均呈正相关,参考时长越大,和/或依赖比例越大,则对应确定的时长阈值越大。In one embodiment, the electronic device may calculate a weighted average of the idle duration of all recyclable memory pages, or may also select an idle duration from the idle duration of all of the recyclable memory pages, the selected idle duration or calculation The weighted average value is used as the reference duration, and the correspondence between the different reference durations, the dependency ratios, and the duration thresholds is set, and the duration threshold corresponding to the reference duration and the dependency ratio is obtained according to the correspondence. For example, in the idle duration of all the recyclable memory pages occupied by the to-be-processed application, the idle duration that is close to the median or is sorted at a certain location may be selected, and the selected idle duration is used as the reference duration. The duration threshold is positively correlated with the dependency ratio and the reference duration. The larger the reference duration, and/or the greater the dependency ratio, the larger the corresponding duration threshold.
操作310,从可回收内存页中选取空闲时长超过时长阈值的内存页进行回收。In operation 310, a memory page whose idle time exceeds a duration threshold is selected from the reclaimable memory page for recycling.
电子设备可按照所确定的时长阈值,从该待处理应用占用的可回收内存页中,选取空闲时长超过该时长阈值的内存页进行回收,以释放出该时长阈值的可回收内存页,供前台应用或其它应用所使用,提高系统的综合处理效率。可选地,电子设备可通过上述的进程内存回 收模块234,按照该时长阈值从可回收内存页中进行内存页的回收,释放长时间不使用的内存,提高内存使用效率,且使得回收内存页之后,对该待处理应用造成的影响也较小。在一个实施例中,回收的内存中的存储数据可存储至电子设备的非易失性存储介质或其它外接存储介质中,比如可为将回收的内存中的存储数据存储至电子设备的flash闪存或硬盘等内置的非易失性存储介质中。The electronic device may select, from the recyclable memory page occupied by the to-be-processed application, a memory page whose idle time exceeds the duration threshold according to the determined duration threshold to release the recyclable memory page of the duration threshold for the foreground. Used by applications or other applications to improve the overall processing efficiency of the system. Optionally, the electronic device may use the process memory recovery module 234 to recover the memory page from the recyclable memory page according to the duration threshold, release the memory that is not used for a long time, improve the memory usage efficiency, and enable the memory page to be reclaimed. After that, the impact on the pending application is also small. In one embodiment, the stored data in the recovered memory may be stored in a non-volatile storage medium or other external storage medium of the electronic device, such as a flash memory that can store the stored data in the recovered memory to the electronic device. Or a built-in non-volatile storage medium such as a hard disk.
举例来说,可回收内存页有100页,相应的空闲时长分别处于5秒至15分钟之间,当确定的时长阈值为5分钟时,可从该100页的内存页中,回收空闲时长超过5分钟的内存页,将回收的内存页进行释放,使得电子设备的空闲的内存页相应的增加,并可供给前台应用或其它的后台应用所使用。For example, the recyclable memory page has 100 pages, and the corresponding idle time is between 5 seconds and 15 minutes respectively. When the determined duration threshold is 5 minutes, the idle time can be recovered from the 100 pages of the memory page. The 5 minute memory page releases the reclaimed memory page, so that the free memory page of the electronic device is correspondingly increased, and can be used by the foreground application or other background applications.
上述的内存处理方法,通过获取待处理应用所占用的可回收内存页及其空闲时长,并获取待处理应用被前台应用依赖的依赖比例,然后根据该空闲时长和依赖比例来确定时长阈值,并对空闲时长超过时长阈值的内存页进行回收,由于回收的对象是可回收内存页,且并非一定是对所有可回收内存页均进行回收,而是按照与每个可回收内存页的空闲时长以及待处理应用被前台应用依赖的依赖比例,选取空闲时长超过相应的时长阈值的内存页进行回收,进一步降低了对待处理应用和前台应用的运行影响,且回收的内存页可释放出来供其它应用使用,保证在整个系统内存变大的情况下,对每个应用的负面影响最小,又提高了内存使用效率,保持了对待处理应用内存的回收与运行之间的平衡性。The memory processing method is configured to obtain a reclaimable memory page occupied by the application to be processed and an idle duration thereof, and obtain a dependency ratio of the to-be-processed application that is dependent on the foreground application, and then determine a duration threshold according to the idle duration and the dependency ratio, and Reclaiming a memory page whose idle time exceeds the duration threshold, because the object being reclaimed is a reclaimable memory page, and it is not necessarily all the recyclable memory pages are reclaimed, but the idle time of each recyclable memory page and The pending application depends on the proportion of dependencies that the foreground application depends on, and the memory pages whose idle time exceeds the corresponding duration threshold are selected for recycling, thereby further reducing the operational impact of the application to be processed and the foreground application, and the reclaimed memory pages can be released for use by other applications. To ensure that the negative impact of each application is minimized, the memory usage efficiency is improved, and the balance between the recycling and operation of the application memory to be processed is maintained.
在一个实施例中,操作304包括:检测每个可回收内存页中存储的数据是否被前台应用依赖;根据检测结果确定待处理应用被前台应用依赖的依赖比例。In one embodiment, operation 304 includes detecting whether data stored in each recyclable memory page is dependent on the foreground application; determining, based on the detection result, a dependency ratio of the application to be processed that is dependent on the foreground application.
检测结果包括内存页未被前台应用依赖或被前台应用依赖。电子设备可针对为待处理应用所分配的每个可回收内存页,检测相应内存页中存储的数据在预设时间段内是否被前台应用所使用到,若是,则判定该内存页被该前台应用所依赖。或者可针对该前台应用,检测其在预设时间段内,是否有使用到为待处理应用所分配的可回收内存页中存储的数据,并判定所使用到的内存页被前台应用所依赖。其中,该预设时间段可为在当前时刻为止的预设时长的时间段,也即最近时间段,该最近时间段的时长为预设时长,该预设时长可为按照经验值设置的任意合适的时长,比如为10分钟,或者半小时等。或者该预设时间段还可为前台应用当前保持在前台运行的时间段。比如,前台应用在10点35分20秒至当前时刻,均保持在前台运行,则当前时间段即为10点35分20秒至当前时刻的时间段。The detection results include that the memory page is not dependent on the foreground application or is dependent on the foreground application. The electronic device may detect, for each recyclable memory page allocated for the application to be processed, whether the data stored in the corresponding memory page is used by the foreground application within a preset time period, and if yes, determine that the memory page is used by the foreground The application depends. Alternatively, for the foreground application, it is detected whether it uses data stored in the recyclable memory page allocated for the application to be processed within a preset time period, and determines that the used memory page is dependent on the foreground application. The preset time period may be a preset time period of the current time, that is, the latest time period, and the duration of the latest time period is a preset duration, and the preset duration may be any set according to an empirical value. The appropriate length of time is, for example, 10 minutes, or half an hour. Or the preset time period may also be a time period in which the foreground application is currently running in the foreground. For example, if the foreground application is running in the foreground from 10:35:20 to the current time, the current time period is 10:35:20 to the current time.
可选地,该依赖比例可为被前台应用所依赖的可回收内存页的依赖总数与客户收内存页的总数之比。通过检测每个可回收内存页中存储的数据是否被前台应用依赖;进而根据检测结果确定待处理应用被前台应用依赖的依赖比例,可提高所确定的依赖比例的准确性。Alternatively, the dependency ratio may be the ratio of the total number of dependencies of the reclaimable memory pages on which the foreground application depends and the total number of memory pages received by the client. By detecting whether the data stored in each recyclable memory page is dependent on the foreground application; and further determining the dependency ratio of the to-be-processed application to be dependent on the foreground application according to the detection result, the accuracy of the determined dependency ratio can be improved.
在一个实施例中,操作310包括:从可回收内存页中选取空闲时长超过时长阈值的、未被前台应用依赖的内存页进行回收。In one embodiment, operation 310 includes selecting, from the reclaimable memory page, a memory page that has an idle duration that exceeds a duration threshold and is not dependent on the foreground application for recycling.
电子设备可进一步剔除被前台应用依赖的内存页,从未被前台应用依赖的可回收内存页中选取空闲时长超过时长阈值的内存页,并对选取的内存页进行回收。通过从未被前台应用依赖的内存页中选取空闲时长超过时长阈值的内存页进行回收,可防止被前台应用依赖的内存页被回收而对前台应用造成影响。The electronic device can further eliminate the memory page that is depended by the foreground application, and select a memory page whose idle time exceeds the duration threshold from the reclaimable memory page that is not dependent on the foreground application, and collect the selected memory page. By reclaiming a memory page whose idle time exceeds the duration threshold from a memory page that is not dependent on the foreground application, the memory page that is relied upon by the foreground application is prevented from being recycled and affects the foreground application.
在一个实施例中,操作306包括:获取每个可回收内存页的时间戳记录的更新时间,根据更新时间计算出对应可回收内存页的空闲时长。In one embodiment, operation 306 includes: obtaining an update time of a timestamp record for each recyclable memory page, and calculating an idle duration corresponding to the recyclable memory page based on the update time.
电子设备可通过上述的资源优先级和限制管理模块222,为每个内存页创建一个时间戳,该时间戳用于记录对应的更新时间,更新时间表示对应内存页最近被使用的时间。当检测到每个内存页中的内存被使用时,可对该时间戳记录的更新时间进行更新。The electronic device can create a timestamp for each memory page by using the resource priority and limit management module 222 described above, the timestamp is used to record the corresponding update time, and the update time indicates the time when the corresponding memory page is recently used. When the memory in each memory page is detected to be used, the update time of the timestamp record can be updated.
其中,每当最近一次发起对内存页的分配、回收、释放等情形,或者对处理器中缓存的使用情况进行查询的情况,均判定对相应涉及到的内存页的数据进行了使用,并将产生对应情形下的系统时间作为该更新时间。当开始执行内存回收机制时,可根据该时间戳记录的更新时间和当前系统时间,可计算出相应的内存页的空闲时长。当前时间和该最近时间之差即 为对相应内存页的空闲时长。Wherein, whenever the allocation, reclaim, release, etc. of the memory page is initiated, or when the usage of the cache in the processor is queried, it is determined that the data of the corresponding memory page is used, and The system time in the corresponding situation is generated as the update time. When the memory reclamation mechanism is started, the idle time of the corresponding memory page can be calculated according to the update time recorded by the time stamp and the current system time. The difference between the current time and the most recent time is the idle time for the corresponding memory page.
通过利用软件创建时间戳的方式来记录每个可回收内存页的更新时间,根据该更新时间来确定空闲时长,可以有效兼容不同的处理器,提高了对内存回收的通用性。By using the software to create a timestamp, the update time of each recyclable memory page is recorded, and the idle time is determined according to the update time, which can effectively be compatible with different processors, and improves the versatility of memory recycling.
在一个实施例中,操作306包括:获取通过最近最久未使用LRU管理单元记录的每个可回收内存页的更新时间,根据更新时间计算出对应可回收内存页的空闲时长。In one embodiment, operation 306 includes: obtaining an update time for each recyclable memory page recorded by the most recently unused LRU management unit, and calculating an idle duration corresponding to the recyclable memory page based on the update time.
在处理器中的内存管理或缓存单元中,设置相应的最近最久未使用(Least Recently Used,LRU)管理单元,用于对最近使用到的内存进行统计。LRU管理单元可记录每个内存地址以及该内存地址的更新时间,当某一地址的内存被使用到时,处理器将对应的内存地址和更新时间放入LRU管理单元中保存。当开始执行内存回收机制时,可根据该内存地址和内存页之间的对应关系,可获知每个内存地址对应的内存页,进而可从LRU管理单元中读取对应内存页的更新时间。其中,每当最近一次发起对内存页的分配、回收、释放等情形,或者对处理器中缓存的使用情况进行查询的情况,均判定对相应涉及到的内存页的数据进行了使用,并将产生对应情形下的系统时间作为该更新时间。In the memory management or cache unit in the processor, set the corresponding Least Recently Used (LRU) management unit to collect statistics on the most recently used memory. The LRU management unit can record each memory address and the update time of the memory address. When the memory of an address is used, the processor stores the corresponding memory address and update time in the LRU management unit. When the memory recovery mechanism is started, the memory page corresponding to each memory address can be obtained according to the correspondence between the memory address and the memory page, and the update time of the corresponding memory page can be read from the LRU management unit. Wherein, whenever the allocation, reclaim, release, etc. of the memory page is initiated, or when the usage of the cache in the processor is queried, it is determined that the data of the corresponding memory page is used, and The system time in the corresponding situation is generated as the update time.
当LRU管理单元用满后,可产生中断信息并通知操作系统,操作系统在读取LRU管理单元的数据后可清空其中的数据,使得LRU管理单元可重新开始工作,存储每个内存地址及其对应的更新时间等信息。When the LRU management unit is full, an interrupt information may be generated and the operating system may be notified, and the operating system may clear the data after reading the data of the LRU management unit, so that the LRU management unit can restart the work, and store each memory address and its Corresponding update time and other information.
本实施例中,通过创建LRU管理单元,可以精确地追踪每一个内存的使用情况,提高了对内存页的更新时间检测的准确性,也提高了内存回收的便利性。In this embodiment, by creating the LRU management unit, the usage of each memory can be accurately tracked, the accuracy of detecting the update time of the memory page is improved, and the convenience of memory recovery is also improved.
在一个实施例中,操作308包括:根据每个可回收内存页的空闲时长计算出待处理应用对可回收内存页的平均空闲时长;根据平均空闲时长与依赖比例确定时长阈值。In one embodiment, operation 308 includes: calculating an average idle duration of the to-be-processed application for the reclaimable memory page according to the idle duration of each recyclable memory page; determining a duration threshold based on the average idle duration and the dependency ratio.
平均空闲时长可为待处理应用所占用的可回收内存页中,每个内存页的占用时长的平均值。电子设备可根据统计到的每个内存页的占用时长,调用相应的计算单元进行计算,以计算出该平均空闲时长。可选地,可将计算出的平均空闲时长作为上述的参考时长,并按照该参考时长和依赖比例来确定时长阈值。The average idle duration is the average of the elapsed duration of each memory page in the reclaimable memory page occupied by the application to be processed. The electronic device can call the corresponding calculation unit to calculate according to the occupied duration of each memory page to calculate the average idle duration. Optionally, the calculated average idle duration is used as the reference duration, and the duration threshold is determined according to the reference duration and the dependency ratio.
通过按照平均空闲时长和依赖比例来确定时长阈值,可提高对时长阈值的计算效率,且计算简单,从而也相应提高了对内存回收的效率。By determining the duration threshold according to the average idle duration and the dependency ratio, the calculation efficiency of the duration threshold can be improved, and the calculation is simple, thereby correspondingly improving the efficiency of memory recovery.
在一个实施例中,如图4所示,操作308包括:In one embodiment, as shown in FIG. 4, operation 308 includes:
操作402,获取与待处理应用对应的回收比例与二次启动时长之间的对应关系。In operation 402, a correspondence between a recovery ratio corresponding to the application to be processed and a secondary startup duration is obtained.
二次启动时长是指待处理应用占用的可回收内存页被回收对应的回收比例后,再次启动时所花费的时长。该对应关系表示该应用所占内存中,回收不同比例的可回收内存后,对应的二次启动时长。可选地,该对应关系可为相应的回收比例与二次启动时长之间的对照表,或者回收比例曲线。该曲线为不同的回收比例下对应的二次启动时长。根据该对应关系,参照不同的二次启动时长来选取合适的回收比例,作为对该应用占用的可回收内存页的回收比例。The secondary startup time is the length of time that the reclaimed memory page occupied by the application to be processed is reclaimed after being recycled. The corresponding relationship indicates the corresponding secondary startup time after reclaiming different proportions of recyclable memory in the memory occupied by the application. Optionally, the correspondence may be a comparison table between the corresponding recovery ratio and the secondary startup time, or a recovery ratio curve. The curve is the corresponding secondary start time under different recovery ratios. According to the correspondence, the appropriate recycling ratio is selected with reference to different secondary startup durations as the recovery ratio of the recyclable memory pages occupied by the application.
操作404,根据依赖比例和可回收内存页和回收比例与二次启动时长之间的对应关系确定内存页的回收数量。 Operation 404, determining the number of reclaimed memory pages according to a correspondence between the dependency ratio and the reclaimable memory page and the recycling ratio and the secondary startup duration.
电子设备可设置对应的启动时长阈值,将二次启动时长达到该启动时长阈值时,对应的比例作为对可回收内存页的参考比例。启动时长阈值可为预设的经验数值,不同应用对应的启动时长阈值可不一定相同,比如可根据对应应用的正常启动时长来确定对应的启动时长阈值,将正常启动时长的1.5倍或2倍的时长作为该启动时长阈值。参考比例表示对内存页回收比例的参考。根据确定的参考比例,再结合依赖比例以及可回收内存页的总数,确定对可回收内存页的回收数量。回收数量为对内存页的回收数量,该数量为正整数。The electronic device can set a corresponding startup time threshold, and when the secondary startup time reaches the startup time threshold, the corresponding ratio is used as a reference ratio to the recyclable memory page. The startup duration threshold may be a preset experience value, and the startup duration thresholds of different applications may not be the same. For example, the corresponding startup duration threshold may be determined according to the normal startup duration of the corresponding application, and the normal startup duration may be 1.5 times or 2 times. The duration is used as the threshold for the start time. The reference scale represents a reference to the memory page recycling ratio. Based on the determined reference ratio, combined with the dependency ratio and the total number of reclaimable memory pages, determine the amount of recycling for recyclable memory pages. The amount of recycling is the amount of recycling to the memory page, which is a positive integer.
在一个实施例中,不同的应用类型的应用,其回收比例与二次启动时长之间的对应关系也不一定相同。该应用类型为根据对内存回收后,对待处理应用的运行影响而设置的类型。应用类型包括无关类、线性类以及非线性类。无关类表示对待处理应用的可回收内存回收后,无论回收多少,均对对应的应用并无显著影响。线性类表示随着对可回收内存的回收比例的 增多,对应的应用的二次启动时长也随之增加,其中该二次启动时长与回收比例之间呈线性或接近线性增长的关系。非线性类表示既非无关类也非线性类的其它类型。其中,无显著影响表示不同回收比例对应的二次启动时长相比正常启动时长的超出比例均小于预设的比例范围。接近线性表示不同回收比例按照对应接近的斜率拟合出的二次启动时长,与对应回收比例下的二次启动时长之间的误差不超过预设范围内的误差。In an embodiment, the correspondence between the recovery ratio and the secondary startup duration is not necessarily the same for applications of different application types. The application type is a type set according to the operational impact of the application to be processed after the memory is reclaimed. Application types include irrelevant classes, linear classes, and nonlinear classes. The irrelevant class indicates that after the reclaimable memory of the application to be processed is recycled, no matter how much it is recycled, it has no significant effect on the corresponding application. The linear class indicates that as the recovery ratio of recyclable memory increases, the secondary startup time of the corresponding application also increases, and the relationship between the secondary startup time and the recovery ratio is linear or nearly linear. Non-linear classes represent other types that are neither extraneous nor nonlinear. Among them, there is no significant influence that the ratio of the second startup time corresponding to different recovery ratios is smaller than the preset ratio range. The near linearity indicates that the difference between the second recovery time and the second startup time when the different recovery ratios are fitted according to the corresponding approximate slope does not exceed the error within the preset range.
举例来说,如图5A、5B至5C所示,分别为一个实施例中无关类、线性类和非线性类的应用的回收比例曲线。其中,该回收比例曲线中的横坐标表示回收比例,纵坐标表示处于对应回收比例下的二次启动时长。其中,无关类的回收比例曲线反映出了对应应用在可回收内存页在按不同的回收比例进行回收后,对应的二次启动时长没有变化或者变化很小。线性类的回收比例曲线在不同的回收比例下,对应的斜率没有变化或者变化很小,而非线性类的回收比例曲线则有的地方斜率较大,有的地方斜率相对较小。针对非线性类的应用,可选取最小斜率对应的回收比例,作为对可回收内存页的回收比例,即作为上述的参考比例。For example, as shown in FIGS. 5A, 5B to 5C, respectively, the recovery ratio curves of the applications of the irrelevant class, the linear class, and the nonlinear class in one embodiment. Wherein, the abscissa in the recovery ratio curve represents the recovery ratio, and the ordinate represents the secondary startup time in the corresponding recovery ratio. Among them, the irrelevant class recovery ratio curve reflects that the corresponding application in the recyclable memory page after the recovery according to different recycling ratios, the corresponding secondary startup time has no change or little change. The recovery ratio curve of the linear type has no change or small change in the corresponding recovery ratio, and the recovery ratio curve of the nonlinear type has a large slope, and the slope of some places is relatively small. For the application of the nonlinear class, the recovery ratio corresponding to the minimum slope can be selected as the recovery ratio of the recyclable memory page, that is, as the above reference ratio.
电子设备针对不同的应用,按照不同的回收比例回收内存后对应的二次启动时长,设置了该应用所属的应用类型,并设置与该应用类型对应的参考比例。根据该可回收内存页、依赖比例和参考比例确定对应的回收数量。进一步地,可根据该参考比例和依赖比例,确定对待处理应用占用的可回收内存页的回收比例,进而可将确定的回收比例与可回收内存页的总数相乘,计算的乘积作为回收数量。For different applications, the electronic device reclaims the corresponding secondary startup time according to different recycling ratios, sets the application type to which the application belongs, and sets a reference ratio corresponding to the application type. The corresponding amount of recycling is determined based on the recyclable memory page, the dependency ratio, and the reference ratio. Further, according to the reference ratio and the dependency ratio, the recycling ratio of the recyclable memory page occupied by the application to be processed may be determined, and the determined recycling ratio may be multiplied by the total number of recyclable memory pages, and the calculated product is used as the recycling quantity.
当该乘积数量不为整数时,可选取与该乘积近似的一个整数,比如可按照四舍五入的方式确定最接近的一个整数作为回收数量,或者还可按照截尾法或进位法等方式确定相应的整数作为回收数量。When the number of products is not an integer, an integer approximate to the product may be selected. For example, the nearest integer may be determined as a number of rounds according to rounding, or the corresponding method may be determined according to a truncation method or a carry method. An integer is used as the recycle quantity.
以按照四舍五入的方式确定可回收数量为例说明。比如,当可回收内存页有100页时,若回收比例为30.5%,得到的乘积为30.5,则可从该100页可回收内存页中回收31页,若回收比例为21.2%时,则可回收21页。The example of determining the recoverable quantity by rounding is taken as an example. For example, when there are 100 pages of recyclable memory pages, if the recycling ratio is 30.5% and the product is 30.5, 31 pages can be recovered from the 100-page recyclable memory page. If the recycling ratio is 21.2%, then Recycling 21 pages.
通过按照该二次启动时长来确定回收数量,进一步保持了对待处理应用内存的回收与运行之间的平衡性。By determining the amount of recycling according to the secondary startup time, the balance between the recycling and operation of the application memory to be processed is further maintained.
操作406,根据回收数量从每个可回收内存页的空闲时长中选取第K大的空闲时长,将选取的空闲时长作为时长阈值。In operation 406, the idle time length of the Kth largest is selected from the idle time of each recyclable memory page according to the quantity of the collection, and the selected idle time length is used as the duration threshold.
其中,超过第K大的空闲时长的数量为回收数量,K为不超过回收数量的自然数。电子设备可按照每个可回收内存页的空闲时长从大到小进行排序,并选取第K大的空闲时长,将该空闲时长作为时长阈值。其中,超过第K大的空闲时长的数量即为该回收数量。可以理解地,K为不超过回收数量的自然数。举例来说,可回收内存页的总数量有100,当确定的回收数量为50时,则K=51,可从该100个可回收内存页的空闲时长中,选取第51大的空闲时长,将该空闲时长作为时长阈值,并选取空闲时长超过该第51大的空闲时长的50个回收内存页进行回收。Among them, the number of idle periods exceeding the Kth largest is the number of collections, and K is a natural number that does not exceed the number of collections. The electronic device can sort the idle time of each recyclable memory page from large to small, and select the idle time of the Kth largest, and use the idle duration as the duration threshold. The number of idle periods exceeding the Kth largest is the amount of the collection. Understandably, K is a natural number that does not exceed the amount recovered. For example, the total number of recyclable memory pages is 100. When the determined number of reclaimed memories is 50, then K=51, and the 51st free idle duration can be selected from the idle duration of the 100 recyclable memory pages. The idle duration is used as the duration threshold, and 50 reclaimed memory pages whose idle duration exceeds the 51st largest idle duration are selected for recovery.
通过选取第K大的空闲时长作为时长阈值,提高了对可回收内存进行回收的灵活性。By choosing the Kth largest idle time as the duration threshold, the flexibility of recycling recyclable memory is improved.
在一个实施例中,操作302包括:查询待处理应用所占用的内存的所有内存页;从所有内存页中获取可回收内存页。In one embodiment, operation 302 includes querying all memory pages of memory occupied by the application to be processed; and obtaining recyclable memory pages from all memory pages.
可选地,电子设备可实时记录不同的应用所占用内存的内存页,并针对该每个被占用的内存页,进一步实时记录其是否可被回收。比如,当存在某一内存页中的数据正在被其它应用或者该待处理应用所使用时,则判定该内存页为不可回收的内存页,当记录到被占用的内存页中的数据处于无应用使用状态,或者处于该无应用使用状态的持续时长超过预设时长时,则判定该内存页为可回收内存页。Optionally, the electronic device can record the memory pages of the memory occupied by different applications in real time, and further record in real time whether the memory pages can be recycled for each occupied memory page. For example, when there is data in a certain memory page being used by another application or the application to be processed, it is determined that the memory page is a non-recyclable memory page, and when the data recorded in the occupied memory page is in no application. When the usage state, or the duration of the non-application use state exceeds the preset duration, the memory page is determined to be a reclaimable memory page.
针对待处理应用,可从预先记录的信息中查询其所占用所有的内存页,并根据所记录的每个内存页的使用状态,判定其是否为可回收内存页,然后获取所有的可回收内存页。For the pending application, all the memory pages occupied by the occupied information can be queried from the pre-recorded information, and according to the recorded usage status of each memory page, it is determined whether it is a recyclable memory page, and then all the recyclable memory is obtained. page.
在一个实施例中,查询待处理应用所占用的内存的所有内存页,包括:遍历待处理应用的内存映射文件;通过内存映射文件查询待处理应用占用的所有内存页。In one embodiment, querying all memory pages of the memory occupied by the application to be processed includes: traversing a memory mapped file of the to-be-processed application; and querying all memory pages occupied by the to-be-processed application through the memory mapped file.
内存映射文件(Memory-Mapped Files)是由一个文件到一块内存的映射。电子设备针对 该待处理应用建立了对应的内存映射文件,该内存映射文件中设置了对应的应用所占用的内存页,通过遍历该待处理应用对应的内存映射文件,并从每个遍历到的内存映射文件中读取该待处理应用占用的内存页,从而可获取到该待处理应用所占用的所有的内存页,提高了对待处理应用占用的内存页的查询效率和查询的全面性。Memory-Mapped Files are mappings from one file to one memory. The electronic device establishes a corresponding memory mapping file for the to-be-processed application, and the memory mapping file stores a memory page occupied by the corresponding application, by traversing the memory mapping file corresponding to the to-be-processed application, and traversing from each The memory map file is used to read the memory page occupied by the to-be-processed application, so that all the memory pages occupied by the to-be-processed application can be obtained, and the query efficiency and the comprehensiveness of the query of the memory page occupied by the application to be processed are improved.
在一个实施例中,从所有内存页中获取可回收内存页,包括:从所有内存页中剔除携带占用标记的内存页;从剔除后的内存页中获取可回收内存页。In one embodiment, the reclaimable memory page is obtained from all of the memory pages, including: removing the memory page carrying the occupied mark from all the memory pages; and obtaining the recyclable memory page from the rejected memory page.
其中,针对查询出的被待处理应用所占用的所有的内存页,电子设备可检测每个查询出的内存页是否携带有占用标记,或者是否被多个应用所占用。其中,占用标记表示对应的内存页中存储的数据正处于对待处理应用所使用,或者是其中的数据是待处理应用在保持正常运行的过程中,不可缺少的数据,当该数据被删除后,待处理应用要么无法正常运行,或者需要反复占用新的内存页来存放对应的数据,针对检测出的这类数据,电子设备可对存储该类数据的内存页而设置占用标记,以表示对应的内存页不能回收。The electronic device can detect whether each of the queried memory pages carries an occupation mark or is occupied by multiple applications, for all the memory pages occupied by the queried application. The occupancy mark indicates that the data stored in the corresponding memory page is being used by the application to be processed, or the data therein is indispensable data in the process of the pending application being kept in normal operation, and when the data is deleted, The pending application may not be able to run normally, or it may need to repeatedly occupy a new memory page to store corresponding data. For such detected data, the electronic device may set an occupancy flag on the memory page storing the data to indicate the corresponding Memory pages cannot be recycled.
被待处理应用占用的内存页中,其中存储的数据还可能被其它应用所使用,即有多个应用均在使用该内存页中的数据,针对该类内存页,也可将其设置占用标记,使电子设备同样将其剔除,以表示不从该类内存页中进行回收。The memory page occupied by the application to be processed, the data stored therein may also be used by other applications, that is, multiple applications are using the data in the memory page, and the memory page may also be set to occupy the mark. , so that the electronic device also culls it to indicate that it is not recycled from the memory page.
针对剔除后的内存页,保留下来的内存页即为可回收内存页,电子设备可从该内存页中进行内存回收。For the culled memory page, the reserved memory page is a recyclable memory page from which the electronic device can perform memory reclamation.
在一个实施例中,电子设备可调用如图2中所示的资源优先级和限制管理模块222来遍历待处理应用的内存映射文件;通过内存映射文件查询待处理应用占用的所有内存页,并通过该资源优先级和限制管理模块222检测每个内存页是否为可回收内存页,对于不可回收内存页设置对应的占用标记,同时记录每个内存页是否还多个应用所占用,从查询出的所有内存页中剔除携带占用标记和/或被多个应用占用的内存页;从剔除后的内存页中获取可回收内存页。In an embodiment, the electronic device may invoke the resource priority and restriction management module 222 as shown in FIG. 2 to traverse the memory mapped file of the to-be-processed application; query all memory pages occupied by the to-be-processed application through the memory-mapped file, and The resource priority and limit management module 222 detects whether each memory page is a reclaimable memory page, sets a corresponding occupation mark for the non-recyclable memory page, and records whether each memory page is occupied by multiple applications, and queries from the query. All memory pages are excluded from carrying memory tags and/or memory pages occupied by multiple applications; retrievable memory pages are obtained from the rejected memory pages.
在一个实施例中,上述方法还包括:当待处理应用与前台应用之间存在通信机制或同步机制时,判定待处理应用被前台应用依赖。In an embodiment, the method further includes: determining that the to-be-processed application is dependent on the foreground application when there is a communication mechanism or a synchronization mechanism between the to-be-processed application and the foreground application.
在一个实施例中,当待处理应用与前台应用之间存在socket通信、binder通信、内存共享或锁等待时,判定后台进程与前台应用之间存在通信机制。In one embodiment, when there is socket communication, binder communication, memory sharing or lock waiting between the to-be-processed application and the foreground application, it is determined that there is a communication mechanism between the background process and the foreground application.
可通过以下任意一种或几种方式检测是否存在与前台应用具有通信机制的后台进程:You can detect whether there is a background process that has communication mechanism with the foreground application by any one or several of the following methods:
(1)检测是否存在与前台应用具有socket和/或binder通信的后台进程;(1) detecting whether there is a background process that has socket and/or binder communication with the foreground application;
(2)检测是否存在与前台应用之间进行内存共享的后台进程;(2) detecting whether there is a background process for memory sharing with the foreground application;
(3)检测是否存在前台应用等待在锁资源上的后台进程。(3) Detect whether there is a background process waiting for the foreground application to wait on the lock resource.
电子设备可在Binder驱动中设置对前台应用和后台进程之间是否存在Binder通信的检测机制,并调用在Binder驱动中设置的检测机制,以检测出与前台应用存在Binder通信的后台进程,将检测出的后台进程判定为被前台应用依赖的后台进程。The electronic device can set a detection mechanism for the Binder communication between the foreground application and the background process in the Binder driver, and call the detection mechanism set in the Binder driver to detect the background process that the Binder communication exists with the foreground application, and the detection will be detected. The background process is determined to be a background process that is dependent on the foreground application.
在一个实施例中,电子设备可检测各个锁资源,锁资源包括线程锁,文件句柄,信号等。针对每个锁资源,可检测是否发生锁等待,即锁资源等待。当检测到产生锁等待时,可进一步检测该发生等待的行为是否发生在前台应用上。若是,则遍历等待在该锁资源上面的所有后台进程,将检测到的等待在该锁资源上的后台进程均判定为被前台应用依赖的后台进程。In one embodiment, the electronic device can detect individual lock resources, including thread locks, file handles, signals, and the like. For each lock resource, it can be detected whether a lock wait occurs, that is, the lock resource waits. When it is detected that a lock wait is generated, it may be further detected whether the behavior of the occurrence of the wait occurs on the foreground application. If so, all the background processes waiting for the lock resource are traversed, and the detected background processes waiting on the lock resource are all determined to be background processes that are depended by the foreground application.
在一个实施例中,电子设备可在操作系统的内核空间中设置锁资源监控模块和优先级调整模块,将锁资源监控模块内嵌到内核原生的等待接口当中。通过该锁资源监控模块,检测线程锁,文件句柄,信号等锁各种锁资源,是否发生等待,发生等待的行为是否是发生在前台应用上面,如果是发生在前台任务上面,则将检测到的消息发送至优先级调整模块。通过该优先级调整遍历等待在该锁资源上面的所有后台线程,将这些后台进程判定为被前台应用依赖的后台进程。In one embodiment, the electronic device may set a lock resource monitoring module and a priority adjustment module in a kernel space of the operating system, and embed the lock resource monitoring module into the kernel's native waiting interface. Through the lock resource monitoring module, detecting thread locks, file handles, signals, etc. lock various lock resources, whether a wait occurs, whether the waiting behavior occurs in the foreground application, and if it occurs on the foreground task, it will detect The message is sent to the priority adjustment module. Through the priority adjustment, all the background threads waiting for the lock resource are traversed, and these background processes are determined as the background processes that are depended by the foreground application.
在一个实施例中,当后台进程与前台应用之间存在同步机制时,判定具有同步机制的待处理应用为被前台应用依赖的后台进程。In an embodiment, when there is a synchronization mechanism between the background process and the foreground application, it is determined that the to-be-processed application with the synchronization mechanism is a background process that is dependent on the foreground application.
电子设备还可通过调用futex系统调用检测后台进程集合中,是否存在与前台应用具有同步机制的后台进程,将具有同步机制的后台进程判定为被前台应用依赖的后台进程。The electronic device can also detect the background process in the background process set by calling the futex system call, whether there is a background process having a synchronization mechanism with the foreground application, and determine the background process with the synchronization mechanism as the background process that is depended by the foreground application.
并发程序设计中,各进程对公共变量的访问必须加以制约,这种制约称为同步。在操作系统中,用户态(user mode)的同步机制可通过调用futex系统调用实现。其中,用户态指非特权状态。同步机制包括信号量、互斥锁等。当通过futex系统调用检测到与前台应用存在任意一种同步机制的后台进程时,可将检测到的后台进程判定为被前台应用依赖的后台进程。In concurrent programming, access to public variables must be restricted by each process. This constraint is called synchronization. In the operating system, the user mode synchronization mechanism can be implemented by calling the futex system call. Among them, the user state refers to the non-privileged state. Synchronization mechanisms include semaphores, mutex locks, and more. When a background process that detects any kind of synchronization mechanism with the foreground application is detected by the futex system call, the detected background process may be determined as a background process that is dependent on the foreground application.
通过对前台应用和后台进程之间的通信机制和/或同步机制的检测,将检测出的与前台应用具有通信机制和/或同步机制的后台进程判定为被前台应用依赖的后台进程,可提高对被前台应用依赖的待处理应用的检测的效率。By detecting the communication mechanism and/or the synchronization mechanism between the foreground application and the background process, the detected background process having the communication mechanism and/or the synchronization mechanism with the foreground application is determined to be a background process dependent on the foreground application, which can be improved. The efficiency of detection of pending applications that are relied upon by the foreground application.
在一个实施例中,如图6所示,提供了另一种内存处理方法,该方法包括:In one embodiment, as shown in FIG. 6, another memory processing method is provided, the method comprising:
操作602,遍历待处理应用的内存映射文件;通过内存映射文件查询待处理应用占用的所有内存页。Operation 602: traverse the memory mapped file of the to-be-processed application; query all memory pages occupied by the to-be-processed application through the memory-mapped file.
在一个实施例中,电子设备可在检测到系统的内存使用率超过预设比例时,或者接收到用户操作而触发的内存回收指令时,触发对内存回收机制,并从所有运行中的应用中确定需要进行内存回收的应用,所确定的应用即为该待处理应用。In one embodiment, the electronic device may trigger a memory reclamation mechanism when detecting that the memory usage of the system exceeds a preset ratio or receiving a memory reclamation instruction triggered by a user operation, and from all running applications. Identify the application that needs to be recycled, and the determined application is the pending application.
在一个实施例中,电子设备可在检测到某一应用从前台切换到后台后,且通过平台冻结管理模块224将该应用设置成进程深度冻结模式后,触发对该应用的内存回收机制。In one embodiment, the electronic device may trigger a memory reclamation mechanism for the application after detecting that an application is switched from the foreground to the background and the platform freeze management module 224 sets the application to the process deep freeze mode.
电子设备可通过上述的资源优先级和限制管理模块222来遍历该待处理应用的内存映射文件,从遍历到的每个内存映射文件中查询被待处理应用占用的内存页,从而可查询出该待处理应用占用的所有内存页。The electronic device can traverse the memory mapping file of the to-be-processed application by using the resource priority and restriction management module 222, and query the memory page occupied by the application to be processed from each memory mapping file traversed, so that the memory can be queried. All memory pages occupied by the pending application.
操作604,从所有内存页中剔除携带占用标记的内存页;从剔除后的内存页中获取可回收内存页。Operation 604, the memory page carrying the occupied mark is removed from all the memory pages; and the reclaimable memory page is obtained from the rejected memory page.
针对每个查询出的内存页,可进行二次遍历,二次遍历用于检测每个查询出的内存页是否为可回收内存页,当检测出携带有占用标记的内存页,则判定该内存页为不可回收内存页,并将该内存页进行剔除,经二次遍历后得到的内存页即为可回收内存页,电子设备可从该所有可回收内存页中选取内存页进行回收。通过二次遍历,可提高对可回收内存页检测的全面性。For each memory page that is queried, a second traversal can be performed, and the second traversal is used to detect whether each of the queried memory pages is a recyclable memory page, and when the memory page carrying the occupied mark is detected, the memory is determined. The page is a non-recyclable memory page, and the memory page is culled. The memory page obtained after the second traversal is a recyclable memory page, and the electronic device can select a memory page from all the recyclable memory pages for recycling. Through the second traversal, the comprehensiveness of the detection of recyclable memory pages can be improved.
操作606,检测每个可回收内存页中存储的数据是否被前台应用依赖;根据检测结果确定待处理应用被前台应用依赖的依赖比例。Operation 606: Detect whether data stored in each recyclable memory page is dependent on the foreground application; and determine, according to the detection result, a proportion of dependencies that the to-be-processed application is dependent on by the foreground application.
其中,当待处理应用与前台应用之间存在通信机制或同步机制时,判定待处理应用被前台应用依赖,并检测该前台应用具体依赖的是哪些可回收内存页中存储的数据,根据该检测结果确定依赖比例。检测结果包括内存页未被前台应用依赖或被前台应用依赖。依赖比例可为被前台应用所依赖的可回收内存页的依赖总数与客户收内存页的总数之比。当待处理应用不被前台应用依赖时,则该依赖比例为0。Wherein, when there is a communication mechanism or a synchronization mechanism between the to-be-processed application and the foreground application, it is determined that the to-be-processed application is dependent on the foreground application, and detecting which reclaimable memory pages are specifically dependent on the foreground application, according to the detection The result determines the dependency ratio. The detection results include that the memory page is not dependent on the foreground application or is dependent on the foreground application. The dependency ratio can be the ratio of the total number of dependencies of the reclaimable memory pages that the foreground application depends on to the total number of pages that the client receives. When the pending application is not dependent on the foreground application, the dependency ratio is zero.
针对检测出的被应用依赖的内存页,可为该内存页设置对应的依赖标识,使得根据该依赖标识可获知对应内存页被哪些具体的应用所依赖。进而根据每个可回收内存页是否被设置对应的依赖标识,以及该依赖标识是否是表示被前台应用所依赖,从而可计算出待处理应用被前台应用依赖的依赖比例。在一个实施例中,可根据该预设时间段来确定对应依赖标识的有效性,当处于对应预设时间段之内时,保持所设置的依赖标识有效,处于预设时间段之外时,可取消所设置的依赖标识。通过设置依赖标识,使得可提高计算出依赖比例的效率。For the detected memory page that is dependent on the application, a corresponding dependency identifier may be set for the memory page, so that according to the dependency identifier, it is known which specific applications the corresponding memory page is dependent on. Further, according to whether each recyclable memory page is set with a corresponding dependency identifier, and whether the dependency identifier is represented by the foreground application, the proportion of dependencies that the to-be-processed application is dependent on by the foreground application can be calculated. In an embodiment, the validity of the corresponding dependency identifier may be determined according to the preset time period, and when the preset dependency period is within the corresponding preset time period, the set dependency identifier is kept valid, when the preset time period is outside, The set dependency ID can be canceled. By setting the dependency identifier, the efficiency of calculating the dependency ratio can be improved.
操作608,获取待处理应用对每个可回收内存页的空闲时长。 Operation 608, obtaining the idle duration of the unprocessable memory page of the to-be-processed application.
在一个实施例中,可获取每个可回收内存页的时间戳记录的更新时间,根据更新时间计算出对应可回收内存页的空闲时长。In one embodiment, the update time of the timestamp record of each recyclable memory page may be obtained, and the idle duration of the corresponding recyclable memory page is calculated according to the update time.
在一个实施例中,还可获取通过最近最久未使用LRU管理单元记录的每个可回收内存页的更新时间,根据更新时间计算出对应可回收内存页的空闲时长。In one embodiment, the update time of each recyclable memory page recorded by the most recently unused LRU management unit may also be obtained, and the idle duration corresponding to the recyclable memory page is calculated according to the update time.
操作610,根据每个可回收内存页的空闲时长和依赖比例确定时长阈值。 Operation 610, determining a duration threshold based on the idle duration and the dependency ratio of each recyclable memory page.
在一个实施例中,根据每个可回收内存页的空闲时长计算出待处理应用对可回收内存页的平均空闲时长;根据平均空闲时长与依赖比例确定时长阈值。In one embodiment, the average idle duration of the to-be-processed application for the reclaimable memory page is calculated according to the idle duration of each recyclable memory page; and the duration threshold is determined according to the average idle duration and the dependency ratio.
在一个实施例中,还可根据获取与待处理应用对应的回收比例与二次启动时长之间的对应关系,并根据该依赖比例和对应关系来确定对内存页的回收数量;然后根据回收数量从可回收内存页的空闲时长中选取第K大的空闲时长,将选取的空闲时长作为时长阈值;超过第K大的空闲时长的数量为回收数量,K为不超过回收数量的自然数。In an embodiment, the correspondence between the recovery ratio corresponding to the application to be processed and the secondary startup duration may be obtained, and the amount of recovery of the memory page may be determined according to the dependency ratio and the correspondence relationship; The idle duration of the Kth largest is selected from the idle duration of the recyclable memory page, and the selected idle duration is taken as the duration threshold; the number of idle durations exceeding the Kth largest is the recovered quantity, and K is the natural number that does not exceed the collected quantity.
操作612,从可回收内存页中选取空闲时长超过时长阈值的、未被前台应用依赖的内存页进行回收。At operation 612, a memory page whose idle time exceeds a duration threshold and is not dependent on the foreground application is selected from the reclaimable memory page for recycling.
进一步地,可从未被前台应用依赖的内存页中选取第K大的空闲时长作为时长阈值。该未被前台应用依赖的内存页中,超过第K大的空闲时长的数量为回收数量。也就是说,仅对未被前台应用依赖的内存页中进行空闲时长的排序和选取。通过从未被前台应用依赖的内存页进行回收,可进一步降低对前台应用的影响。Further, the Kth largest idle time may be selected from the memory pages not depended by the foreground application as the duration threshold. In the memory page that is not dependent on the foreground application, the number of idle times exceeding the Kth largest is the number of recycles. That is to say, only the idle time is sorted and selected in the memory pages that are not dependent on the foreground application. The impact on the foreground application can be further reduced by reclaiming memory pages that are not dependent on the foreground application.
应该理解的是,虽然图3、图4和图6的流程图中的各个操作按照箭头的指示依次显示,但是这些操作并不是必然按照箭头指示的顺序依次执行。除非本文中有明确的说明,这些操作的执行并没有严格的顺序限制,这些操作可以以其它的顺序执行。而且,图3、图4和图6中的至少一部分操作可以包括多个子操作或者多个阶段,这些子操作或者阶段并不必然是在同一时刻执行完成,而是可以在不同的时刻执行,这些子操作或者阶段的执行顺序也不必然是依次进行,而是可以与其它操作或者其它操作的子操作或者阶段的至少一部分轮流或者交替地执行。It should be understood that although the operations in the flowcharts of FIGS. 3, 4, and 6 are sequentially displayed in accordance with the indication of the arrows, these operations are not necessarily performed in the order indicated by the arrows. Except as explicitly stated herein, the execution of these operations is not strictly limited, and the operations may be performed in other sequences. Moreover, at least some of the operations in FIGS. 3, 4, and 6 may include multiple sub-operations or multiple stages, which are not necessarily performed at the same time, but may be executed at different times. The order of execution of sub-operations or stages is not necessarily performed sequentially, but may be performed alternately or alternately with at least a portion of sub-operations or stages of other operations or other operations.
在一个实施例中,如图7所示,提供了一种内存处理装置,该装置包括:内存页获取模块702、依赖确定模块704、时长确定模块706和内存回收模块708。其中,内存页获取模块702用于获取待处理应用所占用的可回收内存页;依赖确定模块704用于获取待处理应用被前台应用依赖的依赖比例;时长确定模块706用于获取待处理应用对每个可回收内存页的空闲时长;根据每个可回收内存页的空闲时长和依赖比例确定时长阈值;内存回收模块708用于从可回收内存页中选取空闲时长超过时长阈值的内存页进行回收。In one embodiment, as shown in FIG. 7, an in-memory processing device is provided. The device includes a memory page acquisition module 702, a dependency determination module 704, a duration determination module 706, and a memory recovery module 708. The memory page obtaining module 702 is configured to obtain a reclaimable memory page occupied by the to-be-processed application; the dependency determining module 704 is configured to obtain a dependency ratio of the to-be-processed application that is dependent on the foreground application; and the duration determining module 706 is configured to obtain the to-be-processed application pair. The idle time of each recyclable memory page; the duration threshold is determined according to the idle duration and the dependency ratio of each recyclable memory page; the memory reclamation module 708 is configured to select a memory page whose idle time exceeds the duration threshold from the reclaimable memory page for recycling .
在一个实施例中,内存页获取模块702还用于查询待处理应用所占用的内存的所有内存页;从所有内存页中剔除携带占用标记的内存页;从剔除后的内存页中获取可回收内存页。In one embodiment, the memory page obtaining module 702 is further configured to query all memory pages of the memory occupied by the application to be processed; the memory page carrying the occupied mark is removed from all the memory pages; and the reclaimable memory page is retrievable Memory page.
在一个实施例中,内存页获取模块702还用于遍历待处理应用的内存映射文件;通过内存映射文件查询待处理应用占用的所有内存页。In one embodiment, the memory page obtaining module 702 is further configured to traverse a memory mapped file of the to-be-processed application; and query all memory pages occupied by the to-be-processed application through the memory mapped file.
在一个实施例中,依赖确定模块704还用于检测每个可回收内存页中存储的数据是否被前台应用依赖;根据检测结果确定待处理应用被前台应用依赖的依赖比例;检测结果包括内存页未被前台应用依赖或被前台应用依赖。In one embodiment, the dependency determination module 704 is further configured to detect whether data stored in each recyclable memory page is dependent on the foreground application; determining, according to the detection result, a dependency ratio of the to-be-processed application being dependent on the foreground application; the detection result includes the memory page Not dependent on the foreground application or dependent on the foreground application.
内存回收模块708用于从可回收内存页中选取空闲时长超过时长阈值的、未被前台应用依赖的内存页进行回收。The memory reclamation module 708 is configured to select, from the reclaimable memory page, a memory page whose idle time exceeds a duration threshold and is not dependent on the foreground application for recycling.
在一个实施例中,时长确定模块706还用于获取每个可回收内存页的时间戳记录的更新时间,根据更新时间计算出对应可回收内存页的空闲时长。In one embodiment, the duration determining module 706 is further configured to obtain an update time of the time stamp record of each recyclable memory page, and calculate an idle duration corresponding to the recyclable memory page according to the update time.
在一个实施例中,时长确定模块706还用于获取通过最近最久未使用LRU管理单元记录的每个可回收内存页的更新时间,根据更新时间计算出对应可回收内存页的空闲时长。In one embodiment, the duration determining module 706 is further configured to obtain an update time of each recyclable memory page recorded by the most recently unused LRU management unit, and calculate an idle duration corresponding to the recyclable memory page according to the update time.
在一个实施例中,时长确定模块706还用于根据每个可回收内存页的空闲时长计算出待处理应用对可回收内存页的平均空闲时长;根据平均空闲时长与依赖比例确定时长阈值。In one embodiment, the duration determining module 706 is further configured to calculate an average idle duration of the to-be-processed application for the reclaimable memory page according to the idle duration of each recyclable memory page; and determine a duration threshold according to the average idle duration and the dependency ratio.
在一个实施例中,时长确定模块706还用于获取与待处理应用对应的回收比例与二次启动时长之间的对应关系;二次启动时长是指待处理应用占用的可回收内存页被回收对应的回收比例后,再次启动时所花费的时长;根据依赖比例和可回收内存页和回收比例与二次启动时长之间的对应关系确定内存页的回收数量;根据回收数量从每个可回收内存页的空闲时长中选取第K大的空闲时长,将选取的空闲时长作为时长阈值;超过第K大的空闲时长的数量为回收数量,K为不超过回收数量的自然数。In an embodiment, the duration determining module 706 is further configured to obtain a correspondence between a recycling ratio corresponding to the to-be-processed application and a secondary startup duration; the secondary startup duration refers to that the reclaimable memory page occupied by the to-be-processed application is recycled. The time taken to start again after the corresponding recovery ratio; determine the amount of memory page reclaimed according to the dependence ratio and the correspondence between the recyclable memory page and the recycling ratio and the secondary startup time; The idle time length of the Kth page is selected as the idle time length of the memory page, and the selected idle time length is used as the duration threshold; the number of idle time exceeding the Kth largest is the recovery quantity, and K is the natural number not exceeding the recovery quantity.
在一个实施例中,依赖确定模块704还用于当待处理应用与前台应用之间存在通信机制或同步机制时,判定待处理应用被前台应用依赖。In one embodiment, the dependency determination module 704 is further configured to determine that the to-be-processed application is dependent on the foreground application when there is a communication mechanism or a synchronization mechanism between the to-be-processed application and the foreground application.
上述的内存处理装置,通过获取待处理应用所占用的可回收内存页及其空闲时长,并获取待处理应用被前台应用依赖的依赖比例,然后根据该空闲时长和依赖比例来确定时长阈值,并对空闲时长超过时长阈值的内存页进行回收,由于回收的对象是可回收内存页,且并非一定是对所有可回收内存页均进行回收,而是按照与每个可回收内存页的空闲时长以及待处理应用被前台应用依赖的依赖比例,选取空闲时长超过相应的时长阈值的内存页进行回收,进一步降低了对待处理应用和前台应用的运行影响,且回收的内存页可释放出来供其它应用使用,保证在整个系统内存变大的情况下,对每个应用的负面影响最小,又提高了内存使用效率,保持了对待处理应用内存的回收与运行之间的平衡性。The memory processing device obtains a reclaimable memory page occupied by the application to be processed and an idle duration thereof, and obtains a dependency ratio of the to-be-processed application that is dependent on the foreground application, and then determines a duration threshold according to the idle duration and the dependency ratio, and Reclaiming a memory page whose idle time exceeds the duration threshold, because the object being reclaimed is a reclaimable memory page, and it is not necessarily all the recyclable memory pages are reclaimed, but the idle time of each recyclable memory page and The pending application depends on the proportion of dependencies that the foreground application depends on, and the memory pages whose idle time exceeds the corresponding duration threshold are selected for recycling, thereby further reducing the operational impact of the application to be processed and the foreground application, and the reclaimed memory pages can be released for use by other applications. To ensure that the negative impact of each application is minimized, the memory usage efficiency is improved, and the balance between the recycling and operation of the application memory to be processed is maintained.
上述内存处理装置中各个模块的划分仅用于举例说明,在其他实施例中,可将内存处理装置按照需要划分为不同的模块,以完成上述内存处理装置的全部或部分功能。The division of each module in the above memory processing device is for illustrative purposes only. In other embodiments, the memory processing device may be divided into different modules as needed to complete all or part of the functions of the memory processing device.
关于内存处理装置的具体限定可以参见上文中对于内存处理方法的限定,在此不再赘述。上述内存处理装置中的各个模块可全部或部分通过软件、硬件及其组合来实现。上述各模块可以硬件形式内嵌于或独立于电子设备中的处理器中,也可以以软件形式存储于电子设备中的存储器中,以便于处理器调用执行以上各个模块对应的操作。For the specific definition of the memory processing device, reference may be made to the definition of the memory processing method in the above, and details are not described herein again. Each of the above-described memory processing devices may be implemented in whole or in part by software, hardware, and combinations thereof. Each of the above modules may be embedded in or independent of the processor in the electronic device, or may be stored in a memory in the electronic device in a software format, so that the processor calls to perform operations corresponding to the above modules.
本申请实施例中提供的内存处理装置中的各个模块的实现可为计算机程序的形式。该计算机程序可在终端或服务器等电子设备上运行。该计算机程序构成的程序模块可存储在电子设备的存储器上。该计算机程序被处理器执行时,实现本申请实施例中所描述的内存处理方法的操作。The implementation of each module in the memory processing device provided in the embodiments of the present application may be in the form of a computer program. The computer program can run on an electronic device such as a terminal or a server. The program module of the computer program can be stored on a memory of the electronic device. When the computer program is executed by the processor, the operation of the memory processing method described in the embodiment of the present application is implemented.
在一个实施例中,提供了一种电子设备,包括存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,处理器执行计算机程序时实现上述各实施例所提供的内存处理方法的操作。In one embodiment, an electronic device is provided, including a memory, a processor, and a computer program stored on the memory and executable on the processor, the memory processing provided by the above embodiments being implemented when the processor executes the computer program The operation of the method.
在一个实施例中,还提供了一种计算机可读存储介质,该计算机可读存储介质上存储有计算机程序,该计算机程序对处理器执行时,实现本申请各实施例中所描述的内存处理方法的操作。In one embodiment, there is also provided a computer readable storage medium having stored thereon a computer program for performing memory processing as described in various embodiments of the present application when executed by a processor The operation of the method.
在一个实施例中,提供了一种包含指令的计算机程序产品,当其在计算机上运行时,使得计算机执行本申请各实施例中所描述的内存处理方法。In one embodiment, a computer program product comprising instructions, when executed on a computer, causes the computer to perform the memory processing methods described in various embodiments of the present application.
本申请实施例还提供了一种计算机设备。如图8所示,为了便于说明,仅示出了与本申请实施例相关的部分,具体技术细节未揭示的,请参照本申请实施例方法部分。该计算机设备可以为包括手机、平板电脑、PDA(Personal Digital Assistant,个人数字助理)、POS(Point of Sales,销售终端)、车载电脑、穿戴式设备等任意终端设备,以计算机设备为手机为例:The embodiment of the present application also provides a computer device. As shown in FIG. 8 , for the convenience of description, only the parts related to the embodiments of the present application are shown. For details that are not disclosed, refer to the method part of the embodiment of the present application. The computer device may be any terminal device including a mobile phone, a tablet computer, a PDA (Personal Digital Assistant), a POS (Point of Sales), a vehicle-mounted computer, a wearable device, and the like, taking a computer device as a mobile phone as an example. :
图8为与本申请实施例提供的计算机设备相关的手机的部分结构的框图。参考图8,手机包括:射频(Radio Frequency,RF)电路810、存储器820、输入单元830、显示单元840、传感器850、音频电路860、无线保真(wireless fidelity,WiFi)模块870、处理器880、以及电源890等部件。本领域技术人员可以理解,图8所示的手机结构并不构成对手机的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置。FIG. 8 is a block diagram showing a part of a structure of a mobile phone related to a computer device according to an embodiment of the present application. Referring to FIG. 8, the mobile phone includes: a radio frequency (RF) circuit 810, a memory 820, an input unit 830, a display unit 840, a sensor 850, an audio circuit 860, a wireless fidelity (WiFi) module 870, and a processor 880. And power supply 890 and other components. It will be understood by those skilled in the art that the structure of the mobile phone shown in FIG. 8 does not constitute a limitation to the mobile phone, and may include more or less components than those illustrated, or a combination of certain components, or different component arrangements.
其中,RF电路810可用于收发信息或通话过程中,信号的接收和发送,可将基站的下行信息接收后,给处理器880处理;也可以将上行的数据发送给基站。通常,RF电路包括但不限于天线、至少一个放大器、收发信机、耦合器、低噪声放大器(Low Noise Amplifier,LNA)、双工器等。此外,RF电路810还可以通过无线通信与网络和其他设备通信。上述无线通信可以使用任一通信标准或协议,包括但不限于全球移动通讯系统(Global System of Mobile communication,GSM)、通用分组无线服务(General Packet Radio Service,GPRS)、码分多址(Code Division Multiple Access,CDMA)、宽带码分多址(Wideband Code Division Multiple Access,WCDMA)、长期演进(Long Term Evolution,LTE))、电子邮件、短消息服务(Short Messaging Service,SMS)等。The RF circuit 810 can be used for receiving and transmitting information during the transmission or reception of information, and can receive and send the downlink information of the base station, and then send the uplink data to the base station. Generally, RF circuits include, but are not limited to, an antenna, at least one amplifier, a transceiver, a coupler, a Low Noise Amplifier (LNA), a duplexer, and the like. In addition, RF circuitry 810 can also communicate with the network and other devices via wireless communication. The above wireless communication may use any communication standard or protocol, including but not limited to Global System of Mobile communication (GSM), General Packet Radio Service (GPRS), Code Division Multiple Access (Code Division). Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Long Term Evolution (LTE), e-mail, Short Messaging Service (SMS), and the like.
存储器820可用于存储软件程序以及模块,处理器880通过运行存储在存储器820的软件程序以及模块,从而执行手机的各种功能应用以及数据处理。存储器820可主要包括程序存储区和数据存储区,其中,程序存储区可存储操作系统、至少一个功能所需的应用程序(比如声音播放功能的应用程序、图像播放功能的应用程序等)等;数据存储区可存储根据手机的使用所创建的数据(比如音频数据、通讯录等)等。此外,存储器820可以包括高速随机存取存储器,还可以包括非易失性存储器,例如至少一个磁盘存储器件、闪存器件、或其他易失性固态存储器件。The memory 820 can be used to store software programs and modules, and the processor 880 executes various functional applications and data processing of the mobile phone by running software programs and modules stored in the memory 820. The memory 820 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function (such as an application of a sound playing function, an application of an image playing function, etc.); The data storage area can store data (such as audio data, address book, etc.) created according to the use of the mobile phone. Moreover, memory 820 can include high speed random access memory, and can also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid state storage device.
输入单元830可用于接收输入的数字或字符信息,以及产生与手机800的用户设置以及功能控制有关的键信号输入。具体地,输入单元830可包括触控面板831以及其他输入设备832。触控面板831,也可称为触摸屏,可收集用户在其上或附近的触摸操作(比如用户使用手指、触笔等任何适合的物体或附件在触控面板831上或在触控面板831附近的操作),并根据预先设定的程式驱动相应的连接装置。在一个实施例中,触控面板831可包括触摸检测装置和触摸控制器两个部分。其中,触摸检测装置检测用户的触摸方位,并检测触摸操作带来的信号,将信号传送给触摸控制器;触摸控制器从触摸检测装置上接收触摸信息,并将它转换成触点坐标,再送给处理器880,并能接收处理器880发来的命令并加以执行。此外,可以采用电阻式、电容式、红外线以及表面声波等多种类型实现触控面板831。除了触控面板831,输入单元830还可以包括其他输入设备832。具体地,其他输入设备832可以包括但不限于物理键盘、功能键(比如音量控制按键、开关按键等)等中的一种或多种。The input unit 830 can be configured to receive input numeric or character information and to generate key signal inputs related to user settings and function control of the handset 800. Specifically, the input unit 830 may include a touch panel 831 and other input devices 832. The touch panel 831, also referred to as a touch screen, can collect touch operations on or near the user (such as the user using a finger, a stylus, or the like on the touch panel 831 or near the touch panel 831. Operation) and drive the corresponding connection device according to a preset program. In one embodiment, the touch panel 831 can include two portions of a touch detection device and a touch controller. Wherein, 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 880 is provided and can receive commands from the processor 880 and execute them. In addition, the touch panel 831 can be implemented in various types such as resistive, capacitive, infrared, and surface acoustic waves. In addition to the touch panel 831, the input unit 830 may also include other input devices 832. In particular, other input devices 832 may include, but are not limited to, one or more of a physical keyboard, function keys (such as volume control buttons, switch buttons, etc.).
显示单元840可用于显示由用户输入的信息或提供给用户的信息以及手机的各种菜单。显示单元840可包括显示面板841。在一个实施例中,可以采用液晶显示器(Liquid Crystal Display,LCD)、有机发光二极管(Organic Light-Emitting Diode,OLED)等形式来配置显示面板841。在一个实施例中,触控面板831可覆盖显示面板841,当触控面板831检测到在其上或附近的触摸操作后,传送给处理器880以确定触摸事件的类型,随后处理器880根据触摸事件的类型在显示面板841上提供相应的视觉输出。虽然在图8中,触控面板831与显示面板841是作为两个独立的部件来实现手机的输入和输入功能,但是在某些实施例中,可以将触控面板831与显示面板841集成而实现手机的输入和输出功能。The display unit 840 can be used to display information input by the user or information provided to the user as well as various menus of the mobile phone. The display unit 840 can include a display panel 841. In one embodiment, the display panel 841 can be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), or the like. In one embodiment, the touch panel 831 can cover the display panel 841. When the touch panel 831 detects a touch operation thereon or nearby, the touch panel 831 transmits to the processor 880 to determine the type of the touch event, and then the processor 880 is The type of touch event provides a corresponding visual output on display panel 841. Although in FIG. 8, the touch panel 831 and the display panel 841 are two independent components to implement the input and input functions of the mobile phone, in some embodiments, the touch panel 831 can be integrated with the display panel 841. Realize the input and output functions of the phone.
手机800还可包括至少一种传感器850,比如光传感器、运动传感器以及其他传感器。具体地,光传感器可包括环境光传感器及接近传感器,其中,环境光传感器可根据环境光线的明暗来调节显示面板841的亮度,接近传感器可在手机移动到耳边时,关闭显示面板841和/或背光。运动传感器可包括加速度传感器,通过加速度传感器可检测各个方向上加速度的大小,静止时可检测出重力的大小及方向,可用于识别手机姿态的应用(比如横竖屏切换)、振动识别相关功能(比如计步器、敲击)等;此外,手机还可配置陀螺仪、气压计、湿度计、温度计、红外线传感器等其他传感器等。The handset 800 can also include at least one type of sensor 850, such as a light sensor, motion sensor, and other sensors. Specifically, the light sensor may include an ambient light sensor and a proximity sensor, wherein the ambient light sensor may adjust the brightness of the display panel 841 according to the brightness of the ambient light, and the proximity sensor may close the display panel 841 and/or when the mobile phone moves to the ear. Or backlight. The motion sensor may include an acceleration sensor, and the acceleration sensor can detect the magnitude of the acceleration in each direction, and the magnitude and direction of the gravity can be detected at rest, and can be used to identify the gesture of the mobile phone (such as horizontal and vertical screen switching), and vibration recognition related functions (such as Pedometer, tapping, etc.; in addition, the phone can also be equipped with gyroscopes, barometers, hygrometers, thermometers, infrared sensors and other sensors.
音频电路860、扬声器861和传声器862可提供用户与手机之间的音频接口。音频电路860可将接收到的音频数据转换后的电信号,传输到扬声器861,由扬声器861转换为声音信号输出;另一方面,传声器862将收集的声音信号转换为电信号,由音频电路860接收后转换为音频数据,再将音频数据输出处理器880处理后,经RF电路810可以发送给另一手机,或者将音频数据输出至存储器820以便后续处理。 Audio circuitry 860, speaker 861, and microphone 862 can provide an audio interface between the user and the handset. The audio circuit 860 can transmit the converted electrical data of the received audio data to the speaker 861 for conversion to the sound signal output by the speaker 861; on the other hand, the microphone 862 converts the collected sound signal into an electrical signal by the audio circuit 860. After receiving, it is converted into audio data, and then processed by the audio data output processor 880, sent to another mobile phone via the RF circuit 810, or outputted to the memory 820 for subsequent processing.
WiFi属于短距离无线传输技术,手机通过WiFi模块870可以帮助用户收发电子邮件、浏览网页和访问流式媒体等,它为用户提供了无线的宽带互联网访问。虽然图8示出了WiFi模块870,但是可以理解的是,其并不属于手机800的必须构成,可以根据需要而省略。WiFi is a short-range wireless transmission technology, and the mobile phone can help users to send and receive emails, browse web pages, and access streaming media through the WiFi module 870, which provides users with wireless broadband Internet access. Although FIG. 8 shows the WiFi module 870, it can be understood that it does not belong to the essential configuration of the mobile phone 800 and can be omitted as needed.
处理器880是手机的控制中心,利用各种接口和线路连接整个手机的各个部分,通过运行或执行存储在存储器820内的软件程序和/或模块,以及调用存储在存储器820内的数据,执行手机的各种功能和处理数据,从而对手机进行整体监控。在一个实施例中,处理器880可包括一个或多个处理单元。在一个实施例中,处理器880可集成应用处理器和调制解调器,其中,应用处理器主要处理操作系统、用户界面和应用程序等;调制解调器主要处理无线通信。可 以理解的是,上述调制解调器也可以不集成到处理器880中。比如,该处理器880可集成应用处理器和基带处理器,基带处理器与和其它外围芯片等可组成调制解调器。手机800还包括给各个部件供电的电源890(比如电池),优选的,电源可以通过电源管理系统与处理器880逻辑相连,从而通过电源管理系统实现管理充电、放电、以及功耗管理等功能。The processor 880 is the control center of the handset, and connects various portions of the entire handset using various interfaces and lines, by executing or executing software programs and/or modules stored in the memory 820, and invoking data stored in the memory 820, executing The phone's various functions and processing data, so that the overall monitoring of the phone. In one embodiment, processor 880 can include one or more processing units. In one embodiment, the processor 880 can integrate an application processor and a modem, wherein the application processor primarily processes an operating system, a user interface, an application, etc.; the modem primarily processes wireless communications. It will be appreciated that the above modems may also not be integrated into the processor 880. For example, the processor 880 can integrate an application processor and a baseband processor, and the baseband processor and other peripheral chips can form a modem. The mobile phone 800 also includes a power source 890 (such as a battery) that supplies power to various components. Preferably, the power source can be logically coupled to the processor 880 through a power management system to manage functions such as charging, discharging, and power management through the power management system.
在一个实施例中,手机800还可以包括摄像头、蓝牙模块等。In one embodiment, the handset 800 can also include a camera, a Bluetooth module, and the like.
在本申请实施例中,该手机所包括的处理器执行存储在存储器上的计算机程序时实现上述所描述的内存处理方法。In the embodiment of the present application, the processor included in the mobile phone implements the memory processing method described above when executing a computer program stored in the memory.
本申请所使用的对存储器、存储、数据库或其它介质的任何引用可包括非易失性和/或易失性存储器。合适的非易失性存储器可包括只读存储器(ROM)、可编程ROM(PROM)、电可编程ROM(EPROM)、电可擦除可编程ROM(EEPROM)或闪存。易失性存储器可包括随机存取存储器(RAM),它用作外部高速缓冲存储器。作为说明而非局限,RAM以多种形式可得,诸如静态RAM(SRAM)、动态RAM(DRAM)、同步DRAM(SDRAM)、双数据率SDRAM(DDR SDRAM)、增强型SDRAM(ESDRAM)、同步链路(Synchlink)DRAM(SLDRAM)、存储器总线(Rambus)直接RAM(RDRAM)、直接存储器总线动态RAM(DRDRAM)、以及存储器总线动态RAM(RDRAM)。Any reference to a memory, storage, database or other medium used herein may include non-volatile and/or volatile memory. Suitable non-volatile memories can include read only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM), which acts as an external cache. By way of illustration and not limitation, RAM is available in a variety of forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchronization. Link (Synchlink) DRAM (SLDRAM), Memory Bus (Rambus) Direct RAM (RDRAM), Direct Memory Bus Dynamic RAM (DRDRAM), and Memory Bus Dynamic RAM (RDRAM).
以上实施例仅表达了本申请的几种实施方式,其描述较为具体和详细,但并不能因此而理解为对本申请专利范围的限制。应当指出的是,对于本领域的普通技术人员来说,在不脱离本申请构思的前提下,还可以做出若干变形和改进,这些都属于本申请的保护范围。因此,本申请专利的保护范围应以所附权利要求为准。The above embodiments are merely illustrative of several embodiments of the present application, and the description thereof is more specific and detailed, but is not to be construed as limiting the scope of the claims. It should be noted that a number of variations and modifications may be made by those skilled in the art without departing from the spirit and scope of the present application. Therefore, the scope of the invention should be determined by the appended claims.
Claims (20)
- 一种内存处理方法,其特征在于,包括:A memory processing method, comprising:获取待处理应用所占用的可回收内存页;Get the reclaimable memory page occupied by the pending application;获取所述待处理应用被前台应用依赖的依赖比例;Obtaining a proportion of dependencies that the to-be-processed application is dependent on by the foreground application;获取所述待处理应用对每个所述可回收内存页的空闲时长;Obtaining an idle duration of the to-be-processed application for each of the recyclable memory pages;根据所述每个所述可回收内存页的空闲时长和所述依赖比例确定时长阈值;及Determining a duration threshold according to the idle duration of each of the recyclable memory pages and the dependency ratio; and从所述可回收内存页中选取空闲时长超过所述时长阈值的内存页进行回收。A memory page whose idle time exceeds the duration threshold is selected from the recyclable memory page for recycling.
- 根据权利要求1所述的方法,其特征在于,所述获取所述待处理应用被前台应用依赖的依赖比例,包括:The method according to claim 1, wherein the obtaining a proportion of dependencies that the to-be-processed application is dependent on by the foreground application comprises:检测每个可回收内存页中存储的数据是否被前台应用依赖;及Detecting whether data stored in each recyclable memory page is dependent on the foreground application; and根据检测结果确定所述待处理应用被前台应用依赖的依赖比例;所述检测结果包括内存页未被前台应用依赖或被前台应用依赖。Determining, according to the detection result, a proportion of dependencies that the to-be-processed application is dependent on by the foreground application; the detection result includes that the memory page is not dependent on the foreground application or is dependent on the foreground application.
- 根据权利要求2所述的方法,其特征在于,所述从所述可回收内存页中选取空闲时长超过所述时长阈值的内存页进行回收,包括:The method according to claim 2, wherein the recovering from the reclaimable memory page a memory page whose idle duration exceeds the duration threshold comprises:从所述可回收内存页中选取空闲时长超过所述时长阈值的、未被前台应用依赖的内存页进行回收。A memory page whose idle time exceeds the duration threshold and is not dependent on the foreground application is selected from the reclaimable memory page for recycling.
- 根据权利要求1所述的方法,其特征在于,所述获取所述待处理应用对每个所述可回收内存页的空闲时长,包括:The method according to claim 1, wherein the obtaining the idle duration of the to-be-processed application for each of the reclaimable memory pages comprises:获取每个可回收内存页的时间戳记录的更新时间,根据所述更新时间计算出对应可回收内存页的空闲时长。Obtaining the update time of the timestamp record of each recyclable memory page, and calculating the idle duration of the corresponding recyclable memory page according to the update time.
- 根据权利要求1所述的方法,其特征在于,所述获取所述待处理应用对每个所述可回收内存页的空闲时长,还包括:The method according to claim 1, wherein the obtaining the idle duration of the to-be-processed application for each of the reclaimable memory pages further comprises:获取通过最近最久未使用LRU管理单元记录的每个可回收内存页的更新时间,根据所述更新时间计算出对应可回收内存页的空闲时长。The update time of each recyclable memory page recorded by the most recently unused LRU management unit is obtained, and the idle time corresponding to the recyclable memory page is calculated according to the update time.
- 根据权利要求1所述的方法,其特征在于,所述根据所述每个所述可回收内存页的空闲时长和所述依赖比例确定时长阈值,包括:The method according to claim 1, wherein the determining the duration threshold according to the idle duration of the each of the recyclable memory pages and the dependency ratio comprises:根据所述每个所述可回收内存页的空闲时长计算出所述待处理应用对可回收内存页的平均空闲时长;及Calculating, according to the idle duration of each of the recyclable memory pages, an average idle duration of the to-be-processed application for the reclaimable memory page; and根据所述平均空闲时长与所述依赖比例确定时长阈值。A duration threshold is determined according to the average idle duration and the dependency ratio.
- 根据权利要求1所述的方法,其特征在于,所述根据所述每个所述可回收内存页的空闲时长和所述依赖比例确定时长阈值,包括:The method according to claim 1, wherein the determining the duration threshold according to the idle duration of the each of the recyclable memory pages and the dependency ratio comprises:获取与所述待处理应用对应的回收比例与二次启动时长之间的对应关系;所述二次启动时长是指所述待处理应用占用的可回收内存页被回收对应的回收比例后,再次启动时所花费的时长;Obtaining a correspondence between the recycling ratio corresponding to the to-be-processed application and the secondary startup duration; the secondary startup duration is when the reclaimable memory page occupied by the to-be-processed application is recycled corresponding to the recycling ratio, The length of time spent at startup;根据所述依赖比例和所述可回收内存页和所述回收比例与二次启动时长之间的对应关系确定所述内存页的回收数量;及Determining the amount of the memory page to be recovered according to the dependency ratio and the correspondence between the recyclable memory page and the recycling ratio and the second startup duration; and根据所述回收数量从所述每个所述可回收内存页的空闲时长中选取第K大的空闲时长,将选取的空闲时长作为时长阈值;超过第K大的空闲时长的数量为所述回收数量,K为不超过回收数量的自然数。Selecting a Kth largest idle duration from the idle time of each of the recyclable memory pages, and selecting the selected idle duration as a duration threshold; and the number of idle durations exceeding the Kth is the recovery. Quantity, K is a natural number that does not exceed the amount recovered.
- 根据权利要求7所述的方法,其特征在于,所述获取与所述待处理应用对应的回收比例与二次启动时长之间的对应关系,包括:The method according to claim 7, wherein the obtaining a correspondence between a recovery ratio corresponding to the to-be-processed application and a secondary startup duration comprises:确定所述待处理应用的应用类型;及Determining an application type of the to-be-processed application; and根据所述待处理应用的应用类型获取与所述待处理应用对应的回收比例与二次启动时长之间的对应关系。Obtaining a correspondence between a recycling ratio corresponding to the to-be-processed application and a secondary startup duration according to an application type of the to-be-processed application.
- 根据权利要求1所述的方法,其特征在于,所述获取待处理应用所占用的可回收内存 页,包括:The method according to claim 1, wherein the obtaining a reclaimable memory page occupied by the application to be processed comprises:查询待处理应用所占用的内存的所有内存页;及Query all memory pages of the memory occupied by the application to be processed; and从所有内存页中获取可回收内存页。Get reclaimable memory pages from all memory pages.
- 根据权利要求9所述的方法,其特征在于,所述查询待处理应用所占用的内存的所有内存页,包括:The method according to claim 9, wherein the querying all memory pages of the memory occupied by the application to be processed comprises:遍历待处理应用的内存映射文件;及Traversing the memory mapped file of the pending application; and通过所述内存映射文件查询所述待处理应用占用的所有内存页。Querying, by the memory mapping file, all memory pages occupied by the to-be-processed application.
- 根据权利要求9所述的方法,其特征在于,所述从所有内存页中获取可回收内存页,包括:The method of claim 9 wherein said obtaining retrievable memory pages from all of the memory pages comprises:从所述所有内存页中剔除携带占用标记的内存页;及Removing the memory page carrying the occupied mark from all the memory pages; and从剔除后的内存页中获取可回收内存页。Get reclaimable memory pages from the stripped memory page.
- 根据权利要求1至11中任一项所述的方法,其特征在于,当所述待处理应用与前台应用之间存在通信机制或同步机制时,判定所述待处理应用被前台应用依赖。The method according to any one of claims 1 to 11, wherein when there is a communication mechanism or a synchronization mechanism between the to-be-processed application and the foreground application, it is determined that the to-be-processed application is dependent on the foreground application.
- 一种电子设备,包括存储器及处理器,所述存储器中储存有计算机程序,其特征在于,所述计算机程序被所述处理器执行时,使得所述处理器执行如下操作:An electronic device comprising a memory and a processor, wherein the memory stores a computer program, wherein when the computer program is executed by the processor, the processor performs the following operations:获取待处理应用所占用的可回收内存页;Get the reclaimable memory page occupied by the pending application;获取所述待处理应用被前台应用依赖的依赖比例;Obtaining a proportion of dependencies that the to-be-processed application is dependent on by the foreground application;获取所述待处理应用对每个所述可回收内存页的空闲时长;Obtaining an idle duration of the to-be-processed application for each of the recyclable memory pages;根据所述每个所述可回收内存页的空闲时长和所述依赖比例确定时长阈值;及Determining a duration threshold according to the idle duration of each of the recyclable memory pages and the dependency ratio; and从所述可回收内存页中选取空闲时长超过所述时长阈值的内存页进行回收。A memory page whose idle time exceeds the duration threshold is selected from the recyclable memory page for recycling.
- 根据权利要求13所述的电子设备,其特征在于,所述处理器执行所述获取所述待处理应用被前台应用依赖的依赖比例时,还执行如下操作:The electronic device according to claim 13, wherein when the processor performs the obtaining the dependency ratio of the to-be-processed application that is dependent on the foreground application, the processor further performs the following operations:检测每个可回收内存页中存储的数据是否被前台应用依赖;及Detecting whether data stored in each recyclable memory page is dependent on the foreground application; and根据检测结果确定所述待处理应用被前台应用依赖的依赖比例;所述检测结果包括内存页未被前台应用依赖或被前台应用依赖。Determining, according to the detection result, a proportion of dependencies that the to-be-processed application is dependent on by the foreground application; the detection result includes that the memory page is not dependent on the foreground application or is dependent on the foreground application.
- 根据权利要求14所述的电子设备,其特征在于,所述处理器执行所述从所述可回收内存页中选取空闲时长超过所述时长阈值的内存页进行回收时,还执行如下操作:The electronic device according to claim 14, wherein the processor performs the following operations when the memory page that is selected from the recyclable memory page and whose idle time exceeds the duration threshold is used for recovery:从所述可回收内存页中选取空闲时长超过所述时长阈值的、未被前台应用依赖的内存页进行回收。A memory page whose idle time exceeds the duration threshold and is not dependent on the foreground application is selected from the reclaimable memory page for recycling.
- 根据权利要求13所述的电子设备,其特征在于,所述处理器执行所述获取所述待处理应用对每个所述可回收内存页的空闲时长时,还执行如下操作:The electronic device according to claim 13, wherein when the processor performs the acquiring the idle duration of the to-be-processed application for each of the reclaimable memory pages, the processor further performs the following operations:获取每个可回收内存页的时间戳记录的更新时间,根据所述更新时间计算出对应可回收内存页的空闲时长。Obtaining the update time of the timestamp record of each recyclable memory page, and calculating the idle duration of the corresponding recyclable memory page according to the update time.
- 根据权利要求13所述的电子设备,其特征在于,所述处理器执行所述获取所述待处理应用对每个所述可回收内存页的空闲时长时,还执行如下操作:The electronic device according to claim 13, wherein when the processor performs the acquiring the idle duration of the to-be-processed application for each of the reclaimable memory pages, the processor further performs the following operations:获取通过最近最久未使用LRU管理单元记录的每个可回收内存页的更新时间,根据所述更新时间计算出对应可回收内存页的空闲时长。The update time of each recyclable memory page recorded by the most recently unused LRU management unit is obtained, and the idle time corresponding to the recyclable memory page is calculated according to the update time.
- 根据权利要求13所述的电子设备,其特征在于,所述处理器执行所述根据所述每个所述可回收内存页的空闲时长和所述依赖比例确定时长阈值,还执行如下操作:The electronic device according to claim 13, wherein the processor performs the determining the duration duration according to the idle duration of the recyclable memory page and the dependency ratio, and further performing the following operations:根据所述每个所述可回收内存页的空闲时长计算出所述待处理应用对可回收内存页的平均空闲时长;及Calculating, according to the idle duration of each of the recyclable memory pages, an average idle duration of the to-be-processed application for the reclaimable memory page; and根据所述平均空闲时长与所述依赖比例确定时长阈值。A duration threshold is determined according to the average idle duration and the dependency ratio.
- 根据权利要求13所述的电子设备,其特征在于,所述处理器执行所述根据所述每个所述可回收内存页的空闲时长和所述依赖比例确定时长阈值时,还执行如下操作:The electronic device according to claim 13, wherein when the processor performs the determining the duration threshold according to the idle duration of the recyclable memory page and the dependency ratio, the processor further performs the following operations:获取与所述待处理应用对应的回收比例与二次启动时长之间的对应关系;所述二次启动时长是指所述待处理应用占用的可回收内存页被回收对应的回收比例后,再次启动时所花费 的时长;Obtaining a correspondence between the recycling ratio corresponding to the to-be-processed application and the secondary startup duration; the secondary startup duration is when the reclaimable memory page occupied by the to-be-processed application is recycled corresponding to the recycling ratio, The length of time spent at startup;根据所述依赖比例和所述可回收内存页和所述回收比例与二次启动时长之间的对应关系确定所述内存页的回收数量;及Determining the amount of the memory page to be recovered according to the dependency ratio and the correspondence between the recyclable memory page and the recycling ratio and the second startup duration; and根据所述回收数量从所述每个所述可回收内存页的空闲时长中选取第K大的空闲时长,将选取的空闲时长作为时长阈值;超过第K大的空闲时长的数量为所述回收数量,K为不超过回收数量的自然数。Selecting a Kth largest idle duration from the idle time of each of the recyclable memory pages, and selecting the selected idle duration as a duration threshold; and the number of idle durations exceeding the Kth is the recovery. Quantity, K is a natural number that does not exceed the amount recovered.
- 一种计算机可读存储介质,其上存储有计算机程序,其特征在于,所述计算机程序被处理器执行时实现如权利要求1至12中任一项所述方法的步骤。A computer readable storage medium having stored thereon a computer program, wherein the computer program is executed by a processor to perform the steps of the method of any one of claims 1 to 12.
Applications Claiming Priority (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810023217.2A CN110018900B (en) | 2018-01-10 | 2018-01-10 | Memory processing method and device, electronic equipment and computer readable storage medium |
CN201810023217.2 | 2018-01-10 |
Publications (1)
Publication Number | Publication Date |
---|---|
WO2019137258A1 true WO2019137258A1 (en) | 2019-07-18 |
Family
ID=67188088
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
PCT/CN2018/125326 WO2019137258A1 (en) | 2018-01-10 | 2018-12-29 | Memory processing method, electronic device and computer readable storage medium |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN110018900B (en) |
WO (1) | WO2019137258A1 (en) |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111158910A (en) * | 2019-12-27 | 2020-05-15 | Oppo广东移动通信有限公司 | Memory management method and device, storage medium and electronic equipment |
CN111831440A (en) * | 2020-07-01 | 2020-10-27 | Oppo广东移动通信有限公司 | Memory recovery method and device, storage medium and electronic equipment |
CN112463374A (en) * | 2020-11-26 | 2021-03-09 | 中国第一汽车股份有限公司 | Memory management method, device, equipment and storage medium |
CN117130767A (en) * | 2023-02-08 | 2023-11-28 | 荣耀终端有限公司 | Method for recycling memory, electronic equipment and storage medium |
Families Citing this family (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113392037B (en) * | 2020-03-12 | 2024-06-18 | 深圳市万普拉斯科技有限公司 | Memory recycling method, memory recycling device, computer equipment and storage medium |
CN113590509B (en) * | 2020-04-30 | 2024-03-26 | 华为技术有限公司 | Page exchange method, storage system and electronic equipment |
CN111625351A (en) * | 2020-05-12 | 2020-09-04 | Oppo(重庆)智能科技有限公司 | Method and device for recycling file pages, terminal and readable storage medium |
CN111949564B (en) * | 2020-08-13 | 2024-05-17 | Vidaa(荷兰)国际控股有限公司 | Memory exchange method and display device |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103092700A (en) * | 2013-02-01 | 2013-05-08 | 华为终端有限公司 | Internal memory cleaning method and cleaning device and terminal device |
CN103500121A (en) * | 2013-09-29 | 2014-01-08 | 深圳Tcl新技术有限公司 | Process managing method and device |
CN103631661A (en) * | 2013-11-27 | 2014-03-12 | 青岛海信电器股份有限公司 | Internal storage management method and device |
CN106354562A (en) * | 2016-08-25 | 2017-01-25 | 上海传英信息技术有限公司 | Memory cleaning system and memory cleaning method |
CN106569733A (en) * | 2015-10-12 | 2017-04-19 | 北京国双科技有限公司 | Processing method and processing device for buffered data |
Family Cites Families (12)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP5385347B2 (en) * | 2011-08-02 | 2014-01-08 | レノボ・シンガポール・プライベート・リミテッド | Method and computer for enlarging free memory in main memory |
KR101596606B1 (en) * | 2011-08-19 | 2016-03-07 | 가부시끼가이샤 도시바 | Information processing apparatus, method for controlling information processing apparatus, non-transitory recording medium storing control tool, host device, non-transitory recording medium storing performance evaluation tool, and performance evaluation method for external memory device |
CN103870333B (en) * | 2012-12-17 | 2017-08-29 | 华为技术有限公司 | A kind of global memory's sharing method, device and a kind of communication system |
CN103324500B (en) * | 2013-05-06 | 2016-08-31 | 广州市动景计算机科技有限公司 | A kind of method and device reclaiming internal memory |
US9424195B2 (en) * | 2014-04-15 | 2016-08-23 | Advanced Micro Devices, Inc. | Dynamic remapping of cache lines |
US10552179B2 (en) * | 2014-05-30 | 2020-02-04 | Apple Inc. | Resource management with dynamic resource policies |
CN105446814A (en) * | 2014-09-30 | 2016-03-30 | 青岛海信移动通信技术股份有限公司 | Cache recovery method and device |
CA2876379A1 (en) * | 2014-12-29 | 2016-06-29 | Adam J. Storm | Memory management in presence of asymmetrical memory transfer costs |
CN105988823B (en) * | 2015-01-27 | 2019-10-22 | 阿里巴巴集团控股有限公司 | Memory allocation method and its system when in terminal using starting |
CN105159777B (en) * | 2015-08-03 | 2018-07-27 | 中科创达软件股份有限公司 | The method for recovering internal storage and device of process |
CN105701025B (en) * | 2015-12-31 | 2019-07-23 | 华为技术有限公司 | A kind of method for recovering internal storage and device |
CN106331148A (en) * | 2016-09-14 | 2017-01-11 | 郑州云海信息技术有限公司 | Cache management method and cache management device for data reading by clients |
-
2018
- 2018-01-10 CN CN201810023217.2A patent/CN110018900B/en active Active
- 2018-12-29 WO PCT/CN2018/125326 patent/WO2019137258A1/en active Application Filing
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103092700A (en) * | 2013-02-01 | 2013-05-08 | 华为终端有限公司 | Internal memory cleaning method and cleaning device and terminal device |
CN103500121A (en) * | 2013-09-29 | 2014-01-08 | 深圳Tcl新技术有限公司 | Process managing method and device |
CN103631661A (en) * | 2013-11-27 | 2014-03-12 | 青岛海信电器股份有限公司 | Internal storage management method and device |
CN106569733A (en) * | 2015-10-12 | 2017-04-19 | 北京国双科技有限公司 | Processing method and processing device for buffered data |
CN106354562A (en) * | 2016-08-25 | 2017-01-25 | 上海传英信息技术有限公司 | Memory cleaning system and memory cleaning method |
Cited By (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111158910A (en) * | 2019-12-27 | 2020-05-15 | Oppo广东移动通信有限公司 | Memory management method and device, storage medium and electronic equipment |
CN111158910B (en) * | 2019-12-27 | 2024-01-12 | Oppo广东移动通信有限公司 | Memory management method and device, storage medium and electronic equipment |
CN111831440A (en) * | 2020-07-01 | 2020-10-27 | Oppo广东移动通信有限公司 | Memory recovery method and device, storage medium and electronic equipment |
CN112463374A (en) * | 2020-11-26 | 2021-03-09 | 中国第一汽车股份有限公司 | Memory management method, device, equipment and storage medium |
CN117130767A (en) * | 2023-02-08 | 2023-11-28 | 荣耀终端有限公司 | Method for recycling memory, electronic equipment and storage medium |
Also Published As
Publication number | Publication date |
---|---|
CN110018900B (en) | 2023-01-24 |
CN110018900A (en) | 2019-07-16 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
WO2019137258A1 (en) | Memory processing method, electronic device and computer readable storage medium | |
US11099900B2 (en) | Memory reclamation method and apparatus | |
WO2019137252A1 (en) | Memory processing method, electronic device, and computer-readable storage medium | |
EP3506105B1 (en) | Method and device for processing a memory and storage medium | |
CN109992402B (en) | Memory processing method and device, electronic equipment and computer readable storage medium | |
EP3506106B1 (en) | Method for processing application, electronic device, and computer-readable storage medium | |
US20220012085A1 (en) | Memory management method and apparatus | |
WO2019128540A1 (en) | Resource management method, mobile terminal and computer readable storage medium | |
CN111274039B (en) | Memory recycling method and device, storage medium and electronic equipment | |
WO2019128542A1 (en) | Application processing method, electronic device, computer readable storage medium | |
WO2019137173A1 (en) | Resource management method, mobile terminal and computer-readable storage medium | |
US11704240B2 (en) | Garbage data scrubbing method, and device | |
WO2019128588A1 (en) | Process processing method and apparatus, electronic device, computer readable storage medium | |
WO2019128537A1 (en) | Application freezing method, and computer device and computer-readable storage medium | |
WO2019128571A1 (en) | Resource management method and device, mobile terminal, as well as computer readable storage medium | |
WO2019128574A1 (en) | Information processing method and device, computer device and computer readable storage medium | |
WO2019128569A1 (en) | Method and apparatus for freezing application, and storage medium and terminal | |
CN110007968B (en) | Information processing method, information processing device, computer equipment and computer readable storage medium | |
WO2019128545A1 (en) | Process handling method, and electronic device and computer-readable storage medium | |
CN115437816A (en) | Application program no-response analysis method and device, electronic equipment and storage medium |
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: 18899163 Country of ref document: EP Kind code of ref document: A1 |
|
NENP | Non-entry into the national phase |
Ref country code: DE |
|
122 | Ep: pct application non-entry in european phase |
Ref document number: 18899163 Country of ref document: EP Kind code of ref document: A1 |