WO2019137252A1 - Memory processing method, electronic device, and computer-readable storage medium - Google Patents

Memory processing method, electronic device, and computer-readable storage medium Download PDF

Info

Publication number
WO2019137252A1
WO2019137252A1 PCT/CN2018/125225 CN2018125225W WO2019137252A1 WO 2019137252 A1 WO2019137252 A1 WO 2019137252A1 CN 2018125225 W CN2018125225 W CN 2018125225W WO 2019137252 A1 WO2019137252 A1 WO 2019137252A1
Authority
WO
WIPO (PCT)
Prior art keywords
memory
application
memory page
recyclable
recycling
Prior art date
Application number
PCT/CN2018/125225
Other languages
French (fr)
Chinese (zh)
Inventor
陈岩
Original Assignee
Oppo广东移动通信有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Oppo广东移动通信有限公司 filed Critical Oppo广东移动通信有限公司
Publication of WO2019137252A1 publication Critical patent/WO2019137252A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5011Allocation 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/5016Allocation 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

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, an electronic device, and a non-transitory computer readable storage medium are provided in accordance with various embodiments of the present application.
  • An in-memory processing method includes: acquiring a reclaimable memory page occupied by an application to be processed; acquiring a dependency ratio of the to-be-processed application to be relied upon by the foreground application; determining, according to the reclaimable memory page and the dependency ratio, Recycling the number of reclaimable memory pages; selecting the reclaimed memory page from the recyclable memory page for recycling.
  • An electronic device comprising a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, causing the processor to execute the memory processing method described in the embodiments of the present application A step of.
  • a computer readable storage medium having stored thereon a computer program that, when executed by a processor, implements the steps of the memory processing method described in various embodiments of the present application.
  • the reclaimable memory page occupied by the to-be-processed application and the dependency ratio of the to-be-processed application depended on by the foreground application are obtained, and the reclaimed quantity is determined according to the dependency ratio and the reclaimable memory page, and the reclaimed memory page is selected from the reclaimable memory page. Recycling the number of memory pages for recycling. Since the recovered objects are recyclable memory pages, and not all recyclable memory pages are reclaimed, the amount of reclaimed is determined according to the proportion of dependencies that the application to be processed is dependent on by the foreground application.
  • 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.
  • 4A is a schematic diagram of a recovery ratio curve for an unrelated application in one embodiment.
  • Figure 4B is a schematic diagram of the recovery ratio curve for a linear application in one embodiment.
  • 4C is a schematic diagram of a recovery ratio curve for a non-linear application in one embodiment.
  • Figure 5 is a flow chart of a memory processing method in another embodiment.
  • Figure 6 is a block diagram showing the structure of an internal memory processing device in an embodiment.
  • Figure 7 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. It also limits the occupation of network resources and I/O interface resources by the process; CPU freeze sleep mode means that the related process is prohibited from using the CPU, but the memory usage is reserved.
  • 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.
  • UID application-based User Identifier
  • 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 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 app is an app that runs in the background.
  • 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.
  • the dependency representation indicates that an application needs to utilize data of another application or applications to smoothly implement the relationship of execution of the one 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.
  • 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 the 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 determining the amount of recycling of the recyclable memory page based on the reclaimable memory page and the dependency ratio.
  • the amount of recycling is the amount of recycling to the memory page, which is an integer.
  • the number of different dependencies and the total number of different recyclable memory pages are different depending on the number of recycles. This total represents the total number of all recyclable memory pages.
  • the electronic device may preset a correspondence between different total numbers under different dependency ratios and the number of recyclings, and according to the corresponding relationship, the corresponding recycling quantity may be determined. Among them, the amount of recycling is positively correlated with the total number of recyclable memory pages, and negatively correlated with the proportion of dependencies. The larger the total number of recyclable memory pages, and/or the smaller the dependency ratio, the larger the corresponding recovery amount.
  • the recycling ratio of the recyclable memory pages may be determined according to the dependency ratio, and the number of reclaimed memory pages may be determined according to the recycling ratio and the total number of recyclable memory pages.
  • the recycling ratio represents the proportion of the recycling of the memory to be recycled, and the recycling ratio is used to guide the recovery of the recyclable memory.
  • the recycling ratio is 50%, which means that 50% of the occupied memory can be recovered.
  • the larger the dependency ratio the smaller the recovery ratio.
  • the correspondence between the different proportions of the application and the different recycling ratios can be established, and the corresponding recycling ratio is obtained according to the corresponding relationship.
  • the amount of recycling can be the product of the total number of recyclable memory pages and the determined recycling ratio.
  • an integer approximating the product may be selected.
  • the nearest integer may be determined as a number of rounds according to rounding, or the corresponding integer may be determined according to a truncation method or a carry method.
  • the amount of recycling is the product of the total number of recyclable memory pages and the determined recycling ratio.
  • 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, when the dependency ratio is 20%, if the proportion of the hand protection determined according to the dependency ratio is 30.5%, the product obtained is 30.5, and the number of recovery is determined to be 31, if corresponding When the recovery ratio is 21.2%, it is determined that the recovery amount is 21.
  • Operation 308 select a reclaimed number of memory pages from the reclaimable memory page for recycling.
  • the electronic device may select, according to the determined quantity of recycling, the reclaimed memory page from the recyclable memory page occupied by the to-be-processed application to reclaim the reclaimed memory page for the foreground application or other
  • the application is used to improve the overall processing efficiency of the system.
  • the selected reclaimable memory page is a memory page whose stored data is not dependent on the foreground application.
  • the electronic device may recover the memory page from the reclaimable memory page according to the recovery ratio by using the process memory recovery module 234, so that after the memory page is reclaimed, the impact on the to-be-processed application is also small.
  • the recycling ratio is 30% and the recyclable memory page has 100 pages
  • 30 pages of memory pages are reclaimed from the 100-page recyclable memory page, that is, 30 pages of recyclable memory pages are released, making the electronic
  • the device's free memory pages are increased by 30 pages for use by foreground applications or other back-end applications.
  • the memory processing method described above obtains the reclaimed memory page occupied by the to-be-processed application and the dependency ratio of the to-be-processed application that is dependent on the foreground application, and then determines the amount of recycling according to the dependency ratio and the reclaimable memory page, and recovers the memory page from the reclaimable memory page. Select a reclaimed number of memory pages for recycling. Since the reclaimed objects are recyclable memory pages, and not all recyclable memory pages are reclaimed, the reclaimed quantity is determined according to the proportion of dependencies that the pending application is dependent on by the foreground application.
  • 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 308 includes selecting a reclaimed number of memory pages that are not dependent on the foreground application for recycling from the reclaimable memory pages.
  • the electronic device can further eliminate the memory page that is relied upon by the foreground application, select the reclaimed memory page from the reclaimable memory page that is not depended by the foreground application, and recycle the selected memory page.
  • the amount of recovery may not exceed the number of memory pages that are not dependent on the foreground application.
  • the method before the operation 306, further includes: obtaining a correspondence between a recycling ratio corresponding to the to-be-processed application and a secondary startup duration; the operation 306 includes: according to the reclaimable memory page, the dependency ratio, and the recycling ratio The correspondence between the secondary startup durations determines the amount of memory page reclaimed.
  • the second startup duration refers to the length of time taken after the reclaimed memory page occupied by the application to be processed is recycled.
  • the electronic device can set a corresponding relationship between the corresponding recycling ratio and the secondary startup time for each application.
  • 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.
  • 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.
  • the electronic device may set a corresponding startup duration threshold, and when the secondary startup duration reaches the startup duration threshold, the corresponding ratio is used as a reference ratio to the reclaimable memory page.
  • the startup duration threshold may be a preset empirical value, and the startup duration thresholds of different applications may not be the same.
  • the corresponding startup time threshold may be determined according to the normal startup time of the corresponding application, and the duration of 1.5 times or 2 times of the normal startup time is used as the startup duration threshold.
  • 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 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, wherein 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 for applications of irrelevant, linear, and nonlinear classes respectively, 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 chosen as the recovery ratio for recyclable memory pages.
  • 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.
  • operation 308 includes reclaiming a reclaimed number of memory pages from the recyclable memory page at equal intervals of the memory page number.
  • the electronic device may randomly collect the recovered memory pages according to the collected quantity, or select a collected number of memory pages from the recyclable memory page according to the serial number of the memory page for recycling.
  • the memory page number is a number set by the electronic device to the memory page, and may be sequentially numbered according to 1, 2, 3, and the like. For example, when the recovery ratio is 33%, the determined uniform recovery interval is 2 memory pages per interval. For example, if the reclaimable memory page is from memory page 1 to memory page 100, the memory page 1 can be sequentially recovered. , memory page 4, memory page 7, memory page 10... memory page 97, memory page 100, to achieve the recovery of 33% of recyclable memory pages. By recycling at even intervals, each segment of memory is not completely reclaimed, making the application more stable when it is reopened.
  • 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. 5 another memory processing method is provided, the method comprising:
  • Operation 502 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 506 detecting whether data stored in each recyclable memory page is dependent on the foreground application; determining, 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 508 obtaining a correspondence between the recovery ratio corresponding to the application to be processed and the secondary startup duration.
  • 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 correspondence relationship 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-up duration at different recovery ratios, which may be the curves as shown in Figures 4A through 4C.
  • the correspondence relationship may be determined according to the corresponding secondary detection duration under different detection ratios recorded under a preset number of times. For example, 100 tests can be performed, each time a different recovery ratio can be detected, and the corresponding secondary start time is long, and the average value of the secondary start time in the same ratio is taken as the second corresponding to the recovery ratio in the corresponding relationship. Startup time.
  • Operation 510 determining the number of reclaimed memory pages according to a correspondence between the recyclable memory page, the dependency ratio, and the reclaim ratio and the secondary boot duration.
  • the electronic device may select an appropriate ratio as the corresponding reference ratio according to the correspondence between the recycling ratio and the secondary startup time, and then determine the recovery ratio of the recyclable memory page according to the reference ratio and the dependency ratio, and then determine the ratio.
  • the product of the recycling ratio and the total number of recyclable memory pages is used as the recycling quantity.
  • the recovery ratio of the recyclable memory page may be determined according to the reference ratio and the dependency ratio, for example, the reference ratio is a, the dependency ratio is b, and the recovery ratio of the recyclable memory page is c.
  • the reference ratio is a
  • the dependency ratio is b
  • the recovery ratio of the recyclable memory page is c.
  • a reclaimed memory page that is not dependent on the foreground application is selected from the reclaimable memory page for recycling.
  • a reclaimed number of memory pages may be reclaimed from memory pages that are not dependent on the foreground application at equal intervals of the memory page number.
  • the impact on the foreground application can be further reduced by reclaiming memory pages that are not dependent on the foreground application.
  • FIGS. 3 and 5 are sequentially displayed as indicated by 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 and 5 may include multiple sub-operations or multiple stages, which are not necessarily performed at the same time, but may be performed at different times, or The order of execution of the stages is also not necessarily sequential, but may be performed alternately or alternately with at least a portion of the sub-operations or stages of other operations or other operations.
  • an in-memory processing device includes a memory page acquisition module 602, a dependency determination module 604, and a memory recovery module 606.
  • the memory page obtaining module 602 is configured to obtain a reclaimable memory page occupied by the to-be-processed application;
  • the dependency determining module 604 is configured to obtain a dependency ratio of the to-be-processed application that is dependent on the foreground application;
  • the memory recycling module 606 is configured to use the reclaimable memory page.
  • the dependency ratio determines the amount of reclaimed reclaimable memory pages; select the reclaimed amount of memory pages from the reclaimable memory pages for recycling.
  • the memory page obtaining module 602 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 602 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 604 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 606 is further configured to select, from the reclaimable memory page, a reclaimed number of memory pages that are not dependent on the foreground application for recycling.
  • the memory recovery module 606 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 number of memory pages to be recycled based on the correspondence between the recyclable memory page, the dependency ratio, and the recycling ratio and the secondary startup duration.
  • the memory reclamation module 606 is further configured to reclaim a reclaimed number of memory pages from the recyclable memory page at equal intervals of the memory page number.
  • the dependency determination module 604 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 above-mentioned memory processing device determines the amount of recycling according to the dependency ratio and the recyclable memory page, and obtains the reclaimed memory page according to the dependency ratio and the reclaimable memory page, by acquiring the recyclable memory page occupied by the application to be processed and the dependency ratio of the to-be-processed application being relied upon by the foreground application. Select a reclaimed number of memory pages for recycling. Since the reclaimed objects are recyclable memory pages, and not all recyclable memory pages are reclaimed, the reclaimed quantity is determined according to the proportion of dependencies that the pending application is dependent on by the foreground application.
  • 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. 7 , for the convenience of description, only the parts related to the embodiments of the present application are shown. If the specific technical details are not disclosed, please 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. 7 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 710, a memory 720, an input unit 730, a display unit 740, a sensor 750, an audio circuit 760, a wireless fidelity (WiFi) module 770, and a processor 780. And power supply 790 and other components.
  • RF radio frequency
  • the RF circuit 710 can be used for receiving and transmitting signals during the transmission and reception of information or during a call.
  • the downlink information of the base station can be received and processed by the processor 780.
  • the uplink data can also be sent 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 710 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
  • the memory 720 can be used to store software programs and modules, and the processor 780 executes various functional applications and data processing of the mobile phone by running software programs and modules stored in the memory 720.
  • the memory 720 can mainly include a program storage area and a data storage area, wherein the program storage area can 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 720 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 730 can be configured to receive input numeric or character information and to generate key signal inputs related to user settings and function controls of the handset 700.
  • the input unit 730 may include a touch panel 731 and other input devices 732.
  • the touch panel 731 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 731 or near the touch panel 731. Operation) and drive the corresponding connection device according to a preset program.
  • the touch panel 731 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 780 is provided and can receive commands from the processor 780 and execute them.
  • the touch panel 731 can be implemented in various types such as resistive, capacitive, infrared, and surface acoustic waves.
  • the input unit 730 may also include other input devices 732.
  • other input devices 732 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 740 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 740 can include a display panel 741.
  • the display panel 741 can be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), or the like.
  • the touch panel 731 can cover the display panel 741. When the touch panel 731 detects a touch operation on or near it, the touch panel 731 transmits to the processor 780 to determine the type of the touch event, and then the processor 780 is The type of touch event provides a corresponding visual output on display panel 741.
  • touch panel 731 and the display panel 741 are used as two independent components to implement the input and input functions of the mobile phone in FIG. 7, in some embodiments, the touch panel 731 can be integrated with the display panel 741. Realize the input and output functions of the phone.
  • the handset 700 can also include at least one type of sensor 750, 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 741 according to the brightness of the ambient light, and the proximity sensor may close the display panel 741 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 760, speaker 761, and microphone 762 can provide an audio interface between the user and the handset.
  • the audio circuit 760 can transmit the converted electrical data of the received audio data to the speaker 761 for conversion to the sound signal output by the speaker 761; on the other hand, the microphone 762 converts the collected sound signal into an electrical signal by the audio circuit 760. After receiving, it is converted into audio data, and then processed by the audio data output processor 780, transmitted to another mobile phone via the RF circuit 710, or outputted to the memory 720 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 770, which provides users with wireless broadband Internet access.
  • FIG. 7 shows the WiFi module 770, it can be understood that it does not belong to the essential configuration of the mobile phone 700 and can be omitted as needed.
  • the processor 780 is the control center of the handset, which 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 720, and invoking data stored in the memory 720, The phone's various functions and processing data, so that the overall monitoring of the phone.
  • processor 780 can include one or more processing units.
  • processor 780 can integrate an application processor and a modem, where the application processor primarily processes an operating system, user interface, applications, etc.; the modem primarily handles wireless communications. It will be appreciated that the above described modem may also not be integrated into the processor 780.
  • the processor 780 can integrate an application processor and a baseband processor, and the baseband processor and other peripheral chips can form a modem.
  • the handset 700 also includes a power source 790 (such as a battery) that supplies power to the various components.
  • the power source can be logically coupled to the processor 780 via a power management system to manage functions such as charging, discharging, and power management through the power management system.
  • the handset 700 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

Abstract

A memory processing method, comprising: acquiring a reclaimable memory page occupied by a pending application; acquiring a dependency ratio where the pending application is depended on by a foreground application; determining the reclaiming number of the reclaimable memory pages according to the reclaimable memory pages and the dependency ratio; and selecting the reclaiming number of memory pages from the reclaimable memory pages for reclaiming.

Description

内存处理方法、电子设备、计算机可读存储介质Memory processing method, electronic device, computer readable storage medium
相关申请的交叉引用Cross-reference to related applications
本申请要求于2018年1月10日提交中国专利局、申请号为201810023232.7、发明名称为“内存处理方法和装置、电子设备、计算机可读存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims priority to Chinese Patent Application No. 201810023232.7 filed on Jan. 10, 2018, entitled "Memory Processing Method and Apparatus, Electronic Apparatus, Computer Readable Storage Medium", the entire contents of which is hereby incorporated by reference. This is incorporated herein by reference.
技术领域Technical field
本申请涉及数据处理领域,特别是涉及一种内存处理方法、电子设备、计算机可读存储介质。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.
背景技术Background technique
电子设备上安装的应用在运行时,需要占用一定的内存。内存是一个应用在运行过程中数据的主要存储介质。由于电子设备上的内存容量有限,当后台应用占据的内存过多时,会影响前台应用的运行效率。因而需要对内存进行回收,以提高前台应用的运行效率。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
根据本申请的各种实施例提供一种内存处理方法、电子设备、非易失性计算机可读存储介质。An in-memory processing method, an electronic device, and a non-transitory computer readable storage medium are provided in accordance with various embodiments of the present application.
一种内存处理方法,包括:获取待处理应用所占用的可回收内存页;获取所述待处理应用被前台应用依赖的依赖比例;根据所述可回收内存页和所述依赖比例确定对所述可回收内存页的回收数量;从所述可回收内存页中选取所述回收数量的内存页进行回收。An in-memory processing method includes: acquiring a reclaimable memory page occupied by an application to be processed; acquiring a dependency ratio of the to-be-processed application to be relied upon by the foreground application; determining, according to the reclaimable memory page and the dependency ratio, Recycling the number of reclaimable memory pages; selecting the reclaimed memory page from the recyclable memory page for recycling.
一种电子设备,包括存储器及处理器,所述存储器中储存有计算机程序,所述计算机程序被所述处理器执行时,使得所述处理器执行本申请各实施例中所述的内存处理方法的步骤。An electronic device comprising a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, causing the processor to execute the memory processing method described in the embodiments of the present application A step of.
一种计算机可读存储介质,其上存储有计算机程序,所述计算机程序被处理器执行时实现本申请各实施例中所述的内存处理方法的步骤。A computer readable storage medium having stored thereon a computer program that, when executed by a processor, implements the steps of the memory processing method described in various embodiments of the present application.
本申请实施例通过获取待处理应用所占用的可回收内存页以及待处理应用被前台应用依赖的依赖比例,进而根据该依赖比例和可回收内存页确定回收数量,并从可回收内存页中选取回收数量的内存页进行回收,由于回收的对象是可回收内存页,且并非一定是对所有可回收内存页均进行回收,回收数量是根据待处理应用被前台应用依赖的依赖比例而确定,进一步降低了对待处理应用的运行影响,且回收的内存页可释放出来供其它应用使用,又提高了系统的综合处理效率,保证在整个系统内存变大的情况下,对每个应用的负面影响最小,保持了对待处理应用内存的回收与运行之间的平衡性。In the embodiment of the present application, the reclaimable memory page occupied by the to-be-processed application and the dependency ratio of the to-be-processed application depended on by the foreground application are obtained, and the reclaimed quantity is determined according to the dependency ratio and the reclaimable memory page, and the reclaimed memory page is selected from the reclaimable memory page. Recycling the number of memory pages for recycling. Since the recovered objects are recyclable memory pages, and not all recyclable memory pages are reclaimed, the amount of reclaimed is determined according to the proportion of dependencies that the application to be processed is dependent on by the foreground application. Reduces the operational impact of the application to be processed, and the reclaimed memory pages can be released for use by other applications, which improves the overall processing efficiency of the system and ensures that the negative impact on each application is minimized when the overall system memory becomes large. , maintaining a balance between the recycling and operation of the application memory to be processed.
附图说明DRAWINGS
为了更清楚地说明本申请实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。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.
图4A为一个实施例中无关类应用的回收比例曲线示意图。4A is a schematic diagram of a recovery ratio curve for an unrelated application in one embodiment.
图4B为一个实施例中线性类应用的回收比例曲线示意图。Figure 4B is a schematic diagram of the recovery ratio curve for a linear application in one embodiment.
图4C为一个实施例中非线性类应用的回收比例曲线示意图。4C is a schematic diagram of a recovery ratio curve for a non-linear application in one embodiment.
图5为另一个实施例中内存处理方法的流程图。Figure 5 is a flow chart of a memory processing method in another embodiment.
图6为一个实施例中内存处理装置的结构框图。Figure 6 is a block diagram showing the structure of an internal memory processing device in an embodiment.
图7为一个实施例中手机的部分结构的框图。Figure 7 is a block diagram showing a portion of the structure of a handset in an embodiment.
具体实施方式Detailed ways
为了使本申请的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本申请进行进一步详细说明。应当理解,此处所描述的具体实施例仅仅用以解释本申请,并不用于限定本申请。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 means that the related process is prohibited from using the CPU, but the memory usage is reserved. When the CPU resources are forbidden, 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 app is an app that runs 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即为被依赖的应用。可以理解地,依赖的应用还可能为第一应用, 第二应用可能为后台应用。电子设备可从后台应用集合中进行检测,以查询出是否存在被前台应用依赖的后台应用。Wherein, the dependency representation indicates that an application needs to utilize data of another application or applications to smoothly implement the relationship of execution of the one 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 the 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, determining the amount of recycling of the recyclable memory page based on the reclaimable memory page and the dependency ratio.
回收数量为对内存页的回收数量,该数量为整数。不同的依赖比例以及不同的可回收内存页的总数对应的回收数量不同。该总数表示所有可回收内存页的总数量。电子设备可预设不同的总数在不同的依赖比例下,与回收数量之间的对应关系,根据该对应关系,可确定相应的回收数量。其中,回收数量与可回收内存页的总数呈正相关,与依赖比例呈负相关,可回收内存页的总数越大,和/或依赖比例越小,则对应确定的回收数量越大。The amount of recycling is the amount of recycling to the memory page, which is an integer. The number of different dependencies and the total number of different recyclable memory pages are different depending on the number of recycles. This total represents the total number of all recyclable memory pages. The electronic device may preset a correspondence between different total numbers under different dependency ratios and the number of recyclings, and according to the corresponding relationship, the corresponding recycling quantity may be determined. Among them, the amount of recycling is positively correlated with the total number of recyclable memory pages, and negatively correlated with the proportion of dependencies. The larger the total number of recyclable memory pages, and/or the smaller the dependency ratio, the larger the corresponding recovery amount.
在一个实施例中,可根据该依赖比例确定对可回收内存页的回收比例,进而根据该回收比例以及可回收内存页的总数确定对可回收内存页的回收数量。其中,回收比例表示对待回收的内存的进行回收的比例,回收比例用于指导对可回收内存的回收的多少。比如回收比例为50%,表示可回收50%的占用内存。回收比例与依赖比例之间呈负相关,依赖比例越大,则回收比例越小。可建立该应用在不同的依赖比例下,与不同的回收比例之间的对应关系,根据该对应关系获取对应的回收比例。In one embodiment, the recycling ratio of the recyclable memory pages may be determined according to the dependency ratio, and the number of reclaimed memory pages may be determined according to the recycling ratio and the total number of recyclable memory pages. Among them, the recycling ratio represents the proportion of the recycling of the memory to be recycled, and the recycling ratio is used to guide the recovery of the recyclable memory. For example, the recycling ratio is 50%, which means that 50% of the occupied memory can be recovered. There is a negative correlation between the recovery ratio and the proportion of dependence. The larger the dependency ratio, the smaller the recovery ratio. The correspondence between the different proportions of the application and the different recycling ratios can be established, and the corresponding recycling ratio is obtained according to the corresponding relationship.
回收数量可为可回收内存页的总数与确定的回收比例之间的乘积。当该乘积不为整数时,可选取与该乘积近似的一个整数,比如可按照四舍五入的方式确定最接近的一个整数作为回收数量,或者还可按照截尾法或进位法等方式确定相应的整数作为回收数量。The amount of recycling can be the product of the total number of recyclable memory pages and the determined recycling ratio. When the product is not an integer, an integer approximating the product may be selected. For example, the nearest integer may be determined as a number of rounds according to rounding, or the corresponding integer may be determined according to a truncation method or a carry method. As the amount of recycling.
以按照四舍五入的方式确定可回收数量为例说明。比如,当可回收内存页有100页时,当依赖比例为20%时,若根据该依赖比例确定的护手比例为30.5%,则得到的乘积为30.5,确定回收数量为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, when the dependency ratio is 20%, if the proportion of the hand protection determined according to the dependency ratio is 30.5%, the product obtained is 30.5, and the number of recovery is determined to be 31, if corresponding When the recovery ratio is 21.2%, it is determined that the recovery amount is 21.
操作308,从可回收内存页中选取回收数量的内存页进行回收。 Operation 308, select a reclaimed number of memory pages from the reclaimable memory page for recycling.
电子设备可按照所确定的回收数量,从该待处理应用占用的可回收内存页中,选取该回收数量的内存页进行回收,以释放出该回收数量的可回收内存页,供前台应用或其它应用所使用,提高系统的综合处理效率。其中,选取的可回收内存页,为存储的数据未被前台应用依赖的内存页。可选地,电子设备可通过上述的进程内存回收模块234,按照该回收比例从可回收内存页中进行内存页的回收,使得回收内存页之后,对该待处理应用造成的影响也较小。The electronic device may select, according to the determined quantity of recycling, the reclaimed memory page from the recyclable memory page occupied by the to-be-processed application to reclaim the reclaimed memory page for the foreground application or other The application is used to improve the overall processing efficiency of the system. The selected reclaimable memory page is a memory page whose stored data is not dependent on the foreground application. Optionally, the electronic device may recover the memory page from the reclaimable memory page according to the recovery ratio by using the process memory recovery module 234, so that after the memory page is reclaimed, the impact on the to-be-processed application is also small.
举例来说,回收比例可为30%,可回收内存页有100页,则从该100页的可回收内存页中回收30页的内存页,即释放出30页的可回收内存页,使得电子设备的空闲的内存页增加了30页,供给前台应用或其它的后台应用所使用。For example, if the recycling ratio is 30% and the recyclable memory page has 100 pages, then 30 pages of memory pages are reclaimed from the 100-page recyclable memory page, that is, 30 pages of recyclable memory pages are released, making the electronic The device's free memory pages are increased by 30 pages for use by foreground applications or other back-end applications.
上述的内存处理方法,通过获取待处理应用所占用的可回收内存页以及待处理应用被前台应用依赖的依赖比例,进而根据该依赖比例和可回收内存页确定回收数量,并从可回收内存页中选取回收数量的内存页进行回收,由于回收的对象是可回收内存页,且并非一定是对所有可回收内存页均进行回收,回收数量是根据待处理应用被前台应用依赖的依赖比例而确定,在降低回收了待处理应用占据的内存对前台应用的影响的同时,也降低了对待处理应用的运行影响,且回收的内存页可释放出来供其它应用使用,又提高了系统的综合处理效率,通过从可回收内存页中选取所确定的回收数量的内存页进行回收,保证在整个系统内存变大的情况下,对每个应用的负面影响最小,保持了对待处理应用内存的回收与运行之间的平衡性。The memory processing method described above obtains the reclaimed memory page occupied by the to-be-processed application and the dependency ratio of the to-be-processed application that is dependent on the foreground application, and then determines the amount of recycling according to the dependency ratio and the reclaimable memory page, and recovers the memory page from the reclaimable memory page. Select a reclaimed number of memory pages for recycling. Since the reclaimed objects are recyclable memory pages, and not all recyclable memory pages are reclaimed, the reclaimed quantity is determined according to the proportion of dependencies that the pending application is dependent on by the foreground application. While reducing the impact of the memory occupied by the pending application on the foreground application, it also reduces the operational impact of the application to be processed, and the reclaimed memory page can be released for use by other applications, thereby improving the overall processing efficiency of the system. Recycling by selecting the determined number of memory pages from the reclaimable memory page ensures that the negative impact on each application is minimized in the case where the entire system memory becomes large, and the recovery and operation of the application memory to be processed is maintained. The balance between.
在一个实施例中,操作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.
在一个实施例中,操作308包括:从可回收内存页中选取回收数量的、未被前台应用依赖的内存页进行回收。In one embodiment, operation 308 includes selecting a reclaimed number of memory pages that are not dependent on the foreground application for recycling from the reclaimable memory pages.
电子设备可进一步剔除被前台应用依赖的内存页,从未被前台应用依赖的可回收内存页中选取该回收数量的内存页,并对选取的内存页进行回收。其中,该回收数量可不超过未被前台应用依赖的内存页的数量。通过从未被前台应用依赖的内存页中选取该回收数量的内存页进行回收,可防止被前台应用依赖的内存页被回收而对前台应用造成影响。The electronic device can further eliminate the memory page that is relied upon by the foreground application, select the reclaimed memory page from the reclaimable memory page that is not depended by the foreground application, and recycle the selected memory page. The amount of recovery may not exceed the number of memory pages that are not dependent on the foreground application. By reclaiming the reclaimed memory page from a memory page that is not dependent on the foreground application, the memory pages that are relied upon by the foreground application are prevented from being recycled and affect the foreground application.
在一个实施例中,在操作306之前,还包括:获取与待处理应用对应的回收比例与二次启动时长之间的对应关系;操作306包括:根据可回收内存页、依赖比例和回收比例与二次启动时长之间的对应关系确定内存页的回收数量。In an embodiment, before the operation 306, the method further includes: obtaining a correspondence between a recycling ratio corresponding to the to-be-processed application and a secondary startup duration; the operation 306 includes: according to the reclaimable memory page, the dependency ratio, and the recycling ratio The correspondence between the secondary startup durations determines the amount of memory page reclaimed.
其中,二次启动时长是指待处理应用占用的可回收内存页被回收对应的回收比例后,再次启动时所花费的时长。电子设备可针对每个应用,设置相应的回收比例与二次启动时长之间的对应关系。该对应关系表示该应用所占内存中,回收不同比例的可回收内存后,对应的二次启动时长。可选地,该对应关系可为相应的回收比例与二次启动时长之间的对照表,或者回收比例曲线。该曲线为不同的回收比例下对应的二次启动时长。根据该对应关系,参照不同的二次启动时长来选取合适的回收比例,作为对该应用占用的可回收内存页的回收比例。The second startup duration refers to the length of time taken after the reclaimed memory page occupied by the application to be processed is recycled. The electronic device can set a corresponding relationship between the corresponding recycling ratio and the secondary startup time for each application. 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.
可选地,电子设备可设置对应的启动时长阈值,将二次启动时长达到该启动时长阈值时,对应的比例作为对可回收内存页的参考比例。启动时长阈值可为预设的经验数值,不同应用对应的启动时长阈值不一定相同。比如可根据对应应用的正常启动时长来确定对应的启动时长阈值,将正常启动时长的1.5倍或2倍的时长作为该启动时长阈值。参考比例表示对内存页回收比例的参考。根据确定的参考比例,再结合依赖比例以及可回收内存页的总数,确定对可回收内存页的回收数量。Optionally, the electronic device may set a corresponding startup duration threshold, and when the secondary startup duration reaches the startup duration threshold, the corresponding ratio is used as a reference ratio to the reclaimable memory page. The startup duration threshold may be a preset empirical value, and the startup duration thresholds of different applications may not be the same. For example, the corresponding startup time threshold may be determined according to the normal startup time of the corresponding application, and the duration of 1.5 times or 2 times of the normal startup time is used as the startup duration threshold. 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.
在一个实施例中,不同的应用类型的应用,其回收比例与二次启动时长之间的对应关系也不一定相同。该应用类型为根据对内存回收后,对待处理应用的运行影响而设置的类型。应用类型包括无关类、线性类以及非线性类。无关类表示对待处理应用的可回收内存回收后,无论回收多少,均对对应的应用并无显著影响。线性类表示随着对可回收内存的回收比例的增多,对应的应用的二次启动时长也随之增加,其中该二次启动时长与回收比例之间呈线性或接近线性增长的关系。非线性类表示既非无关类也非线性类的其它类型。其中,无显著影响表示不同回收比例对应的二次启动时长相比正常启动时长的超出比例均小于预设的比例范围。接近线性表示不同回收比例按照对应接近的斜率拟合出的二次启动时长,与对应回收比例下的二次启动时长之间的误差不超过预设范围内的误差。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, wherein 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.
举例来说,如图4A、4B至4C所示,分别为一个实施例中无关类、线性类和非线性类的应用的回收比例曲线。其中,该回收比例曲线中的横坐标表示回收比例,纵坐标表示处于对应回收比例下的二次启动时长。其中,无关类的回收比例曲线反映出了对应应用在可回收内存页在按不同的回收比例进行回收后,对应的二次启动时长没有变化或者变化很小。线性类的回收比例曲线在不同的回收比例下,对应的斜率没有变化或者变化很小,而非线性类的回收比例曲线则有的地方斜率较大,有的地方斜率相对较小。针对非线性类的应用,可选取最小斜率对应的回收比例,作为对可回收内存页的回收比例。For example, as shown in Figures 4A, 4B through 4C, the recovery ratio curves for applications of irrelevant, linear, and nonlinear classes, respectively, 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 non-linear applications, the recovery ratio corresponding to the minimum slope can be chosen as the recovery ratio for recyclable memory pages.
电子设备针对不同的应用,按照不同的回收比例回收内存后对应的二次启动时长,设置了该应用所属的应用类型,并设置与该应用类型对应的参考比例。根据该可回收内存页、依赖比例和参考比例确定对应的回收数量。进一步地,可根据该参考比例和依赖比例,确定对待处理应用占用的可回收内存页的回收比例,进而可将确定的回收比例与可回收内存页的总数相乘,计算的乘积作为回收数量。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.
通过按照该二次启动时长来确定回收数量,进一步保持了对待处理应用内存的回收与运行之间的平衡性。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.
在一个实施例中,操作308包括:从可回收内存页中按照内存页序号等间隔选取回收数量的内存页进行回收。In one embodiment, operation 308 includes reclaiming a reclaimed number of memory pages from the recyclable memory page at equal intervals of the memory page number.
可选地,电子设备可按照该回收数量,从可回收内存页中随机进行回收,或者从可回收内存页中按照内存页序号等间隔选取回收数量的内存页进行回收。其中,内存页序号为电子设备对内存页所设置的编号,可按照1、2、3等进行顺序编号。举例来说,当回收比例为33%时,所确定的均匀的回收间隔为每间隔2个内存页进行回收,比如可回收内存页为内存页1至内存页100,则可依次回收内存页1、内存页4、内存页7、内存页10…内存页97、内存页100,实现对33%的可回收内存页的回收。通过按照均匀间隔来进行回收,从而保证每一段连续的内存都不会被全部回收,使得应用重新打开时更稳定。Optionally, the electronic device may randomly collect the recovered memory pages according to the collected quantity, or select a collected number of memory pages from the recyclable memory page according to the serial number of the memory page for recycling. The memory page number is a number set by the electronic device to the memory page, and may be sequentially numbered according to 1, 2, 3, and the like. For example, when the recovery ratio is 33%, the determined uniform recovery interval is 2 memory pages per interval. For example, if the reclaimable memory page is from memory page 1 to memory page 100, the memory page 1 can be sequentially recovered. , memory page 4, memory page 7, memory page 10... memory page 97, memory page 100, to achieve the recovery of 33% of recyclable memory pages. By recycling at even intervals, each segment of memory is not completely reclaimed, making the application more stable when it is reopened.
在一个实施例中,操作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.
在一个实施例中,如图5所示,提供了另一种内存处理方法,该方法包括:In one embodiment, as shown in FIG. 5, another memory processing method is provided, the method comprising:
操作502,遍历待处理应用的内存映射文件;通过内存映射文件查询待处理应用占用的所有内存页。Operation 502: 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.
操作504,从所有内存页中剔除携带占用标记的内存页;从剔除后的内存页中获取可回收内存页。Operation 504, 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.
操作506,检测每个可回收内存页中存储的数据是否被前台应用依赖;根据检测结果确定待处理应用被前台应用依赖的依赖比例。Operation 506, detecting whether data stored in each recyclable memory page is dependent on the foreground application; determining, 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.
操作508,获取与待处理应用对应的回收比例与二次启动时长之间的对应关系。 Operation 508, obtaining a correspondence between the recovery ratio corresponding to the application to be processed and the secondary startup duration.
二次启动时长是指待处理应用占用的可回收内存页被回收对应的回收比例后,再次启动时所花费的时长。对应关系可为相应的回收比例与二次启动时长之间的对照表,或者回收比例曲线。该曲线为不同的回收比例下对应的二次启动时长,该曲线可为如图4A至4C中所示的曲线。该对应关系可根据超过预设次数的检测下,记录到的不同回收比例下,对应的二次启动时长而确定的。比如,可通过100次检测,每次可检测不同回收比例下,相应的二次启动时长,将相同比例下的二次启动时长的平均值,作为该对应关系中的回收比例所对应的二次启动时长。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 correspondence relationship 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-up duration at different recovery ratios, which may be the curves as shown in Figures 4A through 4C. The correspondence relationship may be determined according to the corresponding secondary detection duration under different detection ratios recorded under a preset number of times. For example, 100 tests can be performed, each time a different recovery ratio can be detected, and the corresponding secondary start time is long, and the average value of the secondary start time in the same ratio is taken as the second corresponding to the recovery ratio in the corresponding relationship. Startup time.
操作510,根据可回收内存页、依赖比例和回收比例与二次启动时长之间的对应关系确定内存页的回收数量。 Operation 510, determining the number of reclaimed memory pages according to a correspondence between the recyclable memory page, the dependency ratio, and the reclaim ratio and the secondary boot duration.
电子设备可根据回收比例与二次启动时长之间的对应关系,选取一个合适的比例作为 对应的参考比例,进而根据参考比例与该依赖比例确定对可回收内存页的回收比例,进而将确定的回收比例与可回收内存页总数的乘积作为回收数量。The electronic device may select an appropriate ratio as the corresponding reference ratio according to the correspondence between the recycling ratio and the secondary startup time, and then determine the recovery ratio of the recyclable memory page according to the reference ratio and the dependency ratio, and then determine the ratio. The product of the recycling ratio and the total number of recyclable memory pages is used as the recycling quantity.
在一个实施例中,根据该参考比例和依赖比例确定对可回收内存页的回收比例的可有多种,比如,记参考比例为a,依赖比例为b,对可回收内存页的回收比例为c。当a与b之和不大于1时,可直接取c=a;当a与b之和不大于1时,可直接取c=1-b。既提高了对回收比例计算的效率,有使得在保持后续回收的内存页均为不被前台应用依赖的内存页,且对待处理应用的影响较小的同时,回收尽量较多的内存页。In one embodiment, the recovery ratio of the recyclable memory page may be determined according to the reference ratio and the dependency ratio, for example, the reference ratio is a, the dependency ratio is b, and the recovery ratio of the recyclable memory page is c. When the sum of a and b is not more than 1, c=a can be taken directly; when the sum of a and b is not more than 1, c=1-b can be taken directly. It not only improves the efficiency of the calculation of the recovery ratio, but also makes the memory pages that are not subject to the foreground application depend on the memory pages that are subsequently recovered, and the effect of the application to be processed is small, and the memory pages are collected as much as possible.
操作512,从可回收内存页中选取回收数量的、未被前台应用依赖的内存页进行回收。In operation 512, a reclaimed memory page that is not dependent on the foreground application is selected from the reclaimable memory page for recycling.
在一个实施例中,可从未被前台应用依赖的内存页中按照内存页序号等间隔选取回收数量的内存页进行回收。In one embodiment, a reclaimed number of memory pages may be reclaimed from memory pages that are not dependent on the foreground application at equal intervals of the memory page number.
通过从未被前台应用依赖的内存页进行回收,可进一步降低对前台应用的影响。The impact on the foreground application can be further reduced by reclaiming memory pages that are not dependent on the foreground application.
应该理解的是,虽然图3和图5的流程图中的各个操作按照箭头的指示依次显示,但是这些操作并不是必然按照箭头指示的顺序依次执行。除非本文中有明确的说明,这些操作的执行并没有严格的顺序限制,这些操作可以以其它的顺序执行。而且,图3和图5中的至少一部分操作可以包括多个子操作或者多个阶段,这些子操作或者阶段并不必然是在同一时刻执行完成,而是可以在不同的时刻执行,这些子操作或者阶段的执行顺序也不必然是依次进行,而是可以与其它操作或者其它操作的子操作或者阶段的至少一部分轮流或者交替地执行。It should be understood that although the operations in the flowcharts of FIGS. 3 and 5 are sequentially displayed as indicated by 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 and 5 may include multiple sub-operations or multiple stages, which are not necessarily performed at the same time, but may be performed at different times, or The order of execution of the stages is also not necessarily sequential, but may be performed alternately or alternately with at least a portion of the sub-operations or stages of other operations or other operations.
在一个实施例中,如图6所示,提供了一种内存处理装置,该装置包括:内存页获取模块602、依赖确定模块604和内存回收模块606。其中,内存页获取模块602用于获取待处理应用所占用的可回收内存页;依赖确定模块604用于获取待处理应用被前台应用依赖的依赖比例;内存回收模块606用于根据可回收内存页和依赖比例确定对可回收内存页的回收数量;从可回收内存页中选取回收数量的内存页进行回收。In one embodiment, as shown in FIG. 6, an in-memory processing device is provided. The device includes a memory page acquisition module 602, a dependency determination module 604, and a memory recovery module 606. The memory page obtaining module 602 is configured to obtain a reclaimable memory page occupied by the to-be-processed application; the dependency determining module 604 is configured to obtain a dependency ratio of the to-be-processed application that is dependent on the foreground application; and the memory recycling module 606 is configured to use the reclaimable memory page. And the dependency ratio determines the amount of reclaimed reclaimable memory pages; select the reclaimed amount of memory pages from the reclaimable memory pages for recycling.
在一个实施例中,内存页获取模块602还用于查询待处理应用所占用的内存的所有内存页;从所有内存页中剔除携带占用标记的内存页;从剔除后的内存页中获取可回收内存页。In one embodiment, the memory page obtaining module 602 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.
在一个实施例中,内存页获取模块602还用于遍历待处理应用的内存映射文件;通过内存映射文件查询待处理应用占用的所有内存页。In one embodiment, the memory page obtaining module 602 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.
在一个实施例中,依赖确定模块604还用于检测每个可回收内存页中存储的数据是否被前台应用依赖;根据检测结果确定待处理应用被前台应用依赖的依赖比例;检测结果包括内存页未被前台应用依赖或被前台应用依赖。In one embodiment, the dependency determination module 604 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.
内存回收模块606还用于从可回收内存页中选取回收数量的、未被前台应用依赖的内存页进行回收。The memory reclamation module 606 is further configured to select, from the reclaimable memory page, a reclaimed number of memory pages that are not dependent on the foreground application for recycling.
在一个实施例中,内存回收模块606还用于获取与待处理应用对应的回收比例与二次启动时长之间的对应关系;二次启动时长是指待处理应用占用的可回收内存页被回收对应的回收比例后,再次启动时所花费的时长;根据可回收内存页、依赖比例和回收比例与二次启动时长之间的对应关系确定内存页的回收数量。In an embodiment, the memory recovery module 606 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 number of memory pages to be recycled based on the correspondence between the recyclable memory page, the dependency ratio, and the recycling ratio and the secondary startup duration.
在一个实施例中,内存回收模块606还用于从可回收内存页中按照内存页序号等间隔选取回收数量的内存页进行回收。In one embodiment, the memory reclamation module 606 is further configured to reclaim a reclaimed number of memory pages from the recyclable memory page at equal intervals of the memory page number.
在一个实施例中,依赖确定模块604还用于当待处理应用与前台应用之间存在通信机制或同步机制时,判定待处理应用被前台应用依赖。In one embodiment, the dependency determination module 604 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 above-mentioned memory processing device determines the amount of recycling according to the dependency ratio and the recyclable memory page, and obtains the reclaimed memory page according to the dependency ratio and the reclaimable memory page, by acquiring the recyclable memory page occupied by the application to be processed and the dependency ratio of the to-be-processed application being relied upon by the foreground application. Select a reclaimed number of memory pages for recycling. Since the reclaimed objects are recyclable memory pages, and not all recyclable memory pages are reclaimed, the reclaimed quantity is determined according to the proportion of dependencies that the pending application is dependent on by the foreground application. While reducing the impact of the memory occupied by the pending application on the foreground application, it also reduces the operational impact of the application to be processed, and the reclaimed memory page can be released for use by other applications, thereby improving the overall processing efficiency of the system. Recycling by selecting the determined number of memory pages from the reclaimable memory page ensures that the negative impact on each application is minimized in the case where the entire system memory becomes large, and the recovery and operation of the application memory to be processed is maintained. The balance between.
上述内存处理装置中各个模块的划分仅用于举例说明,在其他实施例中,可将内存处理装置按照需要划分为不同的模块,以完成上述内存处理装置的全部或部分功能。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.
本申请实施例还提供了一种计算机设备。如图7所示,为了便于说明,仅示出了与本申请实施例相关的部分,具体技术细节未揭示的,请参照本申请实施例方法部分。该计算机设备可以为包括手机、平板电脑、PDA(Personal Digital Assistant,个人数字助理)、POS(Point of Sales,销售终端)、车载电脑、穿戴式设备等任意终端设备,以计算机设备为手机为例:The embodiment of the present application also provides a computer device. As shown in FIG. 7 , for the convenience of description, only the parts related to the embodiments of the present application are shown. If the specific technical details are not disclosed, please 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. :
图7为与本申请实施例提供的计算机设备相关的手机的部分结构的框图。参考图7,手机包括:射频(Radio Frequency,RF)电路710、存储器720、输入单元730、显示单元740、传感器750、音频电路760、无线保真(wireless fidelity,WiFi)模块770、处理器780、以及电源790等部件。本领域技术人员可以理解,图7所示的手机结构并不构成对手机的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置。FIG. 7 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. 7, the mobile phone includes: a radio frequency (RF) circuit 710, a memory 720, an input unit 730, a display unit 740, a sensor 750, an audio circuit 760, a wireless fidelity (WiFi) module 770, and a processor 780. And power supply 790 and other components. It will be understood by those skilled in the art that the structure of the mobile phone shown in FIG. 7 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电路710可用于收发信息或通话过程中,信号的接收和发送,可将基站的下行信息接收后,给处理器780处理;也可以将上行的数据发送给基站。通常,RF电路包括但不限于天线、至少一个放大器、收发信机、耦合器、低噪声放大器(Low Noise Amplifier,LNA)、双工器等。此外,RF电路710还可以通过无线通信与网络和其他设备通信。上述无线通信可以使用任一通信标准或协议,包括但不限于全球移动通讯系统(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 710 can be used for receiving and transmitting signals during the transmission and reception of information or during a call. The downlink information of the base station can be received and processed by the processor 780. The uplink data can also be sent 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 710 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.
存储器720可用于存储软件程序以及模块,处理器780通过运行存储在存储器720的软件程序以及模块,从而执行手机的各种功能应用以及数据处理。存储器720可主要包括 程序存储区和数据存储区,其中,程序存储区可存储操作系统、至少一个功能所需的应用程序(比如声音播放功能的应用程序、图像播放功能的应用程序等)等;数据存储区可存储根据手机的使用所创建的数据(比如音频数据、通讯录等)等。此外,存储器720可以包括高速随机存取存储器,还可以包括非易失性存储器,例如至少一个磁盘存储器件、闪存器件、或其他易失性固态存储器件。The memory 720 can be used to store software programs and modules, and the processor 780 executes various functional applications and data processing of the mobile phone by running software programs and modules stored in the memory 720. The memory 720 can mainly include a program storage area and a data storage area, wherein the program storage area can 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 720 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.
输入单元730可用于接收输入的数字或字符信息,以及产生与手机700的用户设置以及功能控制有关的键信号输入。具体地,输入单元730可包括触控面板731以及其他输入设备732。触控面板731,也可称为触摸屏,可收集用户在其上或附近的触摸操作(比如用户使用手指、触笔等任何适合的物体或附件在触控面板731上或在触控面板731附近的操作),并根据预先设定的程式驱动相应的连接装置。在一个实施例中,触控面板731可包括触摸检测装置和触摸控制器两个部分。其中,触摸检测装置检测用户的触摸方位,并检测触摸操作带来的信号,将信号传送给触摸控制器;触摸控制器从触摸检测装置上接收触摸信息,并将它转换成触点坐标,再送给处理器780,并能接收处理器780发来的命令并加以执行。此外,可以采用电阻式、电容式、红外线以及表面声波等多种类型实现触控面板731。除了触控面板731,输入单元730还可以包括其他输入设备732。具体地,其他输入设备732可以包括但不限于物理键盘、功能键(比如音量控制按键、开关按键等)等中的一种或多种。The input unit 730 can be configured to receive input numeric or character information and to generate key signal inputs related to user settings and function controls of the handset 700. Specifically, the input unit 730 may include a touch panel 731 and other input devices 732. The touch panel 731, 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 731 or near the touch panel 731. Operation) and drive the corresponding connection device according to a preset program. In one embodiment, the touch panel 731 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 780 is provided and can receive commands from the processor 780 and execute them. In addition, the touch panel 731 can be implemented in various types such as resistive, capacitive, infrared, and surface acoustic waves. In addition to the touch panel 731, the input unit 730 may also include other input devices 732. In particular, other input devices 732 may include, but are not limited to, one or more of a physical keyboard, function keys (such as volume control buttons, switch buttons, etc.).
显示单元740可用于显示由用户输入的信息或提供给用户的信息以及手机的各种菜单。显示单元740可包括显示面板741。在一个实施例中,可以采用液晶显示器(Liquid Crystal Display,LCD)、有机发光二极管(Organic Light-Emitting Diode,OLED)等形式来配置显示面板741。在一个实施例中,触控面板731可覆盖显示面板741,当触控面板731检测到在其上或附近的触摸操作后,传送给处理器780以确定触摸事件的类型,随后处理器780根据触摸事件的类型在显示面板741上提供相应的视觉输出。虽然在图7中,触控面板731与显示面板741是作为两个独立的部件来实现手机的输入和输入功能,但是在某些实施例中,可以将触控面板731与显示面板741集成而实现手机的输入和输出功能。The display unit 740 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 740 can include a display panel 741. In one embodiment, the display panel 741 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 731 can cover the display panel 741. When the touch panel 731 detects a touch operation on or near it, the touch panel 731 transmits to the processor 780 to determine the type of the touch event, and then the processor 780 is The type of touch event provides a corresponding visual output on display panel 741. Although the touch panel 731 and the display panel 741 are used as two independent components to implement the input and input functions of the mobile phone in FIG. 7, in some embodiments, the touch panel 731 can be integrated with the display panel 741. Realize the input and output functions of the phone.
手机700还可包括至少一种传感器750,比如光传感器、运动传感器以及其他传感器。具体地,光传感器可包括环境光传感器及接近传感器,其中,环境光传感器可根据环境光线的明暗来调节显示面板741的亮度,接近传感器可在手机移动到耳边时,关闭显示面板741和/或背光。运动传感器可包括加速度传感器,通过加速度传感器可检测各个方向上加速度的大小,静止时可检测出重力的大小及方向,可用于识别手机姿态的应用(比如横竖屏切换)、振动识别相关功能(比如计步器、敲击)等;此外,手机还可配置陀螺仪、气压计、湿度计、温度计、红外线传感器等其他传感器等。The handset 700 can also include at least one type of sensor 750, 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 741 according to the brightness of the ambient light, and the proximity sensor may close the display panel 741 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.
音频电路760、扬声器761和传声器762可提供用户与手机之间的音频接口。音频电路760可将接收到的音频数据转换后的电信号,传输到扬声器761,由扬声器761转换为声音信号输出;另一方面,传声器762将收集的声音信号转换为电信号,由音频电路760接收后转换为音频数据,再将音频数据输出处理器780处理后,经RF电路710可以发送给另一手机,或者将音频数据输出至存储器720以便后续处理。 Audio circuitry 760, speaker 761, and microphone 762 can provide an audio interface between the user and the handset. The audio circuit 760 can transmit the converted electrical data of the received audio data to the speaker 761 for conversion to the sound signal output by the speaker 761; on the other hand, the microphone 762 converts the collected sound signal into an electrical signal by the audio circuit 760. After receiving, it is converted into audio data, and then processed by the audio data output processor 780, transmitted to another mobile phone via the RF circuit 710, or outputted to the memory 720 for subsequent processing.
WiFi属于短距离无线传输技术,手机通过WiFi模块770可以帮助用户收发电子邮件、浏览网页和访问流式媒体等,它为用户提供了无线的宽带互联网访问。虽然图7示出了WiFi模块770,但是可以理解的是,其并不属于手机700的必须构成,可以根据需要而省略。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 770, which provides users with wireless broadband Internet access. Although FIG. 7 shows the WiFi module 770, it can be understood that it does not belong to the essential configuration of the mobile phone 700 and can be omitted as needed.
处理器780是手机的控制中心,利用各种接口和线路连接整个手机的各个部分,通过运行或执行存储在存储器720内的软件程序和/或模块,以及调用存储在存储器720内的数据,执行手机的各种功能和处理数据,从而对手机进行整体监控。在一个实施例中,处理器780可包括一个或多个处理单元。在一个实施例中,处理器780可集成应用处理器和 调制解调器,其中,应用处理器主要处理操作系统、用户界面和应用程序等;调制解调器主要处理无线通信。可以理解的是,上述调制解调器也可以不集成到处理器780中。比如,该处理器780可集成应用处理器和基带处理器,基带处理器与和其它外围芯片等可组成调制解调器。手机700还包括给各个部件供电的电源790(比如电池),优选的,电源可以通过电源管理系统与处理器780逻辑相连,从而通过电源管理系统实现管理充电、放电、以及功耗管理等功能。The processor 780 is the control center of the handset, which 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 720, and invoking data stored in the memory 720, The phone's various functions and processing data, so that the overall monitoring of the phone. In one embodiment, processor 780 can include one or more processing units. In one embodiment, processor 780 can integrate an application processor and a modem, where the application processor primarily processes an operating system, user interface, applications, etc.; the modem primarily handles wireless communications. It will be appreciated that the above described modem may also not be integrated into the processor 780. For example, the processor 780 can integrate an application processor and a baseband processor, and the baseband processor and other peripheral chips can form a modem. The handset 700 also includes a power source 790 (such as a battery) that supplies power to the various components. Preferably, the power source can be logically coupled to the processor 780 via a power management system to manage functions such as charging, discharging, and power management through the power management system.
在一个实施例中,手机700还可以包括摄像头、蓝牙模块等。In one embodiment, the handset 700 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)

  1. 一种内存处理方法,其特征在于,包括: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;
    根据所述可回收内存页和所述依赖比例确定对所述可回收内存页的回收数量;及Determining the amount of recycling of the recyclable memory page according to the recyclable memory page and the dependency ratio; and
    从所述可回收内存页中选取所述回收数量的内存页进行回收。The recovered number of memory pages are selected from the recyclable memory pages for recycling.
  2. 根据权利要求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 the data stored in each recyclable memory page is dependent on the foreground application;
    根据检测结果确定所述待处理应用被前台应用依赖的依赖比例;所述检测结果包括内存页未被前台应用依赖或被前台应用依赖。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.
  3. 根据权利要求2所述的方法,其特征在于,所述从所述可回收内存页中选取所述回收数量的内存页进行回收,包括:The method according to claim 2, wherein said retrieving said recovered number of memory pages from said recyclable memory page for recycling comprises:
    从所述可回收内存页中选取所述回收数量的、未被前台应用依赖的内存页进行回收。The recycled number of memory pages that are not depended by the foreground application are selected from the reclaimable memory pages for recycling.
  4. 根据权利要求2所述的方法,其特征在于,所述检测每个可回收内存页中存储的数据是否被前台应用依赖,包括:The method according to claim 2, wherein said detecting whether data stored in each recyclable memory page is dependent on a foreground application comprises:
    当所述前台应用在预设时间段内使用所述可回收内存页中存储的数据时,判定所述可回收内存页被所述前台应用依赖。When the foreground application uses data stored in the recyclable memory page within a preset time period, it is determined that the recyclable memory page is dependent on the foreground application.
  5. 根据权利要求1所述的方法,其特征在于,所述根据所述可回收内存页和所述依赖比例确定对所述可回收内存页的回收数量,包括:The method according to claim 1, wherein the determining the amount of recycling of the recyclable memory page according to the recyclable memory page and the dependency ratio comprises:
    根据所述依赖比例确定对所述可回收内存页的回收比例;Determining a recycling ratio of the recyclable memory page according to the dependency ratio;
    根据所述回收比例以及所述可回收内存页的总数确定对所述可回收内存页的回收数量。The amount of recycling of the recyclable memory page is determined based on the recycling ratio and the total number of recyclable memory pages.
  6. 根据权利要求1所述的方法,其特征在于,在所述根据所述可回收内存页和所述依赖比例确定对所述可回收内存页的回收数量之前,还包括:The method according to claim 1, further comprising: before determining the amount of recycling of the recyclable memory page according to the recyclable memory page and the dependency ratio, further comprising:
    获取与所述待处理应用对应的回收比例与二次启动时长之间的对应关系;所述二次启动时长是指所述待处理应用占用的可回收内存页被回收对应的回收比例后,再次启动时所花费的时长;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, according to the recyclable memory page and the dependency ratio, a quantity of the reclaimed memory page, including:
    根据所述可回收内存页、所述依赖比例和所述回收比例与二次启动时长之间的对应关系确定所述内存页的回收数量。And determining, according to the recyclable memory page, the dependency ratio, and the correspondence between the recycling ratio and the secondary startup duration, the number of the memory pages to be recovered.
  7. 根据权利要求6所述的方法,其特征在于,所述根据所述可回收内存页、所述依赖比例和所述回收比例与二次启动时长之间的对应关系确定所述内存页的回收数量,包括:The method according to claim 6, wherein the determining the number of reclaimed memory pages according to the correspondence between the recyclable memory page, the dependency ratio, and the recovery ratio and the secondary startup duration ,include:
    按照所述二次启动时长为应用配置所属的应用类型,并为所述应用类型配置对应的参考比例;And configuring, according to the second startup duration, an application type to which the application belongs, and configuring a corresponding reference ratio for the application type;
    根据所述参考比例和所述依赖比例,确定所述回收比例;Determining the recovery ratio according to the reference ratio and the dependency ratio;
    根据所述回收比例与所述回收内存页的总数处理得到所述内存页的回收数量。The amount of recycling of the memory page is obtained according to the recycling ratio and the total number of the recycled memory pages.
  8. 根据权利要求1所述的方法,其特征在于,所述从所述可回收内存页中选取所述回收数量的内存页进行回收,包括:The method according to claim 1, wherein said retrieving said recovered number of memory pages from said recyclable memory page for recycling comprises:
    从所述可回收内存页中按照内存页序号等间隔选取所述回收数量的内存页进行回收。The recovered number of memory pages are selected from the recyclable memory pages at equal intervals according to the memory page number for recycling.
  9. 根据权利要求1所述的方法,其特征在于,所述获取待处理应用所占用的可回收内存页,包括:The method according to claim 1, wherein the obtaining a recyclable memory page occupied by the application to be processed comprises:
    遍历待处理应用的内存映射文件;Traversing the memory mapped file of the pending application;
    通过所述内存映射文件查询所述待处理应用占用的所有内存页;Querying, by the memory mapping file, all memory pages occupied by the to-be-processed application;
    从所述所有内存页中剔除携带占用标记的内存页;Removing the memory page carrying the occupied mark from all the memory pages;
    从剔除后的内存页中获取可回收内存页。Get reclaimable memory pages from the stripped memory page.
  10. 根据权利要求1至9中任一项所述的方法,其特征在于,还包括:The method according to any one of claims 1 to 9, further comprising:
    当所述待处理应用与前台应用之间存在通信机制或同步机制时,判定所述待处理应用被前台应用依赖。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.
  11. 一种电子设备,包括存储器及处理器,所述存储器中储存有计算机程序,其特征在于,所述计算机程序被所述处理器执行时,使得所述处理器执行如下操作: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;
    根据所述可回收内存页和所述依赖比例确定对所述可回收内存页的回收数量;及Determining the amount of recycling of the recyclable memory page according to the recyclable memory page and the dependency ratio; and
    从所述可回收内存页中选取所述回收数量的内存页进行回收。The recovered number of memory pages are selected from the recyclable memory pages for recycling.
  12. 根据权利要求11所述的电子设备,其特征在于,所述处理器执行获取所述待处理应用被前台应用依赖的依赖比例,还执行以下操作:检测每个可回收内存页中存储的数据是否被前台应用依赖;The electronic device according to claim 11, wherein the processor performs acquisition of a dependency ratio of the to-be-processed application that is dependent on the foreground application, and further performs an operation of: detecting whether data stored in each recyclable memory page is Rely on the foreground application;
    根据检测结果确定所述待处理应用被前台应用依赖的依赖比例;所述检测结果包括内存页未被前台应用依赖或被前台应用依赖。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.
  13. 根据权利要求12所述的电子设备,其特征在于,所述处理器执行从所述可回收内存页中选取所述回收数量的内存页进行回收,还执行以下操作:The electronic device according to claim 12, wherein the processor performs the process of selecting the recovered number of memory pages from the recyclable memory page for recycling, and further performing the following operations:
    从所述可回收内存页中选取所述回收数量的、未被前台应用依赖的内存页进行回收。The recycled number of memory pages that are not depended by the foreground application are selected from the reclaimable memory pages for recycling.
  14. 根据权利要求12所述的电子设备,其特征在于,所述处理器执行检测每个可回收内存页中存储的数据是否被前台应用依赖,还执行以下操作:The electronic device according to claim 12, wherein the processor performs a process of detecting whether data stored in each recyclable memory page is dependent on the foreground application, and further performs the following operations:
    当所述前台应用在预设时间段内使用所述可回收内存页中存储的数据时,判定所述可回收内存页被所述前台应用依赖。When the foreground application uses data stored in the recyclable memory page within a preset time period, it is determined that the recyclable memory page is dependent on the foreground application.
  15. 根据权利要求11所述的电子设备,其特征在于,所述处理器执行所述根据所述可回收内存页和所述依赖比例确定对所述可回收内存页的回收数量,还执行以下操作:The electronic device according to claim 11, wherein the processor performs the determining the amount of recycling of the recyclable memory page according to the recyclable memory page and the dependency ratio, and further performs the following operations:
    根据所述依赖比例确定对所述可回收内存页的回收比例;Determining a recycling ratio of the recyclable memory page according to the dependency ratio;
    根据所述回收比例以及所述可回收内存页的总数确定对所述可回收内存页的回收数量。The amount of recycling of the recyclable memory page is determined based on the recycling ratio and the total number of recyclable memory pages.
  16. 根据权利要求11所述的电子设备,其特征在于,所述处理器执行所述根据所述可回收内存页和所述依赖比例确定对所述可回收内存页的回收数量之前,还执行以下操作:The electronic device according to claim 11, wherein the processor performs the following operations before performing the determining, according to the recyclable memory page and the dependency ratio, the number of reclaimed memory pages. :
    获取与所述待处理应用对应的回收比例与二次启动时长之间的对应关系;所述二次启动时长是指所述待处理应用占用的可回收内存页被回收对应的回收比例后,再次启动时所花费的时长;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;
    所述处理器执行所述根据所述可回收内存页和所述依赖比例确定对所述可回收内存页的回收数量,还执行以下操作:The processor performs the determining, according to the recyclable memory page and the dependency ratio, a quantity of the reclaimed memory page, and further performing the following operations:
    根据所述可回收内存页、所述依赖比例和所述回收比例与二次启动时长之间的对应关系确定所述内存页的回收数量。And determining, according to the recyclable memory page, the dependency ratio, and the correspondence between the recycling ratio and the secondary startup duration, the number of the memory pages to be recovered.
  17. 根据权利要求11所述的电子设备,其特征在于,所述处理器执行从所述可回收内存页中选取所述回收数量的内存页进行回收,还执行以下操作:The electronic device according to claim 11, wherein the processor performs the process of selecting the recovered number of memory pages from the recyclable memory page for recycling, and further performing the following operations:
    从所述可回收内存页中按照内存页序号等间隔选取所述回收数量的内存页进行回收。The recovered number of memory pages are selected from the recyclable memory pages at equal intervals according to the memory page number for recycling.
  18. 根据权利要求11所述的电子设备,其特征在于,所述处理器执行所述获取待处理应用所占用的可回收内存页,还执行以下操作:The electronic device according to claim 11, wherein the processor executes the retrievable memory page occupied by the to-be-processed application, and further performs the following operations:
    遍历待处理应用的内存映射文件;Traversing the memory mapped file of the pending application;
    通过所述内存映射文件查询所述待处理应用占用的所有内存页;Querying, by the memory mapping file, all memory pages occupied by the to-be-processed application;
    从所述所有内存页中剔除携带占用标记的内存页;Removing the memory page carrying the occupied mark from all the memory pages;
    从剔除后的内存页中获取可回收内存页。Get reclaimable memory pages from the stripped memory page.
  19. 根据权利要求11至18所述的电子设备,其特征在于,所述处理器还执行以下操作:The electronic device according to any one of claims 11 to 18, wherein the processor further performs the following operations:
    当所述待处理应用与前台应用之间存在通信机制或同步机制时,判定所述待处理应用被前台应用依赖。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.
  20. 一种计算机可读存储介质,其上存储有计算机程序,其特征在于,所述计算机程序被处理器执行时实现如权利要求1至10中任一项所述方法的步骤。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 10.
PCT/CN2018/125225 2018-01-10 2018-12-29 Memory processing method, electronic device, and computer-readable storage medium WO2019137252A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201810023232.7A CN110018902B (en) 2018-01-10 2018-01-10 Memory processing method and device, electronic equipment and computer readable storage medium
CN201810023232.7 2018-01-10

Publications (1)

Publication Number Publication Date
WO2019137252A1 true WO2019137252A1 (en) 2019-07-18

Family

ID=67188123

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2018/125225 WO2019137252A1 (en) 2018-01-10 2018-12-29 Memory processing method, electronic device, and computer-readable storage medium

Country Status (2)

Country Link
CN (1) CN110018902B (en)
WO (1) WO2019137252A1 (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113392037A (en) * 2020-03-12 2021-09-14 深圳市万普拉斯科技有限公司 Memory recovery method and device, computer equipment and storage medium
CN115729684A (en) * 2021-08-25 2023-03-03 荣耀终端有限公司 Input/output request processing method and electronic equipment

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110727607B (en) * 2019-09-27 2022-08-12 Oppo广东移动通信有限公司 Memory recovery method and device and electronic equipment
CN110727606A (en) * 2019-09-27 2020-01-24 Oppo(重庆)智能科技有限公司 Memory recovery method and device and electronic equipment
CN110888821B (en) * 2019-09-30 2023-10-20 华为技术有限公司 Memory management method and device
CN111625351A (en) * 2020-05-12 2020-09-04 Oppo(重庆)智能科技有限公司 Method and device for recycling file pages, terminal and readable storage medium
CN113268438B (en) * 2021-05-19 2024-03-08 维沃移动通信有限公司 Memory recycling method and device and electronic equipment

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103150259A (en) * 2013-03-22 2013-06-12 华为技术有限公司 Memory recovery method and device
CN103577335A (en) * 2013-10-23 2014-02-12 中国科学院计算技术研究所 Memory garbage recycling system and method
CN105159777A (en) * 2015-08-03 2015-12-16 中科创达软件股份有限公司 Process memory collection method and apparatus
CN106843758A (en) * 2011-05-23 2017-06-13 中兴通讯股份有限公司 A kind of mobile device EMS memory management process and device
CN107133182A (en) * 2016-02-29 2017-09-05 北大方正集团有限公司 A kind of EMS memory management process and device

Family Cites Families (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080005190A1 (en) * 2006-06-28 2008-01-03 Nokia Corporation System, Method, Apparatus and Computer Program Product for Providing Resource Reclamation in a Virtual Machine
CN103890724B (en) * 2011-08-19 2017-04-19 株式会社东芝 Information processing apparatus, method for controlling information processing apparatus, host device, and performance evaluation method used for external storage device
CN103092700B (en) * 2013-02-01 2016-09-28 华为终端有限公司 Internal memory method for cleaning, device and terminal unit
CN103324500B (en) * 2013-05-06 2016-08-31 广州市动景计算机科技有限公司 A kind of method and device reclaiming internal memory
US10552179B2 (en) * 2014-05-30 2020-02-04 Apple Inc. Resource management with dynamic resource policies
CN105279098B (en) * 2014-07-22 2019-02-12 中兴通讯股份有限公司 The method for cleaning and device of memory
CN105988823B (en) * 2015-01-27 2019-10-22 阿里巴巴集团控股有限公司 Memory allocation method and its system when in terminal using starting
CN106569733A (en) * 2015-10-12 2017-04-19 北京国双科技有限公司 Processing method and processing device for buffered data
CN105701025B (en) * 2015-12-31 2019-07-23 华为技术有限公司 A kind of method for recovering internal storage and device
CN105843650B (en) * 2016-03-31 2020-03-31 青岛海信移动通信技术股份有限公司 Application program management method and device in intelligent terminal
CN106331148A (en) * 2016-09-14 2017-01-11 郑州云海信息技术有限公司 Cache management method and cache management device for data reading by clients
CN107102878A (en) * 2017-04-27 2017-08-29 努比亚技术有限公司 One kind application startup method, mobile terminal and computer-readable recording medium
CN107463437B (en) * 2017-07-31 2020-01-31 Oppo广东移动通信有限公司 Application control method and device, storage medium and electronic equipment

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106843758A (en) * 2011-05-23 2017-06-13 中兴通讯股份有限公司 A kind of mobile device EMS memory management process and device
CN103150259A (en) * 2013-03-22 2013-06-12 华为技术有限公司 Memory recovery method and device
CN103577335A (en) * 2013-10-23 2014-02-12 中国科学院计算技术研究所 Memory garbage recycling system and method
CN105159777A (en) * 2015-08-03 2015-12-16 中科创达软件股份有限公司 Process memory collection method and apparatus
CN107133182A (en) * 2016-02-29 2017-09-05 北大方正集团有限公司 A kind of EMS memory management process and device

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113392037A (en) * 2020-03-12 2021-09-14 深圳市万普拉斯科技有限公司 Memory recovery method and device, computer equipment and storage medium
CN115729684A (en) * 2021-08-25 2023-03-03 荣耀终端有限公司 Input/output request processing method and electronic equipment
CN115729684B (en) * 2021-08-25 2023-09-19 荣耀终端有限公司 Input/output request processing method and electronic equipment

Also Published As

Publication number Publication date
CN110018902A (en) 2019-07-16
CN110018902B (en) 2023-01-31

Similar Documents

Publication Publication Date Title
US11099900B2 (en) Memory reclamation method and apparatus
WO2019137252A1 (en) Memory processing method, electronic device, and computer-readable storage medium
WO2019137258A1 (en) Memory processing method, electronic device and computer readable storage medium
CN109992523B (en) Memory processing method and device, electronic equipment and computer readable 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
WO2019128540A1 (en) Resource management method, mobile terminal and computer readable storage medium
EP3937016A1 (en) Memory management method and apparatus
WO2019128546A1 (en) Application program processing method, electronic device, and computer readable storage medium
CN110018901B (en) Memory recovery method and device, computer equipment and computer readable storage medium
WO2019128588A1 (en) Process processing method and apparatus, electronic device, computer readable storage medium
CN110032266B (en) Information processing method, information processing device, computer equipment and computer readable storage medium
WO2019128537A1 (en) Application freezing method, and computer device and computer-readable storage medium
WO2019128574A1 (en) Information processing method and device, computer device and computer readable storage medium
WO2019128571A1 (en) Resource management method and device, mobile terminal, as well as computer readable storage medium
WO2019128573A1 (en) Information processing method, apparatus, computer device and computer-readable storage medium
WO2019128569A1 (en) Method and apparatus for freezing application, and storage medium and terminal
CN110018886B (en) Application state switching method and device, electronic equipment and readable storage medium
CN103793267A (en) Queue access method and device
WO2019128542A1 (en) Application processing method, electronic device, computer readable storage medium
WO2019137173A1 (en) Resource management method, mobile terminal and computer-readable storage medium
CN112445766A (en) Terminal fragment sorting method and device 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
WO2019128570A1 (en) Method and apparatus for freezing application, and storage medium and terminal

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

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

Country of ref document: EP

Kind code of ref document: A1