CN110018900B - 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
CN110018900B
CN110018900B CN201810023217.2A CN201810023217A CN110018900B CN 110018900 B CN110018900 B CN 110018900B CN 201810023217 A CN201810023217 A CN 201810023217A CN 110018900 B CN110018900 B CN 110018900B
Authority
CN
China
Prior art keywords
application
memory
recovery
processed
recoverable
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
CN201810023217.2A
Other languages
Chinese (zh)
Other versions
CN110018900A (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 CN201810023217.2A priority Critical patent/CN110018900B/en
Priority to PCT/CN2018/125326 priority patent/WO2019137258A1/en
Publication of CN110018900A publication Critical patent/CN110018900A/en
Application granted granted Critical
Publication of CN110018900B publication Critical patent/CN110018900B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/0223User address space allocation, e.g. contiguous or non contiguous base addressing
    • G06F12/023Free address space management
    • G06F12/0253Garbage collection, i.e. reclamation of unreferenced memory
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • 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/48Program initiating; Program switching, e.g. by interrupt
    • 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/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
    • G06F9/485Task life-cycle, e.g. stopping, restarting, resuming execution
    • 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/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
    • G06F9/4881Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues
    • 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
    • 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/5022Mechanisms to release resources
    • 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/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
    • G06F9/5038Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals considering the execution order of a plurality of tasks, e.g. taking priority or time dependency constraints into consideration
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/48Indexing scheme relating to G06F9/48
    • G06F2209/482Application
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/50Indexing scheme relating to G06F9/50
    • G06F2209/5021Priority
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/50Indexing scheme relating to G06F9/50
    • G06F2209/504Resource capping

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 dependency proportion of the application to be processed, which is depended on by foreground application; acquiring the idle time of the application to be processed for each recoverable memory page; determining a time length threshold value according to the idle time length of each recoverable memory page and the dependence proportion; and selecting the memory pages with the idle time length exceeding the time length threshold value from the recyclable memory pages for recycling. 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 balance between recovery and operation of the memory of the application to be processed is kept.

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 operating 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, comprising: 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; acquiring the idle time of the application to be processed for each recoverable memory page; determining a time length threshold value according to the idle time length of each recoverable memory page and the dependence proportion; and selecting memory pages with idle time exceeding the time threshold from the recoverable memory pages for recovery.
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; a duration determining module, configured to obtain an idle duration of each recoverable memory page for the application to be processed; determining a time length threshold value according to the idle time length of each recoverable memory page and the dependence proportion; and the memory recovery module is used for selecting the memory pages with the idle time exceeding the time threshold 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 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 application to be processed and the idle time length of the application to be processed are obtained, the dependence proportion of the application to be processed on foreground application is obtained, the time length threshold value is determined according to the idle time length and the dependence proportion, and the memory pages with the idle time lengths exceeding the time length threshold value are 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 embodiments or the prior art descriptions will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art 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. 4 is a flowchart illustrating determining a duration threshold according to an idle duration and a dependency ratio of each reclaimable memory page in one embodiment;
FIG. 5A is a graph illustrating a recycle proportion curve for an unrelated class application, in one embodiment;
FIG. 5B is a graph illustrating recovery ratios for linear class applications in one embodiment;
FIG. 5C is a graph illustrating recovery ratios for non-linear class applications in one embodiment;
FIG. 6 is a flow diagram of a method for memory processing in another embodiment;
FIG. 7 is a block diagram of a memory processing device in accordance with one embodiment;
fig. 8 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 and not restrictive on the broad 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 applied to 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.
Those skilled in the art will appreciate that the architecture shown in fig. 1 is a block diagram of only a portion of the architecture associated with the subject application, and does not constitute a limitation on the electronic devices to which the subject application may be applied, and that a particular electronic device may include more or less components than those shown, 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 thawing 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 the relevant processes, so that the relevant 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 the network resources and the 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 the CPU resource is forbidden to use, the corresponding network resource and the I/O interface resource 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 framework, the memory processing method in each embodiment of the application can be realized.
In an embodiment, as shown in fig. 3, a memory processing method is provided, and this embodiment takes the application of the method to the electronic device shown in fig. 1 as an example for description. The method comprises the following steps:
step 302, acquiring a 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 application to be processed in operation in advance, and obtain the retrievable memory pages from all the memory pages. A reclaimable memory page represents a memory page that can be reclaimed and that has no or less impact on the operation of the application to be processed and other applications after reclamation.
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.
Dependency representations represent relationships that an application needs to utilize for the execution of another application or applications to successfully implement the execution of the application. There are two applications with dependency relationships, the depended-on application and the dependent application, respectively. 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 a first application and the second application may be a 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 application to be processed is not relied upon by the foreground application, then the dependency ratio is 0.
Step 306, obtaining the idle duration of the application to be processed for each recoverable memory page.
Since the data stored in the memory page is not used by the application all the time, the idle duration of the memory page indicates the duration of the unused state of the data stored in the memory page after the system allocates the memory page for the application to be processed. The electronic equipment updates the idle time of each memory page in real time according to the data use condition of each memory page, and can acquire the latest recorded idle time of each recoverable memory page when the memory page occupied by the application to be processed is ready to be recovered.
In one embodiment, when the conditions of allocation, recovery, release, and the like of a memory page are initiated last time, or the conditions of querying the use condition of a cache in a processor are all determined to use data of a corresponding related memory page, and the system time in the corresponding condition is the most recent data use time of the memory page, and the difference between the current time and the most recent time is the idle duration of the corresponding memory page.
In one embodiment, the electronic device may create a corresponding time stamp for each memory page, which records the last time the data in the corresponding memory page was used. In the operating system, whenever the allocation, recovery, release and other opportunities to the memory are actively initiated, the activity of the corresponding memory page can be updated, and the update time is recorded in the timestamp. Or the service condition of the processor cache is checked at the system timing, the data in the current cache can be judged to be the currently used data, the timestamp of the related memory page is updated, and the updating time is recorded in the timestamp. Optionally, the last recorded update time may be replaced by the last update time, so as to reduce resource occupation of the update time.
And step 308, determining a time length threshold according to the idle time length and the dependence proportion of each recoverable memory page.
The duration threshold represents a threshold value used to decide whether to reclaim a reclaimable memory page. The duration threshold may be determined according to the idle duration of each recoverable memory page and the dependency proportion of the foreground application to the application to be processed, where the idle duration is different or the dependency proportion is different, and the determined duration thresholds are also not necessarily the same.
In an embodiment, the electronic device may calculate a weighted average of the idle durations of all the recyclable memory pages, or may further select one idle duration from the idle durations of all the recyclable memory pages, use the selected idle duration or the calculated weighted average as a reference duration, set correspondence between different reference durations, dependency ratios, and duration thresholds, and obtain the duration thresholds corresponding to the reference duration and the dependency ratio according to the correspondence. For example, the idle durations close to the median or sorted at a certain position may be selected from the idle durations of all the recoverable memory pages occupied by the application to be processed, and the selected idle duration is used as the reference duration. The duration threshold value is positively correlated with both the dependency proportion and the reference duration, and the larger the reference duration and/or the larger the dependency proportion, the larger the correspondingly determined duration threshold value is.
Step 310, selecting a memory page with an idle duration exceeding a duration threshold from the recoverable memory pages for recovery.
The electronic device can select the memory pages with idle time exceeding the time length threshold from the recyclable memory pages occupied by the application to be processed according to the determined time length threshold to recycle, so as to release the recyclable memory pages with the time length threshold for foreground application or other applications to use, thereby improving the comprehensive processing efficiency of the system. Optionally, the electronic device may recycle the memory page from the recyclable memory page according to the duration threshold through the process memory recycling module 234, so as to release the memory that is not used for a long time, improve the memory usage efficiency, and reduce the influence on the to-be-processed application after the memory page is recycled. In an embodiment, the storage data in the recycled memory may be stored in a nonvolatile storage medium of the electronic device or other external storage media, for example, the storage data in the recycled memory may be stored in a built-in nonvolatile storage medium such as a flash memory or a hard disk of the electronic device.
For example, 100 memory pages can be recycled, the corresponding idle time is between 5 seconds and 15 minutes, and when the determined time threshold is 5 minutes, the memory pages with the idle time exceeding 5 minutes can be recycled from the memory pages with 100 pages, and the recycled memory pages are released, so that the idle memory pages of the electronic device are correspondingly increased and can be provided for a foreground application or other background applications.
According to the memory processing method, the recoverable memory pages occupied by the application to be processed and the idle time thereof are obtained, the dependence proportion of the application to be processed on foreground application is obtained, the time threshold is determined according to the idle time and the dependence proportion, and the memory pages with the idle time exceeding the time threshold are recycled.
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 310 includes: and selecting memory pages which have idle time exceeding a time threshold and are not depended on by foreground application from the recoverable memory pages for recovery.
The electronic device can further remove the memory pages depended on by the foreground application, select the memory pages with idle duration exceeding the duration threshold from the recoverable memory pages depended on by the foreground application, and recover the selected memory pages. By selecting the memory pages with the idle time exceeding the time threshold from the memory pages not depended on by the foreground application for recycling, the memory pages depended on by the foreground application can be prevented from being recycled to influence the foreground application.
In one embodiment, step 306 comprises: and acquiring the updating time recorded by the timestamp of each recoverable memory page, and calculating the idle time of the corresponding recoverable memory page according to the updating time.
The electronic device may create a timestamp for each memory page through the resource priority and restriction management module 222, where the timestamp is used to record a corresponding update time, and the update time represents a time when the corresponding memory page is recently used. When it is detected that the memory in each memory page is used, the update time recorded by the timestamp may be updated.
When the allocation, recovery, release, and the like of the memory page are initiated or the use condition of the cache in the processor is queried for the last time, it is determined that the data of the relevant memory page is used, and the system time in the corresponding condition is taken as the update time. When the memory recovery mechanism is started to be executed, the idle time of the corresponding memory page can be calculated according to the update time recorded by the timestamp and the current system time. The difference between the current time and the latest time is the idle time length of the corresponding memory page.
The method records the updating time of each recoverable memory page by using a mode of creating a timestamp by software, determines the idle time according to the updating time, can effectively be compatible with different processors, and improves the universality of memory recovery.
In one embodiment, step 306 includes: and acquiring the updating time of each recoverable memory page recorded by the LRU management unit which is not used for the longest time, and calculating the idle time of the corresponding recoverable memory page according to the updating time.
In a memory management or cache unit in a processor, a corresponding Least Recently Used (LRU) management unit is set for counting Recently Used memories. The LRU management unit records each memory address and the update time of the memory address, and when the memory of a certain address is used, the processor stores the corresponding memory address and the update time in the LRU management unit. When the memory recovery mechanism is started, the memory page corresponding to each memory address can be known according to the corresponding relationship between the memory address and the memory page, and the update time of the corresponding memory page can be read from the LRU management unit. When the allocation, recovery, release, and the like of the memory page are initiated or the use condition of the cache in the processor is queried for the last time, it is determined that the data of the relevant memory page is used, and the system time in the corresponding condition is taken as the update time.
When the LRU management unit is full, it can generate interrupt information and notify the operating system, and the operating system can clear the data in the LRU management unit after reading the data, so that the LRU management unit can restart working and store each memory address and its corresponding update time.
In this embodiment, by creating the LRU management unit, the usage of each memory can be accurately tracked, the accuracy of detecting the update time of the memory page is improved, and the convenience of memory recovery is also improved.
In one embodiment, step 308 comprises: calculating the average idle time of the application to be processed on the recoverable memory pages according to the idle time of each recoverable memory page; and determining a time length threshold according to the average idle time length and the dependence proportion.
The average idle duration may be an average of the occupied duration of each memory page in the recoverable memory pages occupied by the to-be-processed application. The electronic device can call the corresponding computing unit to compute according to the counted occupied time length of each memory page, so as to compute the average idle time length. Alternatively, the calculated average idle time length may be used as the reference time length, and the time length threshold value may be determined according to the reference time length and the dependency ratio.
The time length threshold value is determined according to the average idle time length and the dependence proportion, so that the calculation efficiency of the time length threshold value can be improved, the calculation is simple, and the efficiency of memory recovery is correspondingly improved.
In one embodiment, as shown in FIG. 4, step 308 comprises:
step 402, obtaining a corresponding relation between a recovery proportion corresponding to the application to be processed and the secondary starting time length.
The secondary starting time length refers to 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 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 corresponding recovery ratio and a comparison table of the secondary start-up time length, or a recovery ratio curve. The curve is the corresponding secondary start-up duration at different recovery ratios. 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.
In step 404, the recovery number of the memory pages is determined according to the dependency proportion and the corresponding relationship between the recoverable memory pages and the recovery proportion and the secondary start duration.
The electronic equipment can set a corresponding starting time length threshold value, and when the secondary starting time length reaches the starting time length threshold value, the corresponding proportion is used as the reference proportion of 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. The recycle number is the number of recycles to the memory page, which is a positive integer.
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 approximate linearity represents the secondary starting time length which is fitted by different recovery proportions according to correspondingly approximate slopes, and the error between the secondary starting time length corresponding to the recovery proportions does not exceed the error within the preset range.
For example, as shown in fig. 5A, 5B to 5C, there are recovery ratio curves for applications of independent classes, linear classes and non-linear classes, respectively, in one embodiment. The abscissa in the recovery ratio curve represents the recovery ratio, and the ordinate represents the secondary start time 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 ratio corresponding to the minimum slope can be selected as the recovery ratio of the recoverable memory page, i.e. as the reference ratio.
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 proportions aiming at different applications, and sets a reference proportion 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.
When the number of products is not an integer, an integer similar to the product may be selected, for example, the nearest integer may be determined as the recycling number by rounding, or the corresponding integer may be determined as the recycling number 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 recovery ratio is 30.5%, the product obtained is 30.5, 31 pages can be recovered from the 100 recoverable memory pages, and if the recovery ratio is 21.2%, 21 pages can be recovered.
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.
Step 406, selecting the kth idle time from the idle time of each recoverable memory page according to the recovery number, and using the selected idle time as a time threshold.
The number of idle time durations exceeding the Kth is a recovery number, and K is a natural number not exceeding the recovery number. The electronic device may sort the idle durations of the recoverable memory pages from small to large, select the kth idle duration, and use the idle duration as a duration threshold. Wherein, the number of idle durations exceeding the Kth is the recovery number. It is understood that K is a natural number not exceeding the recovery number. For example, the total number of the recoverable memory pages is 100, and when the determined recovery number is 50, K =51, the idle duration with the 51 th size may be selected from the idle durations of the 100 recoverable memory pages, the idle duration is used as a duration threshold, and 50 recoverable memory pages with the idle duration exceeding the 51 th size are selected for recovery.
By selecting the Kth idle time as the time threshold, the flexibility of recycling the recyclable memory is improved.
In one embodiment, step 302 includes: inquiring all memory pages of a memory occupied by the application to be processed; reclaimable memory pages are retrieved from all memory pages.
Optionally, the electronic device may record, in real time, memory pages of the memory 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, the retrieving the recyclable 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 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 normally operating, when the data is deleted, the application to be processed either cannot normally operate, or needs to repeatedly occupy a new memory page 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 recoverable memory pages from the memory pages after the rejection.
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 the Binder communication exists between the foreground application and the background process in the Binder drive, and call the detection mechanism set in the Binder drive to detect the background process which has the 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 individual lock resources, including thread locks, file handles, semaphores, and the like. For each lock resource, it may be detected whether a lock wait occurs, i.e., the lock resource waits. When the generation of the lock wait is detected, it may be further detected whether the wait generation action 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 waiting interface native to 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 of the user mode (user mode) can be realized 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. 6, another memory processing method is provided, where the method includes:
step 602, traversing a memory mapping file of an 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 the application is set to the deep freeze mode by 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 604, removing the memory pages carrying the occupation marks from all the 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 recyclable memory page, when a memory page carrying an occupied mark is detected, judging that the memory page is an unrecoverable memory page, eliminating the memory page, and selecting the memory page obtained after the secondary traversal as the recyclable memory page, wherein the electronic equipment can select the memory page from all the recyclable memory pages to recycle. The comprehensiveness of the recoverable memory page detection can be improved through secondary traversal.
Step 606, 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, the data stored in the recoverable memory pages which are specifically depended on by the foreground application are detected, and the dependence proportion is determined 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 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 provided with a corresponding dependency identifier and whether the dependency identifier represents that the application to be processed is depended on by the foreground application, the dependency proportion of the application to be processed, which is depended on by 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.
Step 608, obtaining the idle time of the application to be processed for each recoverable memory page.
In an embodiment, the update time recorded by the timestamp of each recoverable memory page may be obtained, and the idle duration of the corresponding recoverable memory page may be calculated according to the update time.
In one embodiment, the update time of each recoverable memory page recorded by the least recently used LRU management unit may also be obtained, and the idle duration of the corresponding recoverable memory page may be calculated according to the update time.
Step 610, determining a duration threshold according to the idle duration and the dependency proportion of each recoverable memory page.
In one embodiment, the average idle duration of the application to be processed on the recoverable memory pages is calculated according to the idle duration of each recoverable memory page; and determining a time length threshold according to the average idle time length and the dependence proportion.
In one embodiment, the recovery number of the memory pages can be determined according to the obtained corresponding relation between the recovery proportion corresponding to the application to be processed and the secondary starting time length and the dependence proportion and the corresponding relation; then, selecting the K-th idle time from the idle time of the recoverable memory pages according to the recovery number, and taking the selected idle time as a time threshold; the number of idle durations exceeding the Kth is the recovery number, and K is a natural number not exceeding the recovery number.
Step 612, selecting the memory pages which have idle duration exceeding the duration threshold and are not depended on by the foreground application from the recoverable memory pages for recovery.
Further, the kth idle duration may be selected from the memory pages not depended on by the foreground application as the duration threshold. In the memory pages not depended on by foreground application, the number of idle time durations exceeding the Kth is the recovery number. That is, only the idle duration in the memory pages not depended on by the foreground application is sorted and selected. By reclaiming 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, 4 and 6 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 limited to being performed in the exact order illustrated and, unless explicitly stated herein, may be performed in other orders. Moreover, at least some of the steps in fig. 3, 4, and 6 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 alternatingly with other steps or at least some of the sub-steps or stages of other steps.
In one embodiment, as shown in fig. 7, there is provided a memory processing apparatus, the apparatus comprising: a memory page obtaining module 702, a dependency determining module 704, a duration determining module 706, and a memory recycling module 708. The memory page acquiring module 702 is configured to acquire a recoverable memory page occupied by the application to be processed; the dependency determining module 704 is configured to obtain a dependency ratio of the to-be-processed application being depended on by the foreground application; the duration determining module 706 is configured to obtain an idle duration of each recoverable memory page for the application to be processed; determining a time length threshold value according to the idle time length and the dependence proportion of each recoverable memory page; the memory recovery module 708 is configured to select a memory page with an idle duration exceeding a duration threshold from the recoverable memory pages for recovery.
In an embodiment, the memory page obtaining module 702 is further configured to query all memory pages of the memory occupied by the application to be processed; memory pages carrying occupied 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 702 is further configured to traverse a memory mapped 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, dependency determination module 704 is further configured to detect whether 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 recovery module 708 is configured to select, from the recoverable memory pages, a memory page that has an idle duration exceeding a duration threshold and is not depended on by a foreground application for recovery.
In an embodiment, the duration determining module 706 is further configured to obtain an update time of the timestamp record of each recoverable memory page, and calculate an idle duration corresponding to the recoverable memory page according to the update time.
In an embodiment, the duration determining module 706 is further configured to obtain an update time of each recoverable memory page recorded by the least recently used LRU management unit, and calculate an idle duration of the corresponding recoverable memory page according to the update time.
In an embodiment, the duration determining module 706 is further configured to calculate an average idle duration of the application to be processed on the recoverable memory page according to the idle duration of each recoverable memory page; and determining a time length threshold according to the average idle time length and the dependence proportion.
In one embodiment, the duration determining module 706 is further configured to obtain a correspondence between a recovery ratio corresponding to the application to be processed and the secondary start duration; the secondary starting time length is the time length spent when the recyclable memory page occupied by the application to be processed is restarted after being recycled according to the recycling proportion corresponding to the recycling; determining the recovery quantity of the memory pages according to the dependence proportion and the corresponding relation between the recoverable memory pages and the recovery proportion and the secondary starting duration; selecting a Kth idle time from the idle time of each recoverable memory page according to the recovery number, and taking the selected idle time as a time threshold; the number of idle durations exceeding the kth is the recovery number, and K is a natural number not exceeding the recovery number.
In one embodiment, dependency determination module 704 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 idle time thereof are obtained, the dependence proportion of the application to be processed on foreground application is obtained, the time threshold value is determined according to the idle time and the dependence proportion, and the memory pages with the idle time exceeding the time threshold value are recycled.
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 may be embedded in a hardware form or may be independent of a processor in the electronic device, or may be stored in a memory in the electronic device in a software form, so that the processor calls and executes 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. The computer program, when executed by a processor, 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 storage, a processor, and a computer program stored in the storage 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 comprising instructions which, when run on a computer, cause the computer to perform the memory processing methods described in the embodiments of the present application is provided.
The embodiment of the application also provides computer equipment. As shown in fig. 8, 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. 8 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. 8, the handset includes: radio Frequency (RF) circuit 810, memory 820, input unit 830, display unit 840, sensor 850, audio circuit 860, wireless fidelity (WiFi) module 870, processor 880, and power supply 890. Those skilled in the art will appreciate that the handset configuration shown in fig. 8 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 810 may be used for receiving and transmitting signals during information transmission and reception or during a call, and may receive downlink information of a base station and then process the downlink information to the processor 880; the uplink data may also be transmitted to the base station. Typically, the RF circuitry 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 810 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 820 may be used to store software programs and modules, and the processor 880 executes various functional applications and data processing of the cellular phone by operating the software programs and modules stored in the memory 820. The memory 820 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application 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 820 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 830 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 800. Specifically, the input unit 830 may include a touch panel 831 and other input devices 832. The touch panel 831, which may also be referred to as a touch screen, may collect touch operations performed by a user on or near the touch panel 831 (e.g., operations performed by a user on or near the touch panel 831 using any suitable object or accessory such as a finger, a stylus, etc.) and drive the corresponding connection device according to a preset program. In one embodiment, the touch panel 831 can include two portions, 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 sends the touch point coordinates to the processor 880, and can receive and execute commands from the processor 880. In addition, the touch panel 831 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 830 may include other input devices 832 in addition to the touch panel 831. In particular, other input devices 832 may include, but are not limited to, one or more of a physical keyboard, function keys (such as volume control keys, switch keys, etc.), and the like.
The display unit 840 may be used to display information input by the user or information provided to the user and various menus of the cellular phone. The display unit 840 may include a display panel 841. In one embodiment, the Display panel 841 may be configured in the form of a Liquid Crystal Display (LCD), an Organic Light-Emitting Diode (OLED), or the like. In one embodiment, touch panel 831 can overlay display panel 841, and when touch panel 831 detects a touch operation thereon or nearby, communicate to processor 880 to determine the type of touch event, and processor 880 can then provide a corresponding visual output on display panel 841 based on the type of touch event. Although in fig. 8, the touch panel 831 and the display panel 841 are two separate components to implement the input and output functions of the mobile phone, in some embodiments, the touch panel 831 and the display panel 841 may be integrated to implement the input and output functions of the mobile phone.
The cell phone 800 may also include at least one sensor 850, 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 841 according to the brightness of ambient light, and a proximity sensor that turns off the display panel 841 and/or the 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 860, speaker 861 and microphone 862 can provide an audio interface between a user and a handset. The audio circuit 860 can transmit the electrical signal converted from the received audio data to the speaker 861, and the electrical signal is converted into a sound signal by the speaker 861 and output; on the other hand, the microphone 862 converts the collected sound signal into an electrical signal, which is received by the audio circuit 860 and then converted into audio data, and then the audio data is output to the processor 880 for processing, and then the audio data is sent to another mobile phone through the RF circuit 810, or the audio data is output to the memory 820 for subsequent processing.
WiFi belongs to a short-distance wireless transmission technology, and the mobile phone can help a user to receive and send emails, browse webpages, access streaming media and the like through the WiFi module 870, and provides wireless broadband internet access for the user. Although fig. 8 shows WiFi module 870, it is understood that it does not necessarily form part of cell phone 800 and may be omitted as desired.
The processor 880 is a control center of the mobile phone, connects various parts of the entire mobile phone 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 820 and calling data stored in the memory 820, thereby integrally monitoring the mobile phone. In one embodiment, processor 880 may include one or more processing units. In one embodiment, the processor 880 may integrate an application processor and a modem, wherein the application processor primarily handles operating systems, user interfaces, applications, etc.; the modem handles primarily wireless communications. It is to be appreciated that the modem need not be integrated into the processor 880. For example, the processor 880 may integrate an application processor with a baseband processor, which may form a modem with other peripheral chips, etc. The cell phone 800 also includes a power supply 890 (e.g., a battery) for powering the various components, which may be logically coupled to the processor 880 via a power management system that may be used to manage charging, discharging, and power consumption.
In one embodiment, the cell phone 800 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 memory processing method described above 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 DRAM (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 the idle time of the application to be processed for each recoverable memory page;
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; selecting a Kth idle time from the idle time of each recoverable memory page according to the recovery quantity, and taking the selected idle time as a time threshold; the number of the idle time lengths exceeding the Kth is the recovery number, and K is a natural number exceeding the recovery number;
and selecting memory pages with idle time exceeding the time threshold 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 foreground application or depended on by the foreground application;
the selecting, from the recoverable memory pages, a memory page whose idle duration exceeds the duration threshold for recovery includes:
and selecting memory pages which have idle time exceeding the time threshold and are not depended on by foreground application from the recoverable memory pages for recovery.
3. The method according to claim 1, wherein the obtaining the idle duration of the pending application for each reclaimable memory page comprises:
acquiring the updating time recorded by the timestamp of each recoverable memory page, and calculating the idle time of the corresponding recoverable memory page according to the updating time; or
And acquiring the updating time of each recoverable memory page recorded by the LRU management unit which is not used for the longest time, and calculating the idle time of the corresponding recoverable memory page according to the updating time.
4. The method according to claim 1, wherein the determining the duration threshold according to the idle duration of each of the reclaimable memory pages and the dependency ratio comprises:
calculating the average idle time of the application to be processed for the recoverable memory page according to the idle time of each recoverable memory page;
and determining a time length threshold according to the average idle time length and the dependence proportion.
5. 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 page occupied by the application 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.
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 recyclable memory pages from the rejected memory pages.
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:
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 dependency scale reflects the degree of dependency of the application on which the dependent application depends;
a duration determining module, configured to obtain an idle duration of each recoverable memory page for the application to be processed; 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; selecting a Kth idle time from the idle time of each recoverable memory page according to the recovery number, and taking the selected idle time as a time threshold; the number of the idle time lengths exceeding the Kth is the recovery number, and K is a natural number exceeding the recovery number;
and the memory recovery module is used for selecting the memory pages with the idle time exceeding the time threshold 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.
CN201810023217.2A 2018-01-10 2018-01-10 Memory processing method and device, electronic equipment and computer readable storage medium Active CN110018900B (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN201810023217.2A CN110018900B (en) 2018-01-10 2018-01-10 Memory processing method and device, electronic equipment and computer readable storage medium
PCT/CN2018/125326 WO2019137258A1 (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
CN201810023217.2A CN110018900B (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
CN110018900A CN110018900A (en) 2019-07-16
CN110018900B true CN110018900B (en) 2023-01-24

Family

ID=67188088

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810023217.2A Active CN110018900B (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) CN110018900B (en)
WO (1) WO2019137258A1 (en)

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111158910B (en) * 2019-12-27 2024-01-12 Oppo广东移动通信有限公司 Memory management method and device, storage medium and electronic equipment
CN113392037A (en) * 2020-03-12 2021-09-14 深圳市万普拉斯科技有限公司 Memory recovery method and device, computer equipment and storage medium
CN113590509B (en) * 2020-04-30 2024-03-26 华为技术有限公司 Page exchange method, storage system and electronic equipment
CN111625351A (en) * 2020-05-12 2020-09-04 Oppo(重庆)智能科技有限公司 Method and device for recycling file pages, terminal and readable storage medium
CN111831440A (en) * 2020-07-01 2020-10-27 Oppo广东移动通信有限公司 Memory recovery method and device, storage medium and electronic equipment
CN111949564A (en) * 2020-08-13 2020-11-17 青岛海信传媒网络技术有限公司 Memory exchange method and display device

Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
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
CN103092700A (en) * 2013-02-01 2013-05-08 华为终端有限公司 Internal memory cleaning method and cleaning device and terminal device
CN103324500A (en) * 2013-05-06 2013-09-25 广州市动景计算机科技有限公司 Method and device for recycling internal memory
WO2014094472A1 (en) * 2012-12-17 2014-06-26 华为技术有限公司 Global memory sharing method and device and communication system
CN105159777A (en) * 2015-08-03 2015-12-16 中科创达软件股份有限公司 Process memory collection method and apparatus
CN105446814A (en) * 2014-09-30 2016-03-30 青岛海信移动通信技术股份有限公司 Cache recovery method and device
WO2016119605A1 (en) * 2015-01-27 2016-08-04 阿里巴巴集团控股有限公司 Method for memory allocation during application start in terminal and system thereof
CN106331148A (en) * 2016-09-14 2017-01-11 郑州云海信息技术有限公司 Cache management method and cache management device for data reading by clients
CN106569733A (en) * 2015-10-12 2017-04-19 北京国双科技有限公司 Processing method and processing device for buffered data
WO2017114288A1 (en) * 2015-12-31 2017-07-06 华为技术有限公司 Memory collection method and device

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP5385347B2 (en) * 2011-08-02 2014-01-08 レノボ・シンガポール・プライベート・リミテッド Method and computer for enlarging free memory in main memory
CN103500121A (en) * 2013-09-29 2014-01-08 深圳Tcl新技术有限公司 Process managing method and device
CN103631661B (en) * 2013-11-27 2017-04-05 青岛海信电器股份有限公司 A kind of EMS memory management process and device
US9424195B2 (en) * 2014-04-15 2016-08-23 Advanced Micro Devices, Inc. Dynamic remapping of cache lines
US10552179B2 (en) * 2014-05-30 2020-02-04 Apple Inc. Resource management with dynamic resource policies
CA2876379A1 (en) * 2014-12-29 2016-06-29 Adam J. Storm Memory management in presence of asymmetrical memory transfer costs

Patent Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
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
WO2014094472A1 (en) * 2012-12-17 2014-06-26 华为技术有限公司 Global memory sharing method and device and communication system
CN103092700A (en) * 2013-02-01 2013-05-08 华为终端有限公司 Internal memory cleaning method and cleaning device and terminal device
CN103324500A (en) * 2013-05-06 2013-09-25 广州市动景计算机科技有限公司 Method and device for recycling internal memory
CN105446814A (en) * 2014-09-30 2016-03-30 青岛海信移动通信技术股份有限公司 Cache recovery method and device
WO2016119605A1 (en) * 2015-01-27 2016-08-04 阿里巴巴集团控股有限公司 Method for memory allocation during application start in terminal and system thereof
CN105159777A (en) * 2015-08-03 2015-12-16 中科创达软件股份有限公司 Process memory collection method and apparatus
CN106569733A (en) * 2015-10-12 2017-04-19 北京国双科技有限公司 Processing method and processing device for buffered data
WO2017114288A1 (en) * 2015-12-31 2017-07-06 华为技术有限公司 Memory collection method and device
CN106331148A (en) * 2016-09-14 2017-01-11 郑州云海信息技术有限公司 Cache management method and cache management device for data reading by clients

Also Published As

Publication number Publication date
WO2019137258A1 (en) 2019-07-18
CN110018900A (en) 2019-07-16

Similar Documents

Publication Publication Date Title
CN110018900B (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
CN110018902B (en) Memory processing method and device, electronic equipment and computer readable storage medium
US11099900B2 (en) Memory reclamation method and apparatus
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
CN111274039B (en) Memory recycling method and device, storage medium and electronic equipment
CN109992399B (en) Resource management method, resource management device, mobile terminal and computer-readable storage medium
CN110018885B (en) Application program freezing method and device, storage medium and terminal
CN110018886B (en) Application state switching method and device, electronic equipment and readable storage medium
WO2019128542A1 (en) Application processing method, electronic device, computer readable storage medium
CN112445766A (en) Terminal fragment sorting method and device and terminal
WO2019137173A1 (en) Resource management method, mobile terminal and computer-readable storage medium
CN107682892B (en) Flow control method and device, computer equipment 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
CN109992394B (en) Process processing method and device, electronic equipment and computer readable storage medium
CN109992376B (en) Application freezing method, device, terminal and computer readable storage medium
CN109992361B (en) Application freezing method and device, terminal and computer readable storage medium
CN110032398B (en) Application 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
CN117130947A (en) Memory management method and electronic equipment

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
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.

GR01 Patent grant
GR01 Patent grant