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

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

Info

Publication number
CN110018902B
CN110018902B CN201810023232.7A CN201810023232A CN110018902B CN 110018902 B CN110018902 B CN 110018902B CN 201810023232 A CN201810023232 A CN 201810023232A CN 110018902 B CN110018902 B CN 110018902B
Authority
CN
China
Prior art keywords
application
memory
recovery
memory pages
proportion
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201810023232.7A
Other languages
Chinese (zh)
Other versions
CN110018902A (en
Inventor
陈岩
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guangdong Oppo Mobile Telecommunications Corp Ltd
Original Assignee
Guangdong Oppo Mobile Telecommunications Corp Ltd
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 Guangdong Oppo Mobile Telecommunications Corp Ltd filed Critical Guangdong Oppo Mobile Telecommunications Corp Ltd
Priority to CN201810023232.7A priority Critical patent/CN110018902B/en
Priority to PCT/CN2018/125225 priority patent/WO2019137252A1/en
Publication of CN110018902A publication Critical patent/CN110018902A/en
Application granted granted Critical
Publication of CN110018902B publication Critical patent/CN110018902B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

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

Abstract

The application relates to a memory processing method and device, electronic equipment and a computer readable storage medium. The method comprises the following steps: acquiring a recoverable memory page occupied by the application to be processed; acquiring the dependence proportion of the application to be processed, which is depended on by foreground application; determining the recovery quantity of the recoverable memory pages according to the recoverable memory pages and the dependence proportion; and selecting the memory pages with the recovery quantity from the recoverable memory pages for recovery. The memory processing method and device, the electronic equipment and the computer readable storage medium can ensure that the negative influence on each application is minimum under the condition that the memory of the whole system is increased, and keep the balance between the recovery and the operation of the memory of the application to be processed.

Description

Memory processing method and device, electronic equipment and computer readable storage medium
Technical Field
The present application relates to the field of data processing, and in particular, to a memory processing method and apparatus, an electronic device, and a computer-readable storage medium.
Background
When the application installed on the electronic device runs, a certain memory is occupied. Memory is a primary storage medium for data during operation. Due to the limited memory capacity of the electronic device, when the background application occupies too much memory, the operation efficiency of the foreground application is affected. Therefore, the memory needs to be recycled to improve the operating efficiency of the foreground application.
The traditional method for processing the memory is to completely recycle the memory occupied by a single application running in the background. However, completely recycling the memory used by a single application will cause almost all the recycled memory to be reloaded back during the next startup and execution of the application, resulting in a significant reduction in the running speed of the application with recycled memory.
Disclosure of Invention
Embodiments of the present application provide a memory processing method and apparatus, an electronic device, and a computer-readable storage medium, which can reduce the influence on the operation of an application of a recycled memory while improving the operation efficiency of a foreground application.
A memory processing method includes: acquiring a recoverable memory page occupied by the application to be processed; acquiring the dependence proportion of the application to be processed, which is depended on by foreground application; determining the recovery quantity of the recoverable memory pages according to the recoverable memory pages and the dependence proportion; and selecting the memory pages with the recovery quantity from the recoverable memory pages for recovery.
A memory processing device, the device comprising: a memory page acquisition module, configured to acquire a recoverable memory page occupied by the application to be processed; the dependency determining module is used for acquiring the dependency proportion of the application to be processed, which is depended on by the foreground application; the memory recovery module is used for determining the recovery quantity of the recoverable memory pages according to the recoverable memory pages and the dependence proportion; and selecting the memory pages with the recovery quantity from the recoverable memory pages for recovery.
An electronic device includes a memory and a processor, where the memory stores a computer program, and the computer program, when executed by the processor, causes the processor to execute the steps of the memory processing method described in the embodiments of the present application.
A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, implements the steps of the memory processing method described in the embodiments of the present application.
According to the memory processing method and device, the electronic device and the computer readable storage medium, the recoverable memory pages occupied by the to-be-processed application and the dependency proportion of the to-be-processed application depended on by the foreground application are obtained, the recovery quantity is determined according to the dependency proportion and the recoverable memory pages, and the memory pages with the recovery quantity are selected from the recoverable memory pages to be recovered.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present application, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
FIG. 1 is a schematic diagram showing an internal structure of an electronic apparatus according to an embodiment;
FIG. 2 is a partial block diagram of a system in an electronic device in one embodiment;
FIG. 3 is a flow diagram of a method for memory processing according to one embodiment;
FIG. 4A is a graph illustrating a recycle proportion curve for unrelated class applications in one embodiment;
FIG. 4B is a graph illustrating recovery ratios for linear class applications in one embodiment;
FIG. 4C is a graph illustrating recovery ratios for non-linear class applications in one embodiment;
FIG. 5 is a flow chart of a memory processing method in another embodiment;
FIG. 6 is a block diagram of a memory processing device in accordance with one embodiment;
fig. 7 is a block diagram of a partial structure of a cellular phone in one embodiment.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
In one embodiment, as shown in FIG. 1, a schematic diagram of an internal structure of an electronic device is provided. The electronic device includes a processor, a memory, and a display screen connected by a system bus. Wherein, the processor is used for providing calculation and control capability and supporting the operation of the whole electronic equipment. The memory is used for storing data, programs, and/or instruction codes, and the like, and the memory stores at least one computer program which can be executed by the processor to implement the memory processing method suitable for the electronic device provided in the embodiment 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-Access-Memory (RAM). For example, in one embodiment, the memory includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a database, and a computer program. The database stores data related to implementing a memory processing method provided in the above embodiments, for example, information such as a name of each application and a memory page allocated to each application may be stored. The computer program can be executed by a processor to implement a memory processing method provided by various embodiments of the present application. The internal memory provides a cached operating environment for the operating system, databases, and computer programs in the non-volatile storage medium. The display screen may be a touch screen, such as a capacitive screen or an electronic screen, and is used to display interface display information of foreground application, and may also be used to detect a touch operation acting on the display screen, and generate a corresponding instruction, such as a switching instruction for foreground and background application, and the like.
It will be appreciated by those skilled in the art that the structure shown in fig. 1 is a block diagram of only a portion of the structure associated with the present application, and does not constitute a limitation on the electronic devices to which the present application may be applied, and that a particular electronic device may include more or fewer components than shown in the drawings, or may combine certain components, or have a different arrangement of components. For example, the electronic device further includes a network interface connected via the system bus, where the network interface may be an ethernet card or a wireless network card, and the like, and is used for communicating with an external electronic device, such as a server. For another example, no display is present on the electronic device connected via the system bus, or an external display device may be connected.
In one embodiment, as shown in FIG. 2, a partial architecture diagram of an electronic device is provided. The architecture system of the electronic device includes a JAVA space layer 210, a local framework layer 220, and a Kernel space layer 230. The JAVA space layer 210 may include a freezing management application 212, and the electronic device may implement a freezing policy for each application through the freezing management application 212, and perform management operations such as freezing and unfreezing for related applications consuming power in the background. A resource priority and restriction management module 222 and a platform freeze management module 224 are contained in the local framework layer 220. The electronic device can maintain different applications in organizations with different priorities and different resources in real time through the resource priority and restriction management module 222, and adjust the resource groups of the application programs according to the requirements of the upper layer, thereby achieving the effects of optimizing performance and saving power consumption. The electronic device may allocate, according to the length of the freezing time, the task that the background can be frozen to the freezing layers corresponding to the preset different levels through the platform freezing management module 224, and optionally, the freezing layers may include three, which are: CPU limited sleep mode, CPU frozen sleep mode, process deep frozen mode. The CPU sleep-restricted mode is to restrict CPU resources occupied by related processes, so that the related processes occupy less CPU resources, and the vacant CPU resources are inclined to other processes which are not frozen, so that the occupation of the CPU resources is restricted, and the occupation of network resources and I/O interface resources by the processes is correspondingly restricted; the CPU freezing sleep mode means that related processes are forbidden to use the CPU, the occupation of a memory is reserved, and when CPU resources are forbidden to use, corresponding network resources and I/O interface resources are also forbidden to use; the process deep freezing mode is to further recycle the memory resources occupied by the relevant processes except for forbidding the use of CPU resources, and the recycled 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 recycling module 234, and a freeze timeout exit module 235. The UID management module 231 is configured to manage or freeze resources of the third-party application based on a User Identifier (UID) of the application. Compared with the Process control based on the Process Identifier (PID), the unified management of the resources of the application of one user is facilitated through the UID. The Cgroup module 232 is used to provide a complete set of resource restriction mechanisms related to Central Processing Unit (CPU), CPU set, memory, input/output (I/O) and Net. The Binder management and control module 233 is used for controlling the priority of background Binder communication. The interface module of the local framework layer 220 includes a binder interface that is issued to the upper layer, and the framework or application of the upper layer sends a resource restriction or freezing instruction to the resource priority and restriction management module 222 and the platform freezing management module 224 through the provided binder interface. The process memory recycling module 234 is used to implement a deep process freezing mode, so that when a third-party application is in a frozen state for a long time, a file area of a process is mainly released, thereby achieving a memory-saving module and increasing the speed of the application when the application is started next time. The freeze timeout exit module 235 is used to resolve the exception generated by the freeze timeout scenario. Through the above-mentioned architecture, the memory processing method in each embodiment of the present application can be realized.
In an embodiment, as shown in fig. 3, a memory processing method is provided, and this embodiment is described by taking an example in which the method is applied to the electronic device shown in fig. 1. The method comprises the following steps:
step 302, obtain the recoverable memory page occupied by the application to be processed.
The application to be processed represents an application that needs to recycle the occupied memory. The memory (also called random access memory, RAM) represents a memory used when a program is executed (i.e., an operating memory), and can only temporarily store data for exchanging cache data with the CPU, but the memory itself cannot be used for storing data for a long time. Typically, the pending application is a background application. The background application is an application running in the background; correspondingly, the application running in the foreground is the foreground application. The execution of an Application (APP) is usually represented by the execution of a plurality of related processes. A process (process) is a running activity of a program in a computer on a data set, is a basic unit of resource allocation and scheduling of a system, and is the basis of an operating system structure. The process involved in the foreground application running is the foreground process, and the process involved in the background application running is the background process.
The application needs to occupy memory space to store data in the running process in the running state. Different applications do not necessarily occupy the same amount of memory space in different operating states. The memory pages are units of memory managed by the operating system, and the unit memory size occupied by the memory pages 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, the memory pages occupied by the application to be processed are from memory page 100 to memory page 200, and the memory pages 130 to memory page 200 are recoverable memory pages.
In one embodiment, the electronic device may record all memory pages occupied by the pending application in advance, and obtain the retrievable memory pages from all the memory pages. A reclaimable memory page refers to a memory page that can be reclaimed and that, after reclamation, has no or less impact on the operation of the application to be processed as well as other applications.
In an embodiment, the electronic device may record which memory pages are recoverable memory pages and which memory pages are unrecoverable memory pages, and obtain the recoverable memory pages occupied by the application to be processed according to the record information.
And step 304, acquiring the dependency proportion of the application to be processed, which is depended on by the foreground application.
Wherein a dependency representation represents a relationship in which one application needs to utilize data of another application or applications to successfully implement execution of the one application. There are two applications with dependency relationships, namely the depended-on application and the dependent application. Since the execution of applications is usually reflected by the execution of related processes, the dependency between applications is also expressed as a dependency 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 depended on by the process a, and the process a needs to use data of the process B to implement the execution of the process a, which also indicates that the application a depends on the application B, or the application B is depended on by the application a, and the application a needs to use data of the application B to implement the execution of the application a, and at this time, the application a is a depended application. It will be appreciated 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 set to inquire whether a background application depended on by the foreground application exists.
The dependency ratio reflects the degree of dependency of the application on which the dependent application depends, and the greater the dependency degree, the greater the dependency ratio. In one embodiment, the electronic device may record a dependency scale of each application on other applications and read a dependency scale of a pending application being foreground applied among the recorded plurality of dependency scales.
In one embodiment, when the pending application is not relied upon by the foreground application, then the dependency ratio is 0.
Step 306, determining the recycle amount of the recyclable memory pages according to the recyclable memory pages and the dependence proportion.
The number of evictions is the number of evictions of a memory page, which is an integer. Different dependence ratios and different total numbers of reclaimable memory pages correspond to different amounts of reclamation. The total number represents the total number of all reclaimable memory pages. The electronic equipment can preset the corresponding relation between different total numbers and the recovery numbers under different dependence proportions, and can determine the corresponding recovery numbers according to the corresponding relation. The recovery quantity is positively correlated with the total number of the recoverable memory pages, and is negatively correlated with the dependence proportion, and the larger the total number of the recoverable memory pages is, and/or the smaller the dependence proportion is, the larger the recovery quantity is correspondingly determined.
In one embodiment, a recycle proportion of the recyclable memory pages may be determined according to the dependency proportion, and a recycle number of the recyclable memory pages may be determined according to the recycle proportion and the total number of the recyclable memory pages. The recovery ratio indicates the ratio of the memory to be recovered, and the recovery ratio is used for guiding the recovery amount of the recoverable memory. For example, a 50% recycling rate means that 50% of the occupied memory can be recycled. The recovery ratio and the dependence ratio are in negative correlation, and the larger the dependence ratio is, the smaller the recovery ratio is. The corresponding relation between the application and different recovery proportions can be established under different dependence proportions, and the corresponding recovery proportions can be obtained according to the corresponding relation.
The number of reclaims may be a product between the total number of reclaimable memory pages and the determined ratio of reclaims. When the product is not an integer, an integer similar to the product may be selected, for example, the nearest integer may be determined as the recycling amount by rounding, or the corresponding integer may be determined as the recycling amount by a truncation method or a carry method.
The recoverable amount is illustrated by way of example as being determined in a rounded manner. For example, when the recoverable memory page has 100 pages, if the dependency ratio is 20%, the product obtained is 30.5% if the proportion of handguards determined from the dependency ratio is 30.5%, and the recovery number is 31, and if the corresponding recovery ratio is 21.2%, the recovery number is 21.
Step 308, select the memory pages with the amount of recovery from the recoverable memory pages to recover.
The electronic device can select the memory pages with the recovery quantity from the recoverable memory pages occupied by the application to be processed according to the determined recovery quantity to recover, so that the recoverable memory pages with the recovery quantity are released for foreground application or other applications to use, and the comprehensive processing efficiency of the system is improved. The selected recoverable memory page is a memory page on which the stored data is not depended by foreground application. Optionally, the electronic device may recycle the memory page from the recyclable memory page according to the recycle ratio through the process memory recycle module 234, so that the pending application is less affected after the memory page is recycled.
For example, the recycle percentage may be 30%, and the recoverable memory page has 100 pages, then 30 pages of the memory pages are recycled from the 100 pages of the recoverable memory page, that is, 30 pages of the recoverable memory page are released, so that the idle memory pages of the electronic device are increased by 30 pages for use by foreground applications or other background applications.
According to the memory processing method, the recoverable memory pages occupied by the application to be processed and the dependency proportion of the application to be processed, which is depended on by the foreground application, are obtained, the recovery quantity is determined according to the dependency proportion and the recoverable memory pages, the memory pages with the recovery quantity are selected from the recoverable memory pages to be recovered, the recovered object is the recoverable memory pages, all the recoverable memory pages are not necessarily recovered, the recovery quantity is determined according to the dependency proportion of the application to be processed, the influence of the memory occupied by the application to be processed on the foreground application is reduced, meanwhile, the operation influence of the application to be processed is reduced, the recovered memory pages can be released to be used by other applications, the comprehensive processing efficiency of the system is improved, the determined memory pages with the recovery quantity are selected from the recoverable memory pages to be recovered, the negative influence on each application is minimum under the condition that the memory of the whole system is enlarged, and the balance between the recovery and the operation of the memory of the application to be processed is maintained.
In one embodiment, step 304 includes: detecting whether the data stored in each recoverable memory page is depended on by foreground application; and determining the dependence proportion of the application to be processed, which is depended on by the foreground application, according to the detection result.
The detection result comprises that the memory page is not depended on by the foreground application or depended on by the foreground application. The electronic device may detect, for each recoverable memory page allocated to the application to be processed, whether data stored in the corresponding memory page is used by a foreground application within a preset time period, and if so, determine that the memory page is relied on by the foreground application. Or the foreground application may detect whether the foreground application uses the data stored in the recoverable memory page allocated to the application to be processed within a preset time period, and determine that the used memory page is depended on by the foreground application. The preset time period may be a time period of a preset time length from the current time, that is, a latest time period, where the time length of the latest time period is the preset time length, and the preset time length may be any suitable time length set according to an empirical value, such as 10 minutes, or half an hour, and the like. Or the preset time period may also be a time period during which the foreground application currently keeps running in the foreground. For example, the foreground application is kept running in the foreground from 10 o 'clock 35 minutes 20 seconds to the current time, and the current time period is the time period from 10 o' clock 35 minutes 20 seconds to the current time.
Alternatively, the dependency ratio may be a ratio of a total number of dependencies of reclaimable memory pages that are relied upon by foreground applications to a total number of guest memory pages. Detecting whether the data stored in each recoverable memory page is depended on by foreground application; and then the dependence proportion of the application to be processed, which is depended on by the foreground application, is determined according to the detection result, so that the accuracy of the determined dependence proportion can be improved.
In one embodiment, step 308 comprises: and selecting a reclaimed amount of memory pages which are not depended on by the foreground application from the recoverable memory pages for recovery.
The electronic device may further reject the memory pages depended on by the foreground application, select the memory pages of the recovery number from the recoverable memory pages not depended on by the foreground application, and recover the selected memory pages. Wherein the number of reclaims may not exceed the number of memory pages not relied upon by foreground applications. By selecting the memory pages with the recovery quantity from the memory pages not depended on by the foreground application for recovery, the memory pages depended on by the foreground application can be prevented from being recovered to influence the foreground application.
In one embodiment, before step 306, the method further includes: acquiring a corresponding relation between a recovery ratio corresponding to the application to be processed and the secondary starting time length; step 306 includes: and determining the recovery quantity of the memory pages according to the recoverable memory pages, the dependence proportion and the corresponding relation between the recovery proportion and the secondary starting duration.
The secondary starting time length is the time length spent when the recoverable memory page occupied by the application to be processed is restarted after the recoverable memory page is recovered according to the recovery proportion. The electronic device may set a correspondence between the corresponding recovery ratio and the secondary start-up time period for each application. The corresponding relation represents the corresponding secondary starting time length after the recyclable memories with different proportions are recycled in the memory occupied by the application. Alternatively, the corresponding relationship may be a comparison table between the corresponding recovery ratio and the secondary start-up time period, or a recovery ratio curve. The curve is the corresponding secondary start-up duration under different recovery proportions. And selecting a proper recovery proportion according to the corresponding relation and referring to different secondary starting durations as the recovery proportion of the recoverable memory page occupied by the application.
Optionally, the electronic device may set a corresponding start-up duration threshold, and when the secondary start-up duration reaches the start-up duration threshold, the corresponding proportion is used as a reference proportion for the recoverable memory page. The starting duration threshold may be a preset empirical value, and the starting duration thresholds corresponding to different applications may not necessarily be the same, for example, the corresponding starting duration threshold may be determined according to the normal starting duration of the corresponding application, and the duration 1.5 times or 2 times the normal starting duration is used as the starting duration threshold. The reference ratio represents a reference to the memory page reclamation ratio. And determining the recycling amount of the recyclable memory pages according to the determined reference proportion and the dependence proportion and the total number of the recyclable memory pages.
In one embodiment, the correspondence between the recovery ratio and the secondary start-up time length of the applications of different application types is not necessarily the same. The application type is a type set according to the influence on the operation of the application to be processed after the memory is recycled. Application types include independent classes, linear classes, and non-linear classes. The irrelevant class indicates that after the recyclable memory of the application to be processed is recycled, no matter how much the recyclable memory is recycled, the corresponding application is not influenced obviously. The linear class indicates that as the recycling proportion of the recyclable memory increases, the secondary start-up duration of the corresponding application also increases, wherein the secondary start-up duration and the recycling proportion increase linearly or nearly linearly. The non-linear class represents other types that are neither independent classes nor non-linear classes. Wherein, no significant influence indicates that the exceeding proportion of the secondary starting time length corresponding to different recovery proportions to the normal starting time length is less than the preset proportion range. The approximation linearity represents the secondary starting time length which is fitted by different recovery proportions according to corresponding approximate slopes, and the error between the secondary starting time length under the corresponding recovery proportions does not exceed the error in the preset range.
For example, as shown in fig. 4A, 4B to 4C, the recycling proportion curves of the application of the independent class, the linear class and the non-linear class are shown respectively in one embodiment. The abscissa in the recovery ratio curve represents the recovery ratio, and the ordinate represents the secondary start time length under the corresponding recovery ratio. The recovery proportion curve of the irrelevant class reflects that the corresponding secondary start-up duration does not change or changes slightly after the corresponding application is applied to the recoverable memory page and the recoverable memory page is recovered according to different recovery proportions. Under different recovery proportions, the corresponding slope of the recovery proportion curve of the linear class is not changed or is changed slightly, and the recovery proportion curve of the nonlinear class has a larger local slope and a smaller local slope. For the application of the non-linear class, the recovery proportion corresponding to the minimum slope can be selected as the recovery proportion of the recoverable memory page.
The electronic equipment sets the application type of the application according to the corresponding secondary starting duration after the memory is recovered according to different recovery ratios aiming at different applications, and sets a reference ratio corresponding to the application type. And determining the corresponding recovery quantity according to the recoverable memory page, the dependence proportion and the reference proportion. Further, the recycle proportion of the recyclable memory pages occupied by the application to be processed can be determined according to the reference proportion and the dependency proportion, and then the determined recycle proportion can be multiplied by the total number of the recyclable memory pages, and the calculated product is used as the recycle number.
The recovery quantity is determined according to the secondary starting time length, so that the balance between the recovery and the operation of the application memory to be processed is further kept.
In one embodiment, step 308 comprises: and selecting the memory pages with the recovery quantity from the recoverable memory pages at equal intervals according to the memory page sequence numbers for recovery.
Optionally, the electronic device may randomly recycle the recoverable memory pages according to the recycling amount, or select memory pages with the recycling amount at equal intervals according to the memory page serial number from the recoverable memory pages to recycle. The memory page number is a number set in the memory page by the electronic device, and can be numbered in sequence according to 1, 2, 3, and the like. For example, when the recovery ratio is 33%, the determined uniform recovery interval is to recover every 2 memory pages, for example, the recoverable memory pages are from the memory page 1 to the memory page 100, the memory page 1, the memory page 4, the memory page 7, the memory page 10 …, and the memory page 100 can be sequentially recovered, so as to recover 33% of the recoverable memory pages. By recycling according to the uniform intervals, each section of continuous memory cannot be completely recycled, and the application is more stable when being opened again.
In one embodiment, step 302 includes: inquiring all memory pages of a memory occupied by the application to be processed; the recyclable memory pages are obtained from all the memory pages.
Optionally, the electronic device may record, in real time, memory pages of memories occupied by different applications, and further record, in real time, whether each occupied memory page can be recycled. For example, when data in a certain memory page is being used by another application or the application to be processed, the memory page is determined to be a non-recoverable memory page, and when the data recorded in the occupied memory page is in a non-application use state or the duration of the non-application use state exceeds a preset duration, the memory page is determined to be a recoverable memory page.
For the application to be processed, all the memory pages occupied by the application can be inquired from the pre-recorded information, whether the application is a recyclable memory page or not is judged according to the recorded use state of each memory page, and then all the recyclable memory pages are acquired.
In one embodiment, querying all memory pages of the memory occupied by the application to be processed includes: traversing a memory mapping file of the application to be processed; and inquiring all memory pages occupied by the application to be processed through the memory mapping file.
Memory-Mapped Files (Memory-Mapped Files) are a mapping from one file to one block of Memory. The electronic device establishes a corresponding memory mapping file for the to-be-processed application, the memory pages occupied by the corresponding application are set in the memory mapping file, and all the memory pages occupied by the to-be-processed application can be acquired by traversing the memory mapping file corresponding to the to-be-processed application and reading the memory pages occupied by the to-be-processed application from each traversed memory mapping file, so that the query efficiency and the query comprehensiveness of the memory pages occupied by the to-be-processed application are improved.
In one embodiment, retrieving the reclaimable memory pages from all the memory pages includes: memory pages carrying occupation marks are removed from all memory pages; and acquiring recoverable memory pages from the memory pages after the rejection.
For all the memory pages occupied by the queried applications to be processed, the electronic device may detect whether each queried memory page carries an occupation flag or is occupied by multiple applications. The occupation mark indicates that the data stored in the corresponding memory page is used by the application to be processed, or the data is indispensable data in the process that the application to be processed keeps normal operation, when the data is deleted, the application to be processed either cannot operate normally, or needs to occupy a new memory page repeatedly to store the corresponding data, and for the detected data, the electronic device can set the occupation mark for the memory page storing the data to indicate that the corresponding memory page cannot be recycled.
In the memory page occupied by the application to be processed, the data stored therein may also be used by other applications, that is, a plurality of applications all use the data in the memory page, and for the type of memory page, an occupancy flag may also be set, so that the electronic device also rejects the memory page to indicate that the data is not recovered from the type of memory page.
And aiming at the memory pages after being removed, the reserved memory pages are recoverable memory pages, and the electronic equipment can recover the memory from the memory pages.
In one 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 pending application; inquiring all memory pages occupied by applications to be processed through a memory mapping file, detecting whether each memory page is a recoverable memory page or not through the resource priority and limit management module 222, setting corresponding occupation marks for unrecoverable memory pages, simultaneously recording whether each memory page is occupied by a plurality of applications or not, and removing the memory pages carrying the occupation marks and/or occupied by the plurality of applications from all the inquired memory pages; and acquiring recyclable memory pages from the rejected memory pages.
In one embodiment, the method further comprises: and when a communication mechanism or a synchronization mechanism exists between the application to be processed and the foreground application, judging that the application to be processed is depended on by the foreground application.
In one embodiment, when socket communication, binder communication, memory sharing or lock waiting exists between the application to be processed and the foreground application, it is determined that a communication mechanism exists between the background process and the foreground application.
Whether a background process with a communication mechanism with a foreground application exists can be detected in any one or more of the following ways:
(1) Detecting whether a background process which has socket and/or binder communication with foreground application exists;
(2) Detecting whether a background process for memory sharing with foreground application exists or not;
(3) It is detected whether there is a background process where the foreground application is waiting on the lock resource.
The electronic equipment can set a detection mechanism for detecting whether Binder communication exists between foreground application and background process in the Binder drive, and call the detection mechanism set in the Binder drive to detect the background process which has Binder communication with the foreground application, and determine the detected background process as the background process which is depended by the foreground application.
In one embodiment, the electronic device may detect various lock resources, including thread locks, file handles, signals, and the like. For each lock resource, it may be detected whether a lock wait occurs, i.e., the lock resource waits. When it is detected that a lock wait is generated, it may be further detected whether the wait occurrence behavior occurs on the foreground application. If yes, traversing all background processes waiting on the lock resource, and judging the detected background processes waiting on the lock resource as background processes depended on by foreground application.
In one embodiment, the electronic device may set the lock resource monitoring module and the priority adjustment module in a kernel space of the operating system, and embed the lock resource monitoring module into a native wait interface of the kernel. The resource monitoring module detects whether the thread lock, the file handle, the signal and the like lock various lock resources, whether waiting occurs or not, whether the waiting action occurs on foreground application or not, and if the waiting action occurs on foreground task, the detected message is sent to the priority adjusting module. And traversing all background threads waiting on the lock resource through the priority adjustment, and judging the background processes as background processes depended on by foreground application.
In one embodiment, when a synchronization mechanism exists between a background process and a foreground application, the pending application with the synchronization mechanism is determined to be the background process depended on by the foreground application.
The electronic equipment can also call and detect whether a background process with a synchronization mechanism with the foreground application exists in the background process set by calling the futex system, and the background process with the synchronization mechanism is judged as the background process depended on by the foreground application.
In concurrent programming, processes must restrict access to common variables, a constraint called synchronization. In an operating system, the synchronization mechanism for user mode (user mode) may be implemented by calling a futex system call. Wherein the user state refers to a non-privileged state. The synchronization mechanism includes a semaphore, a mutex, etc. When a background process with any one synchronization mechanism with the foreground application is detected through futex system call, the detected background process can be judged as the background process depended on by 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 which has the communication mechanism and/or the synchronization mechanism with the foreground application is judged as the background process which is depended on by the foreground application, so that the efficiency of detecting the to-be-processed application which is depended on by the foreground application can be improved.
In one embodiment, as shown in fig. 5, another memory processing method is provided, and the method includes:
step 502, traversing a memory mapping file of the application to be processed; and inquiring all memory pages occupied by the application to be processed through the memory mapping file.
In an embodiment, the electronic device may trigger the memory recovery mechanism when detecting that the memory usage rate of the system exceeds a preset ratio, or when receiving a memory recovery instruction triggered by a user operation, and determine an application that needs to be subjected to memory recovery from all running applications, where the determined application is the application to be processed.
In one embodiment, the electronic device may trigger a memory reclamation mechanism for an application after detecting that the application is switched from the foreground to the background and setting the application to a process deep freeze mode through the platform freeze management module 224.
The electronic device may traverse the memory mapping files of the application to be processed through the resource priority and restriction management module 222, and query the memory pages occupied by the application to be processed from each traversed memory mapping file, so as to query all the memory pages occupied by the application to be processed.
Step 504, removing memory pages carrying occupation marks from all memory pages; and acquiring recoverable memory pages from the memory pages after the rejection.
And performing secondary traversal on each inquired memory page, wherein the secondary traversal is used for detecting whether each inquired memory page is a recoverable memory page, when a memory page carrying an occupation mark is detected, the memory page is judged to be a non-recoverable memory page, the memory page is removed, the memory page obtained after the secondary traversal is the recoverable memory page, and the electronic equipment can select the memory page from all the recoverable memory pages for recovery. The comprehensiveness of recoverable memory page detection can be improved through secondary traversal.
Step 506, detecting whether the data stored in each recoverable memory page is depended on by foreground application; and determining the dependence proportion of the application to be processed, which is depended on by the foreground application, according to the detection result.
When a communication mechanism or a synchronization mechanism exists between the application to be processed and the foreground application, the fact that the application to be processed is depended on by the foreground application is judged, data stored in recyclable memory pages which are specifically depended on by the foreground application are detected, and a dependency ratio is determined according to a detection result. The detection result comprises that the memory page is not depended on by the foreground application or depended on by the foreground application. The dependency ratio may be a ratio of a total number of dependencies of the reclaimable memory pages that are relied upon by the foreground application to a total number of guest reclaimable memory pages. When the application to be processed is not depended on by the foreground application, the dependence ratio is 0.
For a detected memory page depended by an application, a corresponding dependency identifier may be set for the memory page, so that it can be known which specific applications depend on the corresponding memory page according to the dependency identifier. And then according to whether each recoverable memory page is set with a corresponding dependency identifier and whether the dependency identifier represents that the recoverable memory page is depended on by foreground application, the dependency ratio of the application to be processed on the foreground application can be calculated. In one embodiment, the validity of the corresponding dependency identifier may be determined according to the preset time period, and when the corresponding dependency identifier is within the preset time period, the set dependency identifier is kept valid, and when the corresponding dependency identifier is outside the preset time period, the set dependency identifier may be cancelled. By setting the dependency identification, the efficiency of calculating the dependency proportion can be improved.
And step 508, acquiring the corresponding relation between the recovery proportion corresponding to the application to be processed and the secondary starting time length.
The secondary starting time length is the time length spent when the recoverable memory page occupied by the application to be processed is restarted after the recoverable memory page is recovered according to the recovery proportion. The corresponding relation can be a comparison table between the corresponding recovery ratio and the secondary starting time length or a recovery ratio curve. The curve is the corresponding secondary start-up duration for different recovery ratios, and may be the curves shown in fig. 4A to 4C. The corresponding relation can be determined according to the corresponding secondary starting duration under different recorded recovery proportions under the detection of exceeding the preset times. For example, the corresponding secondary start durations at different recovery ratios can be detected each time by 100 times of detection, and the average value of the secondary start durations at the same ratio is used as the secondary start duration corresponding to the recovery ratio in the corresponding relationship.
Step 510, determining the recovery quantity of the memory pages according to the recoverable memory pages, the dependency proportion and the corresponding relationship between the recovery proportion and the secondary starting duration.
The electronic equipment can select a proper proportion as a corresponding reference proportion according to the corresponding relation between the recovery proportion and the secondary starting time length, further determine the recovery proportion of the recoverable memory pages according to the reference proportion and the dependence proportion, and further take the product of the determined recovery proportion and the total number of the recoverable memory pages as the recovery number.
In one embodiment, the recycle proportion of the recyclable memory pages may be determined according to the reference proportion and the dependency proportion, for example, the reference proportion is a, the dependency proportion is b, and the recycle proportion of the recyclable memory pages is c. When the sum of a and b is not more than 1, c = a may be directly taken; when the sum of a and b is not more than 1, c =1-b may be directly taken. The efficiency of calculating the recovery ratio is improved, the subsequently recovered memory pages are all the memory pages which are not depended on by foreground application, the influence on the application to be processed is small, and meanwhile, the memory pages which are more as much as possible are recovered.
In step 512, the memory pages that are not depended on by the foreground application are selected from the recoverable memory pages for recovery.
In one embodiment, the memory pages with the recovery number can be selected from the memory pages not depended on by the foreground application at equal intervals according to the memory page sequence numbers for recovery.
By reclaiming from memory pages that are not relied upon by foreground applications, the impact on foreground applications can be further reduced.
It should be understood that although the steps in the flowcharts of fig. 3 and 5 are shown in order as indicated by the arrows, the steps are not necessarily performed in order as indicated by the arrows. The steps are not performed in the exact order shown and described, and may be performed in other orders, unless explicitly stated otherwise. Moreover, at least some of the steps in fig. 3 and 5 may include multiple sub-steps or multiple stages that are not necessarily performed at the same time, but may be performed at different times, and the order of performing the sub-steps or stages is not necessarily sequential, but may be performed alternately or alternately with other steps or at least some of the sub-steps or stages of other steps.
In one embodiment, as shown in fig. 6, there is provided a memory processing apparatus, including: a memory page obtaining module 602, a dependency determining module 604, and a memory reclaiming module 606. The memory page obtaining module 602 is configured to obtain a recoverable memory page occupied by the application to be processed; the dependency determining module 604 is configured to obtain a dependency ratio of the to-be-processed application being depended on by the foreground application; the memory recovery module 606 is configured to determine a recovery number of the recoverable memory pages according to the recoverable memory pages and the dependency proportion; and selecting a reclaimed amount of memory pages from the recyclable memory pages for recycling.
In an 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; memory pages carrying occupation marks are removed from all memory pages; and acquiring recoverable memory pages from the memory pages after the rejection.
In an embodiment, the memory page obtaining module 602 is further configured to traverse a memory mapping file of the application to be processed; and inquiring all memory pages occupied by the application to be processed through the memory mapping file.
In one embodiment, the dependency determination module 604 is further configured to detect whether the data stored in each reclaimable memory page is depended on by a foreground application; determining the dependence proportion of the application to be processed, which is depended on by the foreground application, according to the detection result; the detection result comprises that the memory page is not depended on by the foreground application or depended on by the foreground application.
The memory reclamation module 606 is further configured to select a reclaimed number of memory pages from the reclaimable memory pages, which are not depended on by the foreground application, for reclamation.
In one embodiment, the memory recovery module 606 is further configured to obtain a corresponding relationship between a recovery ratio corresponding to the application to be processed and the secondary start time; the secondary starting time length is the time length spent when the recoverable memory page occupied by the application to be processed is restarted after the recoverable memory page is recovered according to the recovery proportion; and determining the recovery quantity of the memory pages according to the recoverable memory pages, the dependence proportion and the corresponding relation between the recovery proportion and the secondary starting duration.
In an embodiment, the memory recovery module 606 is further configured to select the memory pages with the recovery number from the recoverable memory pages at equal intervals according to the memory page sequence numbers for recovery.
In one embodiment, the dependency determination module 604 is further configured to determine that the pending application is depended on by the foreground application when a communication mechanism or a synchronization mechanism exists between the pending application and the foreground application.
According to the memory processing device, the recoverable memory pages occupied by the application to be processed and the dependency proportion of the application to be processed, which is depended on by the foreground application, are obtained, the recovery quantity is determined according to the dependency proportion and the recoverable memory pages, the memory pages with the recovery quantity are selected from the recoverable memory pages to be recovered, the recovered object is the recoverable memory pages, all the recoverable memory pages are not necessarily recovered, the recovery quantity is determined according to the dependency proportion of the application to be processed, the influence of the memory occupied by the application to be processed on the foreground application is reduced, meanwhile, the operation influence of the application to be processed is reduced, the recovered memory pages can be released to be used by other applications, the comprehensive processing efficiency of the system is improved, the determined memory pages with the recovery quantity are selected from the recoverable memory pages to be recovered, the negative influence on each application is minimum under the condition that the memory of the whole system is enlarged, and the balance between the recovery and the operation of the memory of the application to be processed is maintained.
The division of each module in the memory processing apparatus is only for illustration, and in other embodiments, the memory processing apparatus may be divided into different modules as needed to complete all or part of the functions of the memory processing apparatus.
For specific limitations of the memory processing apparatus, reference may be made to the above limitations of the memory processing method, which is not described herein again. The modules in the memory processing device can be wholly or partially implemented by software, hardware and a combination thereof. The modules can be embedded in a hardware form or independent of a processor in the electronic device, or can be stored in a memory in the electronic device in a software form, so that the processor can call and execute operations corresponding to the modules.
The implementation of each module in the memory processing device provided in the embodiment of the present application may be in the form of a computer program. The computer program may be run on an electronic device such as a terminal or a server. Program modules constituted by such computer programs may be stored on the memory of the electronic device. When executed by a processor, the computer program implements the steps of the memory processing method described in the embodiments of the present application.
In one embodiment, an electronic device is provided, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, and when the processor executes the computer program, the steps of the memory processing method provided in the foregoing embodiments are implemented.
In one embodiment, a computer-readable storage medium is further provided, on which a computer program is stored, which, when executed on a processor, implements the steps of the memory processing method described in the embodiments of the present application.
In one embodiment, a computer program product containing instructions is provided, which when run on a computer, causes the computer to perform the memory processing method described in the embodiments of the present application.
The embodiment of the application also provides computer equipment. As shown in fig. 7, for convenience of explanation, only the parts related to the embodiments of the present application are shown, and details of the technology are not disclosed, please refer to the method part of the embodiments 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 the computer device as the mobile phone as an example:
fig. 7 is a block diagram of a partial structure of a mobile phone related to a computer device provided in an embodiment of the present application. Referring to fig. 7, the handset includes: radio Frequency (RF) circuit 710, memory 720, input unit 730, display unit 740, sensor 750, audio circuit 760, wireless fidelity (WiFi) module 770, processor 780, and power supply 790. Those skilled in the art will appreciate that the handset configuration shown in fig. 7 is not intended to be limiting and may include more or fewer components than those shown, or some components may be combined, or a different arrangement of components.
The RF circuit 710 may be used for receiving and transmitting signals during information transmission or communication, and may receive downlink information of a base station and then process the downlink information to the processor 780; the uplink data may also be transmitted to the base station. Typically, the RF circuit includes, but is 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, the RF circuit 710 may also communicate with networks and other devices via wireless communication. The wireless communication may use any communication standard or protocol, including but not limited to Global System for Mobile communication (GSM), general Packet Radio Service (GPRS), code Division Multiple Access (CDMA), wideband Code Division Multiple Access (WCDMA), long Term Evolution (LTE)), e-mail, short Messaging Service (SMS), and the like.
The memory 720 may be used to store software programs and modules, and the processor 780 may execute various functional applications and data processing of the cellular phone by operating the software programs and modules stored in the memory 720. The memory 720 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application program required for at least one function (such as an application program for a sound playing function, an application program for an image playing function, and the like), and the like; the data storage area may store data (such as audio data, an address book, etc.) created according to the use of the mobile phone, and the like. Further, the memory 720 may include high speed random access memory, and may 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 may be used to receive input numeric or character information and generate key signal inputs related to user settings and function control of the cellular phone 700. Specifically, the input unit 730 may include a touch panel 731 and other input devices 732. The touch panel 731, which may also be referred to as a touch screen, can collect touch operations of a user (e.g., operations of the user on or near the touch panel 731 by using a finger, a stylus, or any other suitable object or accessory) thereon or nearby, and drive the corresponding connection device according to a preset program. In one embodiment, the touch panel 731 may include two parts of a touch detection device and a touch controller. The touch detection device detects the touch direction of a user, detects a signal brought by touch operation and transmits the signal to the touch controller; the touch controller receives touch information from the touch sensing device, converts it to touch point coordinates, and provides them to processor 780, where they can receive commands from processor 780 and execute them. In addition, the touch panel 731 may be implemented by various types, such as a resistive type, a capacitive type, an infrared ray, and a surface acoustic wave. The input unit 730 may include other input devices 732 in addition to the touch panel 731. 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 keys, switch keys, etc.), and the like.
The display unit 740 may be used to display information input by the user or information provided to the user and various menus of the mobile phone. The display unit 740 may include a display panel 741. In one embodiment, the Display panel 741 may 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, and when the touch panel 731 detects a touch operation on or near the touch panel 731, the touch operation is transmitted to the processor 780 to determine the type of the touch event, and then the processor 780 provides a corresponding visual output on the display panel 741 according to the type of the touch event. Although the touch panel 731 and the display panel 741 are two independent components in fig. 7 to implement the input and output functions of the mobile phone, in some embodiments, the touch panel 731 and the display panel 741 may be integrated to implement the input and output functions of the mobile phone.
The cell phone 700 may also include at least one sensor 750, such as light sensors, motion sensors, and other sensors. Specifically, the light sensor may include an ambient light sensor that adjusts the brightness of the display panel 741 according to the brightness of ambient light, and a proximity sensor that turns off the display panel 741 and/or a backlight when the mobile phone is moved to the ear. The motion sensor can comprise an acceleration sensor, the acceleration sensor can detect the magnitude of acceleration in each direction, the magnitude and the direction of gravity can be detected when the mobile phone is static, and the motion sensor can be used for identifying the application of the gesture of the mobile phone (such as horizontal and vertical screen switching), the vibration identification related functions (such as pedometer and knocking) and the like; the mobile phone may be provided with other sensors such as a gyroscope, a barometer, a hygrometer, a thermometer, and an infrared sensor.
Audio circuitry 760, speaker 761, and microphone 762 may provide an audio interface between a user and a cell phone. The audio circuit 760 can transmit the electrical signal converted from the received audio data to the speaker 761, and the electrical signal is converted into a sound signal by the speaker 761 and output; on the other hand, the microphone 762 converts the collected sound signal into an electric signal, converts the electric signal into audio data after being received by the audio circuit 760, and then outputs the audio data to the processor 780 for processing, and then the processed audio data may be transmitted to another mobile phone through the RF circuit 710, or outputs the audio data to the memory 720 for subsequent processing.
WiFi belongs to short-distance wireless transmission technology, and the mobile phone can help a user to receive and send e-mails, browse webpages, access streaming media and the like through the WiFi module 770, and provides wireless broadband Internet access for the user. Although fig. 7 shows WiFi module 770, it is understood that it does not belong to the essential components of handset 700 and may be omitted as desired.
The processor 780 is a control center of the mobile phone, connects various parts of the entire mobile phone by using various interfaces and lines, and performs various functions of the mobile phone and processes data by operating or executing software programs and/or modules stored in the memory 720 and calling data stored in the memory 720, thereby integrally monitoring the mobile phone. In one embodiment, processor 780 may include one or more processing units. In one embodiment, processor 780 may integrate an application processor and a modem, wherein the application processor primarily handles operating systems, user interfaces, applications, and the like; the modem handles primarily wireless communications. It will be appreciated that the modem may not be integrated into the processor 780. For example, the processor 780 may integrate an application processor with a baseband processor, which may constitute a modem with other peripheral chips, etc. The handset 700 also includes a power supply 790 (e.g., a battery) for powering the various components, which may preferably be logically coupled to the processor 780 via a power management system that may be used to manage charging, discharging, and power consumption.
In one embodiment, the cell phone 700 may 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 above-described memory processing method when executing the computer program stored in the memory.
Any reference to memory, storage, database, or other medium used herein may include non-volatile and/or volatile memory. Suitable 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 external cache memory. 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), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchronous Link (SLDRAM), rambus (Rambus) direct RAM (RDRAM), direct bused dynamic RAM (DRDRAM), and Rambus Dynamic RAM (RDRAM).
The above examples only express several embodiments of the present application, and the description thereof is more specific and detailed, but not construed as limiting the scope of the present application. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the concept of the present application, which falls within the scope of protection of the present application. Therefore, the protection scope of the present patent shall be subject to the appended claims.

Claims (10)

1. A memory processing method, comprising:
acquiring a recoverable memory page occupied by the application to be processed;
acquiring the dependency proportion of the application to be processed, which is depended on by foreground application; the dependency ratio reflects the degree of dependency of the application on which the depended application depends;
acquiring a corresponding relation between a recovery ratio corresponding to the application to be processed and a secondary starting time; the secondary starting time length is the time length spent when the recoverable memory page occupied by the application to be processed is restarted after being recovered according to the recovery proportion; acquiring a starting time length threshold, taking a corresponding recovery proportion as a reference proportion when the secondary starting time length in the corresponding relation reaches the starting time length threshold, and determining the recovery quantity based on the reference proportion, the dependence proportion and the total number of the recoverable memory pages;
and selecting the memory pages with the recovery quantity from the recoverable memory pages for recovery.
2. The method of claim 1, wherein the obtaining the dependency ratio of the pending application depended on by the foreground application comprises:
detecting whether the data stored in each recoverable memory page is depended on by foreground application;
determining the dependence proportion of the application to be processed, which is depended on by foreground application, according to the detection result; the detection result comprises that the memory page is not depended on by the foreground application or depended on by the foreground application.
3. The method according to claim 2, wherein the selecting the reclaimed number of memory pages from the reclaimable memory pages for reclaiming comprises:
and selecting the memory pages which are not depended by the foreground application and have the recovery quantity from the recoverable memory pages for recovery.
4. The method of claim 1, wherein determining the number of reclaims based on the reference proportion, the dependency proportion, and the total number of reclaimable memory pages comprises:
determining the recovery proportion of the recoverable memory pages occupied by the applications to be processed according to the reference proportion and the dependence proportion;
and multiplying the recovery proportion by the total number of the recoverable memory pages, and taking the calculated product as the recovery number.
5. The method according to claim 1, wherein the selecting the reclaimed number of memory pages from the reclaimable memory pages for reclaiming comprises:
and selecting the memory pages with the recovery quantity from the recoverable memory pages at equal intervals according to the memory page sequence numbers for recovery.
6. The method according to claim 1, wherein the obtaining the reclaimable memory pages occupied by the application to be processed comprises:
traversing a memory mapping file of the application to be processed;
inquiring all memory pages occupied by the application to be processed through the memory mapping file;
memory pages carrying occupation marks are removed from all the memory pages;
and acquiring recoverable memory pages from the memory pages after the rejection.
7. The method according to any one of claims 1 to 6, wherein the pending application is determined to be relied upon by a foreground application when a communication mechanism or a synchronization mechanism exists between the pending application and the foreground application.
8. A memory processing apparatus, the apparatus comprising:
the memory page acquisition module is used for acquiring recoverable memory pages occupied by the application to be processed;
the dependency determining module is used for acquiring the dependency proportion of the application to be processed, which is depended on by the foreground application; the dependency ratio reflects the degree of dependency of the application on which the depended application depends;
the memory recovery module is used for acquiring the corresponding relation between the recovery proportion corresponding to the application to be processed and the secondary starting time length; the secondary starting time length is the time length spent when the recoverable memory page occupied by the application to be processed is restarted after the recoverable memory page is recovered according to the recovery proportion; acquiring a starting time length threshold, taking a corresponding recovery proportion as a reference proportion when the secondary starting time length in the corresponding relation reaches the starting time length threshold, and determining the recovery quantity based on the reference proportion, the dependence proportion and the total number of the recoverable memory pages; and selecting the memory pages with the recovery quantity from the recoverable memory pages for recovery.
9. An electronic device comprising a memory and a processor, the memory having stored thereon a computer program, wherein the computer program, when executed by the processor, causes the processor to perform the steps of the method according to any of claims 1 to 7.
10. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the method according to any one of claims 1 to 7.
CN201810023232.7A 2018-01-10 2018-01-10 Memory processing method and device, electronic equipment and computer readable storage medium Active CN110018902B (en)

Priority Applications (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
PCT/CN2018/125225 WO2019137252A1 (en) 2018-01-10 2018-12-29 Memory processing method, electronic device, and computer-readable storage medium

Applications Claiming Priority (1)

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

Publications (2)

Publication Number Publication Date
CN110018902A CN110018902A (en) 2019-07-16
CN110018902B true CN110018902B (en) 2023-01-31

Family

ID=67188123

Family Applications (1)

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

Country Status (2)

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

Families Citing this family (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110727606A (en) * 2019-09-27 2020-01-24 Oppo(重庆)智能科技有限公司 Memory recovery method and device and electronic equipment
CN110727607B (en) * 2019-09-27 2022-08-12 Oppo广东移动通信有限公司 Memory recovery method and device and electronic equipment
CN110888821B (en) * 2019-09-30 2023-10-20 华为技术有限公司 Memory management method and device
CN113392037A (en) * 2020-03-12 2021-09-14 深圳市万普拉斯科技有限公司 Memory recovery method and device, computer equipment and storage medium
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
CN115729684B (en) * 2021-08-25 2023-09-19 荣耀终端有限公司 Input/output request processing method and electronic equipment

Family Cites Families (18)

* 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
CN102226894A (en) * 2011-05-23 2011-10-26 中兴通讯股份有限公司 Mobile device memory management method and device
WO2013027642A1 (en) * 2011-08-19 2013-02-28 Kabushiki Kaisha Toshiba Information processing apparatus, method for controlling information processing apparatus, non-transitory recording medium storing control tool, host device, non-transitory recording medium storing performance evaluation tool, and performance evaluation method for external memory device
CN103092700B (en) * 2013-02-01 2016-09-28 华为终端有限公司 Internal memory method for cleaning, device and terminal unit
CN103150259B (en) * 2013-03-22 2016-03-30 华为技术有限公司 A kind of method for recovering internal storage and device
CN103324500B (en) * 2013-05-06 2016-08-31 广州市动景计算机科技有限公司 A kind of method and device reclaiming internal memory
CN103577335B (en) * 2013-10-23 2016-09-07 中国科学院计算技术研究所 A kind of internal memory garbage retrieving system and method
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
CN105159777B (en) * 2015-08-03 2018-07-27 中科创达软件股份有限公司 The method for recovering internal storage and device of process
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
CN107133182A (en) * 2016-02-29 2017-09-05 北大方正集团有限公司 A kind of EMS memory management process 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

Also Published As

Publication number Publication date
CN110018902A (en) 2019-07-16
WO2019137252A1 (en) 2019-07-18

Similar Documents

Publication Publication Date Title
CN110018902B (en) Memory processing method and device, electronic equipment and computer readable storage medium
CN109992523B (en) Memory processing method and device, electronic equipment and computer readable storage medium
US11099900B2 (en) Memory reclamation method and apparatus
CN110018900B (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
CN107526640B (en) Resource management method, resource management device, mobile terminal and computer-readable storage medium
EP3506106B1 (en) Method for processing application, electronic device, and computer-readable storage medium
CN109144232B (en) Process processing method and device, electronic equipment and computer readable storage medium
CN110018901B (en) Memory recovery method and device, computer equipment and computer readable storage medium
CN109992399B (en) Resource management method, resource management device, mobile terminal and computer-readable storage medium
CN109992375B (en) Information processing method, information processing device, computer equipment and computer readable storage medium
CN110018886B (en) Application state switching method and device, electronic equipment and readable storage medium
CN110018885B (en) Application program freezing method and device, storage medium and terminal
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
CN109992395B (en) Application freezing method and device, terminal and computer readable storage medium
CN110046031B (en) Application processing method and device, electronic equipment and computer readable storage medium
CN110007968B (en) Information processing method, information processing device, computer equipment and computer readable storage medium
CN109992376B (en) Application freezing method, device, terminal and computer readable storage medium
CN109992394B (en) Process processing method and device, electronic equipment and computer readable storage medium
CN109992361B (en) Application freezing method and device, terminal and computer readable storage medium
CN110046030B (en) Application program processing method and device, electronic equipment and computer readable storage medium
CN109992365B (en) Application processing method and device, electronic equipment and computer readable storage medium
CN110032398B (en) Application processing method and device, electronic equipment and computer readable storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
CB02 Change of applicant information

Address after: Changan town in Guangdong province Dongguan 523860 usha Beach Road No. 18

Applicant after: GUANGDONG OPPO MOBILE TELECOMMUNICATIONS Corp.,Ltd.

Address before: Changan town in Guangdong province Dongguan 523860 usha Beach Road No. 18

Applicant before: GUANGDONG OPPO MOBILE TELECOMMUNICATIONS Corp.,Ltd.

CB02 Change of applicant information
GR01 Patent grant
GR01 Patent grant