CN114443510A - Memory recovery method and device - Google Patents

Memory recovery method and device Download PDF

Info

Publication number
CN114443510A
CN114443510A CN202210087228.3A CN202210087228A CN114443510A CN 114443510 A CN114443510 A CN 114443510A CN 202210087228 A CN202210087228 A CN 202210087228A CN 114443510 A CN114443510 A CN 114443510A
Authority
CN
China
Prior art keywords
memory
target
memory resource
target kernel
resource group
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.)
Pending
Application number
CN202210087228.3A
Other languages
Chinese (zh)
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.)
Vivo Mobile Communication Co Ltd
Original Assignee
Vivo Mobile Communication Co 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 Vivo Mobile Communication Co Ltd filed Critical Vivo Mobile Communication Co Ltd
Priority to CN202210087228.3A priority Critical patent/CN114443510A/en
Publication of CN114443510A publication Critical patent/CN114443510A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/0223User address space allocation, e.g. contiguous or non contiguous base addressing
    • G06F12/023Free address space management
    • G06F12/0253Garbage collection, i.e. reclamation of unreferenced memory
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • 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/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
    • 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/505Allocation 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 load
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/50Indexing scheme relating to G06F9/50
    • G06F2209/5018Thread allocation

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Memory System (AREA)

Abstract

The application discloses a memory recovery method and device, and belongs to the technical field of memory management. The memory recovery method comprises the following steps: establishing a plurality of memory resource groups, wherein each memory resource group corresponds to at least one application program of the electronic equipment; and under the condition that the used memory of the electronic equipment reaches a target memory threshold value, recovering the memory of the memory resource group through a target kernel thread, wherein the target kernel thread is a kernel thread for page recovery.

Description

Memory recovery method and device
Technical Field
The application belongs to the technical field of memory management, and particularly relates to a memory recovery method and device.
Background
The electronic equipment brings great convenience to life and work of people, and more scenes are used in daily work. The speed of memory recovery is an important guarantee of the fluency of electronic equipment, a native system usually uses one thread for memory recovery, and the memory recovery is carried out according to the remaining capacity of the memory, but the memory recovery rate of a single thread is not high; in order to improve the memory recovery rate, a plurality of threads are adopted for memory recovery at present, but although the memory recovery speed of the threads is high, serious lock competition exists, performance degradation is easily caused, the problems that electronic equipment is easy to cause screen-locking and flashing under the scene that the memory is used too high are caused, and user experience is influenced.
Disclosure of Invention
The embodiment of the application aims to provide a memory recovery method and device, and the method and device can solve the problems that when a plurality of threads are adopted to recover a memory in the prior art, serious lock competition exists, performance degradation is easily caused, and then electronic equipment is easily blocked and flickered in a scene with over-high memory usage.
In a first aspect, an embodiment of the present application provides a memory recycling method, where the method includes:
establishing a plurality of memory resource groups, wherein each memory resource group corresponds to at least one application program of the electronic equipment;
and under the condition that the used memory of the electronic equipment reaches a target memory threshold value, recovering the memory of the memory resource group through a target kernel thread, wherein the target kernel thread is a kernel thread for page recovery.
In a second aspect, an embodiment of the present application provides a memory recycling device, where the device includes:
the system comprises an establishing module, a processing module and a processing module, wherein the establishing module is used for establishing a plurality of memory resource groups, and each memory resource group corresponds to at least one application program of the electronic equipment;
the recovery module is configured to recover, by a target kernel thread, the memory of the memory resource group when the used memory of the electronic device reaches a target memory threshold, where the target kernel thread is a kernel thread for page recovery.
In a third aspect, an embodiment of the present application provides an electronic device, which includes a processor, a memory, and a program or instructions stored on the memory and executable on the processor, and when executed by the processor, the program or instructions implement the steps of the method according to the first aspect.
In a fourth aspect, embodiments of the present application provide a readable storage medium, on which a program or instructions are stored, which when executed by a processor implement the steps of the method according to the first aspect.
In a fifth aspect, an embodiment of the present application provides a chip, where the chip includes a processor and a communication interface, where the communication interface is coupled to the processor, and the processor is configured to execute a program or instructions to implement the method according to the first aspect.
In the embodiment of the application, the memory resource groups are established according to the application programs on the electronic equipment, and are dynamically bound with the kernel threads for recovering the memory, when the used memory of the electronic equipment reaches a certain threshold value, the memory of the corresponding memory resource groups can be recovered through the dynamically bound target kernel threads, so that the lock competition among the target kernel threads is reduced, the performance problem caused by the lock competition is reduced, the memory bump is reduced, the system smoothness is improved, and the use experience of a user is improved.
Drawings
Fig. 1 is a schematic flow chart illustrating a memory recovery method according to an embodiment of the present disclosure;
fig. 2 is a schematic flowchart of another memory recycling method according to an embodiment of the present disclosure;
fig. 3 is a schematic diagram illustrating a memory reclamation principle according to an embodiment of the present application;
fig. 4 is a schematic structural diagram of a memory recovery apparatus according to an embodiment of the present disclosure;
fig. 5 is a schematic structural diagram of an electronic device according to an embodiment of the present disclosure;
fig. 6 is a schematic diagram of a hardware structure of an electronic device implementing an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be described clearly below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are some, but not all, embodiments of the present application. All other embodiments that can be derived by one of ordinary skill in the art from the embodiments given herein are intended to be within the scope of the present disclosure.
The terms first, second and the like in the description and in the claims of the present application are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It will be appreciated that the data so used may be interchanged under appropriate circumstances such that embodiments of the application may be practiced in sequences other than those illustrated or described herein, and that the terms "first," "second," and the like are generally used herein in a generic sense and do not limit the number of terms, e.g., the first term can be one or more than one. In addition, "and/or" in the specification and claims means at least one of connected objects, a character "/" generally means that a preceding and succeeding related objects are in an "or" relationship.
The following describes in detail the memory recovery method and apparatus provided in the embodiments of the present application with reference to the accompanying drawings.
Referring to fig. 1, fig. 1 is a schematic flow chart illustrating a memory recycling method according to an embodiment of the present disclosure. As shown in fig. 1, an embodiment of an aspect of the present application provides a memory recycling method, which can be applied to an electronic device, and the method includes the following steps:
step 101: establishing a plurality of memory resource groups, wherein each memory resource group corresponds to at least one application program of the electronic equipment;
in this embodiment of the present application, optionally, the electronic device has a memory resource controller, and the memory resource controller may group memory resources according to some grouping manners. The number of the application programs installed on the electronic equipment is the same as the number of the established memory resource groups, and when the number of the application programs on the electronic equipment is increased or decreased, the memory resource groups can be correspondingly increased or decreased. By establishing the memory resource grouping mode according to the application program, the memory resources can be effectively divided so as to be convenient for respectively recycling the memory resources of each memory resource grouping in the following, thereby realizing load balancing and avoiding excessive competition during memory recycling.
Step 102: and under the condition that the used memory of the electronic equipment reaches a target memory threshold value, recycling the memory of the memory resource group through a target kernel thread.
In this step, the electronic device determines whether the current used memory reaches a target memory threshold, wakes up a target kernel thread when the used memory of the electronic device reaches the target memory threshold, and recovers the memory resources of the memory resource group through the target kernel thread, wherein the target kernel thread is a kernel thread for page recovery, i.e. a kernel thread for memory recovery, which is also called kswapd; that is to say, when the memory of the electronic device needs to be recovered, a certain target kernel thread can recover the memory of at least one application program belonging to a certain memory resource group, so that the memory recovery of multiple threads is realized, the memory recovery efficiency is improved, and moreover, because each target kernel thread can recover different memory resource groups, the probability of lock contention existing in each target kernel thread during the memory recovery is greatly reduced, so that the system performance is improved, and the memory thrashing is reduced.
Therefore, in the embodiment of the application, the memory resource groups are established according to the application program on the electronic equipment, when the used memory of the electronic equipment reaches a certain threshold value, the memory of the corresponding memory resource groups can be recycled through the target kernel thread, so that the lock competition among the target kernel threads is reduced, the performance problem caused by the lock competition is reduced, the memory bump is reduced, the system smoothness is improved, and the use experience of a user is improved.
In some embodiments of the present application, after the establishing a plurality of memory resource groups, each of the memory resource groups corresponds to at least one application program of an electronic device, the method further includes:
dynamically binding the memory resource groups with a plurality of target kernel threads, wherein the target kernel threads are kernel threads for page recovery, and at least one memory resource group is correspondingly bound to each target kernel thread;
the recycling the memory of the memory resource group by the target kernel thread includes:
and recovering the memory of the memory resource group dynamically bound with the target kernel thread through the target kernel thread.
That is to say, in the embodiment of the present application, after a plurality of memory resource groups are established, the plurality of memory resource groups may be dynamically bound to a plurality of target kernel threads, where a target kernel thread is a kernel thread for page recovery, that is, a kernel thread for memory recovery, also referred to as kswapd, and each target kernel thread is correspondingly bound to at least one memory resource group, that is, one target kernel thread may bind one memory resource group, or may bind two or more memory resource groups. By dynamic binding, it is meant that the corresponding relationship between the memory resource packets and the target kernel threads is not fixed, for example, when the number of the memory resource packets increases, the increased memory resource packets may be bound to the target kernel threads again, and when the number of the memory resource packets decreases, the number of the memory resource packets bound to the target kernel threads corresponding to the target kernel threads may also change, for example, all the memory resource packets are bound to each target kernel thread in a balanced distribution manner again. By dynamically binding the plurality of memory resource groups and the plurality of target kernel threads, each target kernel thread can only recover the memory of the corresponding bound memory resource group when the memory is required to be recovered subsequently, so that the lock competition among the target kernel threads is greatly reduced, the recovery of the memory is accelerated, and the smoothness of the system is improved.
In some embodiments of the present application, the establishing a plurality of memory resource groups, where each memory resource group corresponds to at least one application program of an electronic device includes:
and establishing a corresponding memory resource group for each application program.
That is to say, in this embodiment, one memory resource group is correspondingly established by one application program on the electronic device. By the grouping establishing mode, the grouping of the memory resources is more finely divided, and the subsequent target kernel thread has more pertinence in memory recovery, so that the memory recovery efficiency is improved, and the lock competition is reduced.
In other embodiments of the present application, after dynamically binding the plurality of memory resource groups to the plurality of target kernel threads, the method further includes:
binding other target kernel threads except the first target kernel thread with other CPU kernels except the first CPU kernel of the electronic equipment;
wherein the dominant frequency of the first CPU core is higher than a target frequency threshold.
Exemplarily, in this embodiment, the electronic device includes a first CPU core and other CPU cores except the first CPU core, where the dominant frequency of the first CPU core is higher than that of the other CPU cores, that is, the first CPU core is a large core of the electronic device, and the other CPU cores are small cores of the electronic device. By binding part of the target kernel threads with other CPU kernels of the electronic device except the first CPU kernel, the target kernel threads bound with the other CPU kernels do not occupy the first CPU kernel resource, so that the situation that all the target kernel threads contend for the first CPU kernel and then cause the application program to be blocked can be avoided. Optionally, one first target kernel thread may be removed from all target kernel threads, and then the remaining target kernel threads are bound to other CPU kernels of the electronic device except the first CPU kernel, so that only the first target kernel thread uses the first CPU kernel, which may prevent the first CPU kernel from being contended for, and the first target kernel thread may not be bound to the first CPU kernel, nor to other CPU kernels, which may freely use the first CPU kernel or other CPU kernels.
In other embodiments of the present application, the recovering, by the target kernel thread, the memory of the memory resource group dynamically bound to the target kernel thread when the memory level of the electronic device reaches the target memory threshold includes:
under the condition that the used memory of the electronic equipment reaches a first target memory threshold value, recycling the memory of the corresponding dynamically bound memory resource group through one or more of other target kernel threads except the first target kernel thread;
under the condition that the used memory of the electronic equipment reaches a second target memory threshold value, recycling the memory of the corresponding dynamically bound memory resource group through one or more of all target kernel threads;
wherein the first target memory threshold is less than the second target memory threshold.
In this embodiment, the electronic device determines whether the target kernel thread needs to be awakened to recycle the memory according to the currently used memory, and sets two different target memory thresholds, that is, a first target memory threshold and a second target memory threshold, where the first target memory threshold is smaller than the second target memory threshold, and when the used memory of the electronic device reaches the different target memory thresholds, the recycling policies are different. Exemplarily, if the used memory of the electronic device reaches a first target memory threshold, that is, the used memory of the electronic device is less at this time, and the memory recovery requirement is not urgent, the memory corresponding to the dynamically bound memory resource group is awakened and recovered by one or more of other target kernel threads except the first target kernel thread, and since the other target kernel threads except the first target kernel thread are bound to the other CPU kernels except the first CPU kernel of the electronic device, the resources of the first CPU kernel are not occupied, so that the fluency of the system is not substantially affected, and the use experience of the user is not affected; and if the used memory of the electronic device reaches the second target memory threshold, that is, the used memory of the electronic device is more and the memory recovery requirement is urgent, waking up and recovering the memory corresponding to the dynamically bound memory resource group through one or more of all target kernel threads.
Therefore, by setting two different target memory thresholds, when the used memory is less, the first target kernel thread does not occupy the resource of the first CPU kernel, so that the occupation of the operation resource is reduced as much as possible, and the fluency of the system is ensured; when the used memory is more, the first target kernel thread is used for using the resource of the first CPU kernel, so that the memory recovery efficiency can be accelerated.
And when the memory is recovered, traversing all the memory resource groups, finding out the memory resource group bound with the currently awakened target kernel thread, then recovering the memory, and if no binding relation exists, not skipping the memory resource group.
In this embodiment, optionally, the first target memory threshold and the second target memory threshold may be preset, and the second target memory threshold may be increased by a predetermined value, for example, 10M, based on the first target memory threshold.
In some embodiments of the present application, the dynamically binding the plurality of memory resource groups with the plurality of target kernel threads includes:
under the condition that the number of the memory resource groups and/or the number of the target kernel threads are changed, rebinding the memory resource groups for each target kernel thread according to the number of the target kernel threads;
and the difference value of the number of the memory resource groups bound by any two target kernel threads after the re-binding is smaller than a target value.
Illustratively, when the number of application programs on the electronic device changes, the number of correspondingly established memory resource packets will also change, or the user changes the number of active target kernel threads, so that the number of target kernel threads changes. And under the condition that at least one of the number of the memory resource groups and the number of the target kernel threads is changed, uniformly distributing all the memory resource groups according to the number of the target kernel threads, and rebinding the memory resource groups for each target kernel thread, so that the difference value of the number of the memory resource groups bound by any two rebinding target kernel threads is smaller than a target value, and the balance of the memory resource groups corresponding to each target kernel thread is ensured when the number of the memory resource groups and/or the number of the target kernel threads are changed. Optionally, the target number may be preset, for example, the target number is 2, that is, a difference between the numbers of the memory resource packets bound to any two target kernel threads is less than 2. The memory resource groups are dynamically bound for the target kernel threads, so that the effect of balancing the memory resource groups corresponding to each target kernel thread in real time can be achieved, and memory thrashing is reduced.
For example, when the memory resource grouping bound by a certain target kernel thread is reduced, the memory resource grouping corresponding to other target kernel threads can be balanced to the target kernel thread, so that the overall balancing effect is realized; for another example, when the memory resource grouping is increased, the increased memory resource grouping is dynamically bound to the corresponding target kernel thread, so that the overall balance effect is realized.
Referring to fig. 2, fig. 2 is a schematic flow chart illustrating another memory recycling method according to an embodiment of the present disclosure. As shown in fig. 2, an embodiment of the present application provides another memory recycling method, where the method includes:
step 201: establishing a memory resource group for each application program, and managing the use of memory resources;
for example, a memory resource group mem _ cgroup1 is established for the application APP1, a memory resource group mem _ cgroup2 is established for the application APP2, a memory resource group mem _ cgroup2 is established for the application APP2, a memory resource group mem _ cgroup3 is established for the application APP3, a memory resource group mem _ cgroup4 is established for the application AP,4, a memory resource group mem _ cgroup5 is established for the application APP5, and so on.
Step 202: dynamically binding a plurality of memory resource groups to a plurality of target kernel threads;
in this step, a plurality of memory resource packets are dynamically bound to a plurality of target kernel threads through a dynamic binding algorithm, wherein one target kernel thread is correspondingly bound with at least one memory resource packet. For example, the memory resource packet mem _ cgroup1 and memory resource packet mem _ cgroup2 are dynamically bound to the target core thread kswapd0, the memory resource packet mem _ cgroup3 and memory resource packet mem _ cgroup4 are dynamically bound to the target core thread kswapd1, and the memory resource packet mem _ cgroup5 is dynamically bound to the target core thread kswapd 3.
In this embodiment, optionally, the target kernel thread kswapd0 is not bound to any CPU kernel of the electronic device, and the target kernel thread kswapd1, the target kernel thread kswapd2, and the like are bound to a CPU corelet of the electronic device.
Step 203: triggering memory recovery by a target kernel thread when a water level condition is met;
the water level is a water level of a memory of the electronic device, and is used for measuring the capacity of the remaining memory of the electronic device. For the target kernel thread kswapd0, the set water level condition is that the native water level water _ mark is used, that is, when the water level reaches the native water level water _ mark, the target kernel thread kswapd0 is triggered to perform memory recovery; for target kernel threads kswapd1, kswapd2 and the like of bound CPU corelets, a delta _ mark value, namely, water _ mark + delta _ mark, is increased on the basis of a native water level, namely, when the water level reaches the water _ mark + delta _ mark, the target kernel threads kswapd1, kswapd2 and the like are triggered to perform memory recovery.
Step 204: and traversing all the memory resource groups, and recycling the memory through the target kernel thread to which the memory resource groups belong.
And when the corresponding water level condition is met, the memory resource of the target kernel thread is recycled through the target kernel thread correspondingly bound to the memory resource packet. Specifically, all the memory resource packets may be traversed to find the memory resource packet bound to the target kernel thread, and then the target kernel thread is used to recycle the memory of the memory resource packet.
Referring to fig. 3, fig. 3 is a schematic diagram illustrating a memory reclamation principle according to an embodiment of the present application. As shown in the upper part of fig. 3, in the prior art, when memory recovery is performed, a page needs to be recovered from the tail of the page replacement algorithm linked list lru _ list, for example, when page recovery is performed from the tail by using multiple kernel threads (e.g., kswapd0 and kswapd1), kswapd0 and kswapd1 may simultaneously separate pages from the tail of the page replacement algorithm linked list lru _ list, at this time, a severe contention relationship, i.e., lock contention, exists, and such a recovery manner may cause excessive recovery of memory of a certain application, for example, when the page replacement algorithm linked list lru _ list is a page of the same application, excessive recovery of memory of the application may be caused, and when the application is subsequently awakened again, a page re-application is required, so that response time is increased, and computational resources are occupied, and a problem of memory thrashing exists.
As shown in the lower content of fig. 3, with the memory reclamation method in the embodiment of the present application, a plurality of memory resource groups (e.g., mem _ cgroup0, mem _ cgroup1, mem _ cgroup2, and mem _ cgroup3) are established, and the plurality of memory resource groups are dynamically and equally bound to a plurality of target kernel threads (e.g., kswapd0 and kswapd1), then the page replacement algorithm linked list lru _ list is also equally split into a plurality of linked lists. When the memory is recycled, the target kernel threads which are correspondingly bound with the memory resource groups are adopted to recycle the memory, namely, the memory is recycled dispersedly, so that the competition among a plurality of target kernel threads is reduced, and the memory recycling speed is improved.
In summary, in the embodiment of the present application, a memory resource group is established according to an application program on an electronic device, and the memory resource group is dynamically bound to a kernel thread for recovering a memory, and when a used memory of the electronic device reaches a certain threshold, the memory of the corresponding memory resource group can be recovered through a target kernel thread that is dynamically bound, so that lock contention among the target kernel threads is reduced, performance problems caused by the lock contention are reduced, memory thrashing is reduced, system fluency is improved, and user experience is improved.
It should be noted that in the memory recovery method provided in the embodiment of the present application, the execution main body may be a memory recovery device, or a control module in the memory recovery device for executing the memory recovery method. The memory recovery device provided in the embodiment of the present application is described with an example of a memory recovery device executing a memory recovery method.
Referring to fig. 4, fig. 4 is a schematic structural diagram of a memory recycling device according to an embodiment of the present disclosure. As shown in fig. 4, another embodiment of the present application further provides a memory recycling apparatus, where the apparatus 400 includes:
an establishing module 401, configured to establish a plurality of memory resource groups, where each memory resource group corresponds to at least one application program of an electronic device;
a recycling module 402, configured to recycle, by a target kernel thread, the memory of the memory resource group when the used memory of the electronic device reaches a target memory threshold, where the target kernel thread is a kernel thread for page recycling.
Optionally, the establishing module includes:
and the establishing unit is used for establishing a corresponding memory resource group for each application program.
Optionally, the apparatus further comprises:
the first binding module is used for dynamically binding the memory resource groups with a plurality of target kernel threads, wherein the target kernel threads are kernel threads for page recovery, and at least one memory resource group is correspondingly bound to each target kernel thread;
the recovery module includes:
and the recovery unit is used for recovering the memory of the memory resource group dynamically bound with the target kernel thread through the target kernel thread under the condition that the used memory of the electronic equipment reaches a target memory threshold value.
Optionally, the apparatus further comprises:
the second binding module is used for binding other target kernel threads except the first target kernel thread with other CPU kernels except the first CPU kernel of the electronic equipment;
wherein the dominant frequency of the first CPU core is higher than a target frequency threshold.
Optionally, the recycling module includes:
a first recovery unit, configured to, when a used memory of the electronic device reaches a first target memory threshold, recover, by using one or more of other target kernel threads except the first target kernel thread, a memory of a memory resource group that corresponds to the dynamic binding;
a second recovery unit, configured to, when a used memory of the electronic device reaches a second target memory threshold, recover, through one or more of all target kernel threads, a memory of a corresponding dynamically bound memory resource group;
wherein the first target memory threshold is less than the second target memory threshold.
Optionally, the first binding module includes:
a binding unit, configured to rebind the memory resource packet for each target kernel thread according to the number of target kernel threads when the number of memory resource packets and/or the number of target kernel threads are changed;
and the difference value of the number of the memory resource groups bound by any two target kernel threads after the re-binding is smaller than a target value.
In the embodiment of the application, the memory resource groups are established according to the application programs on the electronic equipment, and are dynamically bound with the kernel threads for recovering the memory, when the used memory of the electronic equipment reaches a certain threshold value, the memory of the corresponding memory resource groups can be recovered through the dynamically bound target kernel threads, so that the lock competition among the target kernel threads is reduced, the performance problem caused by the lock competition is reduced, the memory bump is reduced, the system smoothness is improved, and the use experience of a user is improved.
The memory recovery device in the embodiment of the present application may be a device, or may be a component, an integrated circuit, or a chip in a terminal. The device can be mobile electronic equipment or non-mobile electronic equipment. By way of example, the mobile electronic device may be a mobile phone, a tablet computer, a notebook computer, a palm top computer, a vehicle-mounted electronic device, a wearable device, an ultra-mobile personal computer (UMPC), a netbook or a Personal Digital Assistant (PDA), and the like, and the non-mobile electronic device may be a server, a Network Attached Storage (NAS), a personal computer (personal computer, PC), a Television (TV), a teller machine or a self-service machine, and the like, and the embodiments of the present application are not limited in particular.
The memory recovery device in the embodiment of the present application may be a device having an operating system. The operating system may be an Android operating system (Android), an iOS operating system, or other possible operating systems, which is not specifically limited in the embodiments of the present application.
The memory recovery device provided in the embodiment of the present application can implement each process implemented by the method embodiments in fig. 1 to fig. 3, and is not described here again to avoid repetition.
Optionally, as shown in fig. 5, an electronic device 500 is further provided in this embodiment of the present application, and includes a processor 501, a memory 502, and a program or an instruction stored in the memory 502 and capable of being executed on the processor 501, where the program or the instruction is executed by the processor 501 to implement each process of the foregoing memory recovery method embodiment, and can achieve the same technical effect, and in order to avoid repetition, details are not repeated here.
It should be noted that the electronic device in the embodiment of the present application includes the mobile electronic device and the non-mobile electronic device described above.
Fig. 6 is a schematic diagram of a hardware structure of an electronic device implementing an embodiment of the present application.
The electronic device 600 includes, but is not limited to: a radio frequency unit 601, a network module 602, an audio output unit 603, an input unit 604, a sensor 605, a display unit 606, a user input unit 607, an interface unit 608, a memory 609, and a processor 6010.
Those skilled in the art will appreciate that the electronic device 600 may further include a power supply (e.g., a battery) for supplying power to various components, and the power supply may be logically connected to the processor 6010 through a power management system, so that the functions of managing charging, discharging, and power consumption are implemented through the power management system. The electronic device structure shown in fig. 6 does not constitute a limitation of the electronic device, and the electronic device may include more or less components than those shown, or combine some components, or arrange different components, and thus, the description is omitted here.
The processor 6010 is configured to establish a plurality of memory resource groups, where each memory resource group corresponds to at least one application program of an electronic device;
the processor 6010 is further configured to, when the used memory of the electronic device reaches a target memory threshold, recycle the memory of the memory resource group through a target kernel thread, where the target kernel thread is a kernel thread used for page recycling.
In the embodiment of the application, the memory resource groups are established according to the application programs on the electronic equipment, and are dynamically bound with the kernel threads for recovering the memory, when the used memory of the electronic equipment reaches a certain threshold value, the memory of the corresponding memory resource groups can be recovered through the dynamically bound target kernel threads, so that the lock competition among the target kernel threads is reduced, the performance problem caused by the lock competition is reduced, the memory bump is reduced, the system smoothness is improved, and the use experience of a user is improved.
Optionally, the establishing a plurality of memory resource groups, where each memory resource group corresponds to at least one application program of the electronic device, includes:
and establishing a corresponding memory resource group for each application program.
Optionally, the processor 6010 is further configured to dynamically bind the plurality of memory resource packets with a plurality of target kernel threads, where the target kernel threads are kernel threads for page recycling, and each target kernel thread is correspondingly bound with at least one memory resource packet;
optionally, the processor 6010 is further configured to bind, with the other CPU cores of the electronic device except the first CPU core, the other target core threads except the first target core thread;
wherein the dominant frequency of the first CPU core is higher than a target frequency threshold.
Optionally, the processor 6010 is further configured to, when the used memory of the electronic device reaches a first target memory threshold, recycle, by using one or more of other target kernel threads except the first target kernel thread, a memory of the memory resource group that corresponds to the dynamic binding;
under the condition that the used memory of the electronic equipment reaches a second target memory threshold value, recycling the memory of the corresponding dynamically bound memory resource group through one or more of all target kernel threads;
wherein the first target memory threshold is less than the second target memory threshold.
Optionally, the processor 6010 is further configured to, when the number of the memory resource packets and/or the number of the target kernel threads are changed, rebind the memory resource packets for each target kernel thread according to the number of the target kernel threads;
and the difference value of the number of the memory resource groups bound by any two target kernel threads after the re-binding is smaller than a target value.
It is to be understood that, in the embodiment of the present application, the input Unit 604 may include a Graphics Processing Unit (GPU) 6041 and a microphone 6042, and the Graphics Processing Unit 6041 processes image data of a still picture or a video obtained by an image capturing apparatus (such as a camera) in a video capturing mode or an image capturing mode. The display unit 606 may include a display panel 6061, and the display panel 6061 may be configured in the form of a liquid crystal display, an organic light emitting diode, or the like. The user input unit 607 includes a touch panel 6071 and other input devices 6072. A touch panel 6071, also referred to as a touch screen. The touch panel 6071 may include two parts of a touch detection device and a touch controller. Other input devices 6072 may include, but are not limited to, a physical keyboard, function keys (e.g., volume control keys, switch keys, etc.), a trackball, a mouse, and a joystick, which are not described in detail herein. The memory 609 may be used to store software programs as well as various data including, but not limited to, application programs and an operating system. Processor 6010 may integrate an application processor that handles primarily the operating system, user interfaces, application programs, etc. and a modem processor that handles primarily wireless communications. It is to be appreciated that the modem processor described above may not be integrated into processor 6010.
The embodiment of the present application further provides a readable storage medium, where a program or an instruction is stored on the readable storage medium, and when the program or the instruction is executed by a processor, the program or the instruction implements each process of the memory recovery method embodiment, and can achieve the same technical effect, and in order to avoid repetition, details are not repeated here.
The processor is the processor in the electronic device described in the above embodiment. The readable storage medium includes a computer readable storage medium, such as a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and so on.
The embodiment of the present application further provides a chip, where the chip includes a processor and a communication interface, the communication interface is coupled to the processor, and the processor is configured to run a program or an instruction, so as to implement each process of the memory recovery method embodiment, and achieve the same technical effect, and in order to avoid repetition, the description is omitted here.
It should be understood that the chips mentioned in the embodiments of the present application may also be referred to as system-on-chip, system-on-chip or system-on-chip, etc.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element. Further, it should be noted that the scope of the methods and apparatus of the embodiments of the present application is not limited to performing the functions in the order illustrated or discussed, but may include performing the functions in a substantially simultaneous manner or in a reverse order based on the functions involved, e.g., the methods described may be performed in an order different than that described, and various steps may be added, omitted, or combined. Additionally, features described with reference to certain examples may be combined in other examples.
Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better implementation manner. Based on such understanding, the technical solutions of the present application may be embodied in the form of a computer software product, which is stored in a storage medium (such as ROM/RAM, magnetic disk, optical disk) and includes instructions for enabling a terminal (such as a mobile phone, a computer, a server, or a network device) to execute the method according to the embodiments of the present application.
While the present embodiments have been described with reference to the accompanying drawings, it is to be understood that the invention is not limited to the precise embodiments described above, which are meant to be illustrative and not restrictive, and that various changes may be made therein by those skilled in the art without departing from the spirit and scope of the invention as defined by the appended claims.

Claims (12)

1. A memory reclamation method, comprising:
establishing a plurality of memory resource groups, wherein each memory resource group corresponds to at least one application program of the electronic equipment;
and under the condition that the used memory of the electronic equipment reaches a target memory threshold value, recovering the memory of the memory resource group through a target kernel thread, wherein the target kernel thread is a kernel thread for page recovery.
2. The method of claim 1, wherein the establishing a plurality of memory resource groups, each memory resource group corresponding to at least one application of an electronic device comprises:
and establishing a corresponding memory resource group for each application program.
3. The method of claim 1, wherein the establishing a plurality of memory resource groups, each memory resource group corresponding to at least one application of an electronic device, further comprises:
dynamically binding the memory resource groups with target kernel threads, wherein each target kernel thread is correspondingly bound with at least one memory resource group;
the recycling, by the target kernel thread, the memory of the memory resource group when the used memory of the electronic device reaches the target memory threshold includes:
and under the condition that the used memory of the electronic equipment reaches a target memory threshold value, recovering the memory of the memory resource group dynamically bound with the target kernel thread through the target kernel thread.
4. The method of claim 3, wherein after dynamically binding the plurality of memory resource groups to a plurality of target kernel threads, further comprising:
binding other target kernel threads except the first target kernel thread with other CPU kernels except the first CPU kernel of the electronic equipment;
wherein the dominant frequency of the first CPU core is higher than a target frequency threshold.
5. The method of claim 4, wherein the reclaiming, by the target kernel thread, the memory of the memory resource group dynamically bound to the target kernel thread if the memory level of the electronic device reaches a target memory threshold comprises:
under the condition that the used memory of the electronic equipment reaches a first target memory threshold value, recycling the memory of the corresponding dynamically bound memory resource group through one or more of other target kernel threads except the first target kernel thread;
under the condition that the used memory of the electronic equipment reaches a second target memory threshold value, recycling the memory of the corresponding dynamically bound memory resource group through one or more of all target kernel threads;
wherein the first target memory threshold is less than the second target memory threshold.
6. The method of claim 3, wherein dynamically binding the plurality of memory resource groups to a plurality of target kernel threads comprises:
under the condition that the number of the memory resource groups and/or the number of the target kernel threads are changed, rebinding the memory resource groups for each target kernel thread according to the number of the target kernel threads;
and the difference value of the number of the memory resource groups bound by any two target kernel threads after the re-binding is smaller than a target value.
7. A memory recycling device, comprising:
the system comprises an establishing module, a processing module and a processing module, wherein the establishing module is used for establishing a plurality of memory resource groups, and each memory resource group corresponds to at least one application program of the electronic equipment;
the recovery module is configured to recover, by a target kernel thread, the memory of the memory resource group when the used memory of the electronic device reaches a target memory threshold, where the target kernel thread is a kernel thread for page recovery.
8. The apparatus of claim 7, wherein the establishing module comprises:
and the establishing unit is used for establishing a corresponding memory resource group for each application program.
9. The apparatus of claim 7, further comprising:
the first binding module is used for dynamically binding the memory resource groups with target kernel threads, wherein the target kernel threads are kernel threads for page recovery, and each target kernel thread is correspondingly bound with at least one memory resource group;
the recovery module includes:
and the recovery unit is used for recovering the memory of the memory resource group dynamically bound with the target kernel thread through the target kernel thread under the condition that the used memory of the electronic equipment reaches a target memory threshold value.
10. The apparatus of claim 9, further comprising:
the second binding module is used for binding other target kernel threads except the first target kernel thread with other CPU kernels except the first CPU kernel of the electronic equipment;
wherein the dominant frequency of the first CPU core is higher than a target frequency threshold.
11. The apparatus of claim 10, wherein the recovery unit comprises:
the first recovery subunit is configured to, when the used memory of the electronic device reaches a first target memory threshold, recover, by using one or more of other target kernel threads except the first target kernel thread, a memory of the memory resource group that corresponds to the dynamic binding;
a second recycling subunit, configured to, when the used memory of the electronic device reaches a second target memory threshold, recycle, through one or more of all target kernel threads, the memory of the memory resource group that corresponds to the dynamic binding;
wherein the first target memory threshold is less than the second target memory threshold.
12. The apparatus of claim 9, wherein the first binding module comprises:
a binding unit, configured to rebind the memory resource packet for each target kernel thread according to the number of target kernel threads when the number of memory resource packets and/or the number of target kernel threads are changed;
and the difference value of the number of the memory resource groups bound by any two target kernel threads after the re-binding is smaller than a target value.
CN202210087228.3A 2022-01-25 2022-01-25 Memory recovery method and device Pending CN114443510A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210087228.3A CN114443510A (en) 2022-01-25 2022-01-25 Memory recovery method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210087228.3A CN114443510A (en) 2022-01-25 2022-01-25 Memory recovery method and device

Publications (1)

Publication Number Publication Date
CN114443510A true CN114443510A (en) 2022-05-06

Family

ID=81370600

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210087228.3A Pending CN114443510A (en) 2022-01-25 2022-01-25 Memory recovery method and device

Country Status (1)

Country Link
CN (1) CN114443510A (en)

Similar Documents

Publication Publication Date Title
US20210311749A1 (en) Resource management with dynamic resource policies
CN111158910B (en) Memory management method and device, storage medium and electronic equipment
EP3514689B1 (en) Memory management method and apparatus
CN103324500B (en) A kind of method and device reclaiming internal memory
KR101799253B1 (en) Systems and methods for providing dynamic cache extension in a multi-cluster heterogeneous processor architecture
CN110764906B (en) Memory recovery processing method and device, electronic equipment and storage medium
CN105701025A (en) Memory recovery method and device
CN110888746A (en) Memory management method and device, storage medium and electronic equipment
CN102027453A (en) System and method for optimizing interrupt processing in virtualized environments
CN111274039B (en) Memory recycling method and device, storage medium and electronic equipment
CN111475299B (en) Memory allocation method and device, storage medium and electronic equipment
CN103257700A (en) Energy saving method and energy saving device for Android system
CN113268438B (en) Memory recycling method and device and electronic equipment
US20130145374A1 (en) Synchronizing java resource access
CN114237381A (en) Application processing method and device
WO2024078494A1 (en) Thread management method and apparatus, electronic device, and storage medium
CN117170872A (en) Memory management method, device, equipment and storage medium
CN114443510A (en) Memory recovery method and device
CN115587049A (en) Memory recovery method and device, electronic equipment and storage medium
CN114968551B (en) Process management method and device, electronic equipment and storage medium
CN111078405A (en) Memory allocation method and device, storage medium and electronic equipment
CN114546171A (en) Data distribution method, data distribution device, storage medium and electronic equipment
CN113032290A (en) Flash memory configuration method and device, electronic equipment and storage medium
CN113225830A (en) Data network uplink scheduling method and device and electronic equipment
CN113037871A (en) Conference call recovery method, device, system, electronic equipment and readable storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination