CN111414254A - Device management method, device, storage medium and electronic device - Google Patents

Device management method, device, storage medium and electronic device Download PDF

Info

Publication number
CN111414254A
CN111414254A CN202010197370.4A CN202010197370A CN111414254A CN 111414254 A CN111414254 A CN 111414254A CN 202010197370 A CN202010197370 A CN 202010197370A CN 111414254 A CN111414254 A CN 111414254A
Authority
CN
China
Prior art keywords
memory
management area
target
management
electronic device
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
CN202010197370.4A
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.)
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 CN202010197370.4A priority Critical patent/CN111414254A/en
Publication of CN111414254A publication Critical patent/CN111414254A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • 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/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4812Task transfer initiation or dispatching by interrupt, e.g. masked
    • 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

Abstract

The application discloses a device management method, a device management apparatus, a storage medium and an electronic device. The equipment management method is applied to electronic equipment and comprises the following steps: acquiring information of the memory size occupied by each process in the electronic equipment in each management area of the memory of the electronic equipment; when the memory recovery process is triggered, determining a target management area, wherein the target management area is a management area for triggering the memory recovery process because the allocable memory is smaller than a preset threshold value; selecting a target process according to a preset strategy, and recycling the memory occupied by the target process by the memory recycling process, wherein the preset strategy is as follows: determining the process with the lowest priority as a target process; and if the number of the processes with the lowest priority is at least two, determining the process occupying the largest memory in the target management area in the processes with the lowest priority as the target process according to the information of the memory size occupied by each process in each management area. The memory management capability of the electronic equipment can be improved.

Description

Device management method, device, storage medium and electronic device
Technical Field
The present application relates to the field of memory technologies, and in particular, to a device management method and apparatus, a storage medium, and an electronic device.
Background
Memory (Memory) is one of the important components in electronic devices, and it is the bridge between external Memory and CPU. All programs in the electronic device are executed in the memory, so the performance of the memory has a great influence on the electronic device. The memory is also called an internal memory and a main memory, and functions to temporarily store operation data in the CPU and data exchanged with an external memory such as a hard disk. As long as the electronic equipment is in operation, the operating system transfers data to be operated to the CPU from the memory for operation, and the CPU transmits the result after the operation is finished, so that the operation of the memory also determines the stable operation of the electronic equipment. However, in the related art, the memory management capability of the electronic device is poor.
Disclosure of Invention
The embodiment of the application provides a device management method and device, a storage medium and an electronic device, which can improve the memory management capability of the electronic device.
In a first aspect, an embodiment of the present application provides an apparatus management method, which is applied to an electronic apparatus, and the method includes:
acquiring information of the memory size occupied by each process in the electronic equipment in each management area of the memory of the electronic equipment;
when a memory recovery process is triggered, determining a target management area, wherein the target management area is a management area for triggering the memory recovery process because the allocable memory is smaller than a preset threshold value;
selecting a target process according to a preset strategy, and recovering the memory occupied by the target process by the memory recovery process, wherein the preset strategy is as follows:
determining the process with the lowest priority as a target process;
and if the number of the processes with the lowest priority is at least two, determining the process occupying the largest memory in the target management area in the processes with the lowest priority as a target process according to the information of the memory size occupied by each process in each management area.
In a second aspect, an embodiment of the present application provides an apparatus for device management, which is applied to an electronic device, and the apparatus includes:
the acquisition module is used for acquiring the information of the memory size occupied by each process in the electronic equipment in each management area of the memory of the electronic equipment;
the memory recovery system comprises a determining module, a judging module and a judging module, wherein the determining module is used for determining a target management area when a memory recovery process is triggered, and the target management area is a management area which triggers the memory recovery process because an allocable memory is smaller than a preset threshold value;
the recovery module is configured to select a target process according to a preset policy, and recover, by the memory recovery process, a memory occupied by the target process, where the preset policy is:
determining the process with the lowest priority as a target process;
and if the number of the processes with the lowest priority is at least two, determining the process occupying the largest memory in the target management area in the processes with the lowest priority as a target process according to the information of the memory size occupied by each process in each management area.
In a third aspect, an embodiment of the present application provides a storage medium, on which a computer program is stored, and when the computer program is executed on a computer, the computer program is enabled to execute the flow in the device management method provided in the embodiment of the present application.
In a fourth aspect, an embodiment of the present application further provides an electronic device, which includes a memory and a processor, where the processor is configured to execute the procedure in the device management method provided in the embodiment of the present application by calling a computer program stored in the memory.
In this embodiment, the electronic device may first obtain information about the size of a memory occupied by each process in each management area of the memory of the electronic device. When the memory recovery process is triggered, the electronic device may determine a target management area for triggering the memory recovery process due to insufficient memory available for allocation. Then, the electronic device may select a target process according to a preset policy, and a memory recovery process recovers a memory occupied by the target process, where the preset policy is: determining the process with the lowest priority as a target process; and if the number of the processes with the lowest priority is at least two, determining the process with the highest memory occupation in the target management area in the processes with the lowest priority as the target process according to the information of the memory occupation size of each process in each management area. Therefore, compared with a mode of recovering the memory only according to the priority and the memory occupation condition in the related art, the memory occupation condition of each process in each management area in the memory can be recorded, and the memory occupied by the process with the largest memory occupation in the target management area in the process with the lowest priority can be recycled, so that the memory management capability of the electronic device can be improved.
Drawings
The technical solutions and advantages of the present application will become apparent from the following detailed description of specific embodiments of the present application when taken in conjunction with the accompanying drawings.
Fig. 1 is a schematic flowchart of a device management method according to an embodiment of the present application.
Fig. 2 is another schematic flow chart of a device management method according to an embodiment of the present application.
Fig. 3 is a schematic flowchart of a device management method according to an embodiment of the present application.
Fig. 4 is a schematic structural diagram of a device management apparatus according to an embodiment of the present application.
Fig. 5 is a schematic structural diagram of an electronic device provided in an embodiment of the present application.
Fig. 6 is another schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
Referring to the drawings, wherein like reference numbers refer to like elements, the principles of the present application are illustrated as being implemented in a suitable computing environment. The following description is based on illustrated embodiments of the application and should not be taken as limiting the application with respect to other embodiments that are not detailed herein.
It is understood that the execution subject of the embodiment of the present application may be an electronic device such as a smart phone or a tablet computer.
Referring to fig. 1, fig. 1 is a schematic flowchart of a device management method according to an embodiment of the present application, where the flowchart may include:
101. the method comprises the steps of obtaining information of the size of a memory occupied by each process in the electronic equipment in each management area of the memory of the electronic equipment.
Memory (Memory) is one of the important components in electronic devices, and it is the bridge between external Memory and CPU. All programs in the electronic device are executed in the memory, so the performance of the memory has a great influence on the electronic device. The memory is also called an internal memory and a main memory, and functions to temporarily store operation data in the CPU and data exchanged with an external memory such as a hard disk. As long as the electronic equipment is in operation, the operating system transfers data to be operated to the CPU from the memory for operation, and the CPU transmits the result after the operation is finished, so that the operation of the memory also determines the stable operation of the electronic equipment.
Taking an electronic device provided with a L inux system as an example, the memory of a L inux system is divided into different management areas (zones) for management at present, the management areas are used for representing a certain range in the memory, when the memory of the system is in shortage, a L owmemorkiller mechanism is called to carry out process killing so as to recycle the memory, and the function of calling L owmemorkiller is to release the memory for distribution by other processes.
For example, the memory of the system is divided into a management zone0 and a management zone1, wherein the memory currently belonging to the management zone0 is in short supply, that is, the memory available for allocation in the management zone0 is insufficient, at this time, the process is killed by L owmemorkiler, and as a result, the memory occupied by the killed process belongs to the management zone1, the released memory cannot meet the current needs of the system, and therefore, the recovered memory is not effectively killed by calling L owmemorkiler to perform process killing.
It should be noted that, some different management areas in the memory have a hierarchical relationship. For example, there are two management zones, zone0 and zone1, in the memory, wherein the management zone1 only allocates movable pages, and the management zone0 is available for all page allocation. Since most of the pages allocated by the application are movable pages, the management zone1 is mainly used for the user space, and the management zone1 is used for both kernel space and user space. The two management zones zone0 and zone1 are in a hierarchical relationship, so that when the memory of the management zone1 is in shortage, the system can allocate the memory of the management zone0 to a needed process, and when the memory of the management zone0 is in shortage, the memory needs to be recycled, and the memory of the management zone1 cannot be allocated to the needed process. The system is arranged in such a way that the memory space needed by the user is very large, which may result in the management zone1 being used up quickly, and at this time, if the management zone0 has memory available for allocation, the memory space of the management zone0 may be used continuously. Most of the kernel space is non-removable memory, so if the memory available for allocation in the management zone0 is not enough, the system cannot use the memory space in the management zone 1.
In this embodiment, for example, the electronic device may first obtain information of a memory size occupied by each process in each management area (zone) of a memory of the electronic device. That is, the electronic device may first obtain the memory usage of each process in each management area.
For example, the memory of the electronic device is divided into a management zone0 and a management zone 1. The electronic device acquires that the process a occupies 10MB of memory in the management zone0 and occupies 20M of memory in the management zone 1. Process B occupies 5MB of memory in the management zone0, 30M of memory in the management zone1, and so on.
102. When the memory recovery process is triggered, a target management area is determined, wherein the target management area is a management area which triggers the memory recovery process because the allocable memory is smaller than a preset threshold value.
For example, when the electronic device calls the memory reclamation process L owMemoryKiller because the allocated memory in a certain management area in the memory is smaller than the preset threshold, the electronic device may determine the target management area, where the target management area is a management area that triggers the electronic device to call the memory reclamation process L owMemoryKiller because the allocated memory in the target management area is smaller than the preset threshold.
For example, because insufficient memory is available for allocation in the management zone0 to cause the system call L owMemoryKiller process, the electronic device may determine the management zone0 as the target management zone.
It should be noted that when the memory reclamation process L owmemorrykiller is triggered, the system indicates which management area is triggered due to the shortage of memory, so that the electronic device can directly read the corresponding information in the system to determine the target management area.
103. Selecting a target process according to a preset strategy, and recycling the memory occupied by the target process by a memory recycling process, wherein the preset strategy is as follows: determining the process with the lowest priority as a target process; and if the number of the processes with the lowest priority is at least two, determining the process with the highest memory occupation in the target management area in the processes with the lowest priority as the target process according to the information of the memory occupation size of each process in each management area.
For example, after the target management area is determined, the electronic device may select a target process according to a preset policy, and the memory recovery process L owMemoryKiller recovers the memory occupied by the target process, where the preset policy may be to determine a process with the lowest priority as the target process, and if there are at least two processes with the lowest priority, determine a process with the largest memory occupied by the target management area in the processes with the lowest priority as the target process according to the information of the memory size occupied by each process in each management area acquired in the process 101.
For example, if the number of the processes with the lowest priority is at least two, the electronic device may determine the process with the largest memory occupied in the target management zone0 among the processes with the lowest priority as the target process.
It can be understood that, in the embodiment of the present application, the memory corresponding to the process currently occupying the target management area with insufficient allocable memory can be recovered, so as to release the memory of the target management area required by the system, and therefore, the embodiment of the present application can improve the effectiveness of memory recovery and improve the memory management capability of the system.
In this embodiment, the electronic device may first obtain information about the size of a memory occupied by each process in each management area of the memory of the electronic device. When the memory recovery process is triggered, the electronic device may determine a target management area for triggering the memory recovery process due to insufficient memory available for allocation. Then, the electronic device may select a target process according to a preset policy, and a memory recovery process recovers a memory occupied by the target process, where the preset policy is: determining the process with the lowest priority as a target process; and if the number of the processes with the lowest priority is at least two, determining the process with the highest memory occupation in the target management area in the processes with the lowest priority as the target process according to the information of the memory occupation size of each process in each management area. Therefore, compared with a mode of recovering the memory only according to the priority and the memory occupation condition in the related art, the memory occupation condition of each process in each management area in the memory can be recorded, and the memory occupied by the process with the largest memory occupation in the target management area in the process with the lowest priority can be recycled, so that the memory management capability of the electronic device can be improved.
Referring to fig. 2, fig. 2 is another schematic flow chart of a device management method according to an embodiment of the present disclosure. The device management method can be applied to electronic equipment, and the electronic equipment can configure corresponding Adj values for each process, wherein the higher the Adj value corresponding to the process is, the lower the priority of the process is. The flow of the device management method may include:
201. when a page is allocated to a process or released in a memory of an electronic device, the electronic device records information of a management area to which the page allocated to the process or the released page belongs.
202. And according to the recorded information of the management areas to which the pages distributed for the processes or the released pages belong, the electronic equipment determines the size of the memory occupied by the processes in each management area of the memory.
For example, 201 and 202 may include:
when the electronic device allocates a page to a process or releases a page in the memory of the electronic device, the electronic device may record information of a management zone to which the page allocated to the process or the released page belongs, and determine a memory size occupied by the process in each management zone of the memory according to the recorded information of the management zone to which the page allocated to the process or the released page belongs.
That is, each time a process is allocated pages in memory, the electronic device may record which pages of which management areas are allocated to the process. Whenever a page is released for a process in memory, the electronic device may record which pages of which management areas are released. Then, the electronic device may determine, according to the recorded information, the size of the memory occupied by each process in each management area of the memory.
For example, the memory of the electronic device is divided into a management zone0, a management zone1, and a management zone 2. When the system allocates a page for process a for the first time, 5MB of memory belonging to the management zone1 is allocated to process a. Then the electronic device may record that process a is allocated 5MB of memory space for the management zone 1. When the system allocates a page for process a for the second time, 10MB of memory belonging to the management zone2 is allocated to process a. Then, the electronic device may record that a memory space of 10MB size of the management zone2 is allocated to the process a, and update the memory information corresponding to the process a to a memory space of 5MB size in the zone1 and a memory space of 10MB size in the zone 2.
When the system frees up a page for process a, for example, memory space of 5MB size that belongs to the management zone2 is freed up. Then the electronic device may record that the 5MB size memory space of process a in the management zone2 is freed. The electronic device may update the memory information corresponding to process a to have a memory space of 5MB in zone1 and a memory space of 5MB in zone 2.
For another example, when the system allocates a page to process B for the first time, process B is allocated 10MB of memory belonging to the management zone 0. Then the electronic device may record that process B is allocated memory space of 10MB size for the management zone 0. Furthermore, the electronic device may record the memory information corresponding to the process B as a memory space of 10MB size in the zone 0. When the system frees up a page for process B, for example, memory space of 5MB size that belongs to the management zone0 is freed up. Then the electronic device may record that the 5MB size memory space of process B in the management zone0 is freed. And, the electronic device may update the memory information corresponding to the process B to have a memory space of 5MB in the zone0, and so on.
It can be understood that, through the processes 201 and 202, the electronic device can record information of the memory size occupied by each process in each management area of the memory.
203. The electronic equipment acquires the information of the memory size occupied by each process in each management area of the memory.
For example, the electronic device may obtain, according to a preset time interval, information of a memory size occupied by each process in each management area of the memory, where the information is recorded.
204. When the memory recovery process is triggered, the electronic device determines a target management area, wherein the target management area is a management area for triggering the memory recovery process because the allocable memory is smaller than a preset threshold value.
For example, when the electronic device calls the memory reclamation process L owMemoryKiller because the allocated memory in a certain management area in the memory is smaller than the preset threshold, the electronic device may determine the target management area, where the target management area is a management area that triggers the electronic device to call the memory reclamation process L owMemoryKiller because the allocated memory in the target management area is smaller than the preset threshold.
For example, because insufficient memory is available for allocation in the management zone0 to cause the system call L owMemoryKiller process, the electronic device may determine the management zone0 as the target management zone.
205. The electronic equipment selects a target process according to a preset strategy, and a memory recovery process recovers a memory occupied by the target process, wherein the preset strategy is as follows: determining the process with the maximum Adj value as a target process; and if the number of the processes with the maximum Adj value is at least two, determining the process with the maximum Adj value occupying the maximum memory in the target management area as the target process according to the information of the memory size occupied by each process in each management area.
For example, after the target management area is determined, the electronic device may select a target process according to a preset policy, and the memory occupied by the target process is recovered by the memory recovery process L owMemoryKiller, where the preset policy may be to determine the process with the largest Adj value as the target process, and if there are at least two processes with the largest Adj value, determine the process with the largest memory occupied by the target management area in the processes with the largest Adj value as the target process according to the information of the memory size occupied by each process in each management area, which is acquired in the process 203.
For example, the electronic device may obtain and compare Adj values of all current processes after determining zone0 as a target management area, and determine a process with the largest Adj value as a target process, where the Adj value of process C is greater than the Adj values of all other processes, that is, the Adj value of process C is the largest, then the priority or importance of process C may be considered to be the lowest, and therefore, the electronic device may determine process C as the target process, and reclaim the memory occupied by process C by L owmemorkiller.
For example, the electronic device may determine, according to the information about the memory size occupied by each process in each management area obtained in the flow 203, a process with the largest memory occupied by the target management area in the five processes C, D, E, F, G as the target process, where, for example, the memory occupied by the process C, D, E, F, G in the management area zone0 is 5MB, 10MB, 12MB, 5MB, and 15 MB. respectively, and since the memory occupied by the process G in the management area zone 7 is greater than the memory occupied by the process 355631 in the management area zone0, the electronic device may determine the process G as the target process, and recover the memory occupied by the process G by L owmorkiler.
In one embodiment, the memory size occupied by each page in the memory of the electronic device is equal.
Then, when the electronic device executes 201 and when a page is allocated or released for a process in a memory of the electronic device, and records information of a management area to which the page allocated or released for the process belongs, the following steps may be performed: when pages are allocated or released for a process in a memory of the electronic equipment, the number of the pages allocated or released for the process in each management area is recorded.
When determining the memory size occupied by the process in each management area of the memory according to the recorded information of the management area to which the page allocated for the process or the released page belongs in the electronic device execution 202, the following steps may be performed: and according to the recorded number of the pages distributed or released for the process in each management area and the information of the memory size occupied by each page, the electronic equipment determines the memory size occupied by the process in each management area of the memory.
For example, the memory size occupied by each page in the memory is 5 KB. Then, when allocating a page to a process or releasing a page from the memory of the electronic device, the electronic device may record which management areas in the memory allocate how many pages to the process or release how many pages to the process. Based on this, the electronic device may determine the memory size occupied by each process in each management area of the memory according to the recorded number of pages allocated or released by the process in each management area and the memory size occupied by each page.
For example, the memory of the electronic device is divided into a management zone0, a management zone1, and a management zone 2. The first time the system allocates pages for process a, 1024 pages belonging to the management zone1 are allocated to process a. Then, the electronic apparatus may record information that 1024 pages belonging to the management zone1 are allocated to the process a. When the system allocates pages for process a the second time, 2048 pages belonging to the management zone2 are allocated to process a. Then the electronic device may record that 2048 pages belonging to the management zone2 are allocated for process a. Since each page is 5KB in size, the electronic device may count that the memory information corresponding to process a is 5MB in memory space in zone1 and 10MB in memory space in zone 2.
When the system frees pages for process a, for example, 1024 pages belonging to the management zone2 are freed. Then, the electronic device may record that 1024 pages of process a in the management zone2 are released, that is, the electronic device releases 5MB of memory space of process a in the management zone 2. The electronic device may update the memory information corresponding to process a to have a memory space of 5MB in zone1 and a memory space of 5MB in zone 2.
For another example, when the system allocates a page to process B for the first time, 2048 pages belonging to the management zone0 are allocated to process B. Then, the electronic device may record that process B is allocated 2048 pages belonging to the management zone 0. The electronic device may record the memory information corresponding to process B as having a memory space of 10MB size in zone 0. When the system frees pages for process B, for example, 1024 pages belonging to the management zone0 are freed. Then the electronic device may record that 1024 pages of process B in the management zone0 were released. And, the electronic device may update the memory information corresponding to the process B to have a memory space of 5MB in the zone0, and so on.
In another implementation, this embodiment may further include the following process:
the electronic equipment generates a corresponding relation table, wherein the corresponding relation table comprises corresponding relations of all processes and memory sizes occupied by all the processes in all management areas of the memory.
Then, when the electronic device executes 203 to obtain the information of the memory size occupied by each process in each management area of the memory, it may execute: and acquiring the information of the memory size occupied by each process in the electronic equipment in each management area of the memory according to the corresponding relation table.
For example, the memory information corresponding to the process a is a memory space having a size of 5MB in the zone1, and a memory space having a size of 5MB in the zone 2. If the memory information corresponding to the process B is a memory space with a size of 5MB in the zone0, the correspondence table may be in the following form:
zone0 zone1 zone2
process A 0MB 5MB 5MB
Process B 5MB 0MB 0MB
When the information of the memory size occupied by each process in the electronic equipment in each management area of the memory needs to be acquired, the electronic equipment can quickly acquire the required information by inquiring the corresponding relation table.
Referring to fig. 3, fig. 3 is a schematic flowchart illustrating a device management method according to an embodiment of the present disclosure.
For example, the operating system of the electronic device is an Android (Android) system. The electronic device may configure a corresponding Adj value for each process, where a larger Adj value for a process indicates a lower priority or importance of the process.
The memory of the electronic device may be divided into a plurality of management zones. Each management area may be used to represent a certain range in memory.
Whenever a process is allocated pages in the memory of an electronic device, the electronic device may record which pages of which management areas are allocated to the process. Whenever a page is released for a process in memory, the electronic device may record which pages of which management areas are released. Then, the electronic device may determine, according to the recorded information, the size of the memory occupied by each process in each management area of the memory. For example, the electronic device may create a correspondence table, where the correspondence table may include correspondence between processes and sizes of memories occupied by the processes in management areas of the memories. The electronic device can dynamically update the corresponding relation table according to the operation that the system allocates pages for each process or releases pages in real time. For example, the form of the correspondence table may be as follows:
zone0 zone1 zone2
process A 0MB 5MB 5MB
Process B 5MB 0MB 0MB
Process C 3MB 12MB 7MB
It can be understood that, in this embodiment, it is assumed that the electronic device currently has 3 processes, and the memory is divided into 3 management areas, which are zone0, zone1, and zone2, respectively. Of course, in other embodiments, the number of processes in the electronic device and the number of management areas in the memory may be more than 3, which is not specifically limited in this embodiment of the present application.
For example, the system may call L owmemorkiller process to reclaim memory when triggering the system call L owmemorkiller process, the zone electronic device may determine the management zone0 as the target management zone because the system call L owmemorkiller process was initiated because of insufficient memory in the management zone 0.
After determining the target management area, the electronic device may traverse each current process and obtain Adj values of the processes. In the traversing process, the electronic device may determine a process with the largest Adj value among the processes traversed currently as a target process, and if the Adj values of a plurality of processes are parallel to the largest, the electronic device may determine a process with the largest Adj value, which occupies the largest memory in the target management zone0, among the processes with the largest Adj values as the target process until the electronic device completes all the processes.
For example, after traversing all the processes, the process with the maximum Adj value has only one process, and the electronic device may determine the process with the maximum Adj value as the target process, and reclaim the memory of the target process by the L owmemorykiler process, so as to allocate the reclaimed memory to the process D for use.
For example, because the memory occupied by the process B in the target management zone0 is large, the electronic device may determine the process B as the target process, and recover the memory of the target process B by the L owmemorkiler process, so as to use the recovered memory for allocating to the process D.
Referring to fig. 4, fig. 4 is a schematic structural diagram of a device management apparatus according to an embodiment of the present disclosure. The device management apparatus may be applied to an electronic device, and the device management apparatus 300 may include: the system comprises an acquisition module 301, a determination module 302 and a recovery module 303.
An obtaining module 301, configured to obtain information of memory sizes occupied by processes in the electronic device in management areas of a memory of the electronic device;
a determining module 302, configured to determine a target management area when a memory reclamation process is triggered, where the target management area is a management area where the memory reclamation process is triggered because an allocable memory is smaller than a preset threshold;
a recycling module 303, configured to select a target process according to a preset policy, and recycle, by the memory recycling process, a memory occupied by the target process, where the preset policy is:
determining the process with the lowest priority as a target process;
and if the number of the processes with the lowest priority is at least two, determining the process occupying the largest memory in the target management area in the processes with the lowest priority as a target process according to the information of the memory size occupied by each process in each management area.
In one embodiment, the obtaining module 301 may further be configured to:
when a page is allocated to a process or released in a memory of the electronic equipment, recording information of a management area to which the page allocated to the process or the released page belongs;
and determining the size of the memory occupied by the process in each management area of the memory according to the recorded information of the management area to which the page distributed for the process or the released page belongs.
In one embodiment, the electronic device configures corresponding Adj values for each process, wherein the larger the Adj value corresponding to a process is, the lower the priority of the process is;
the preset strategy is as follows:
determining the process with the maximum Adj value as a target process;
and if the number of the processes with the maximum Adj value is at least two, determining the process with the maximum memory occupied in the target management area in the processes with the maximum Adj value as a target process according to the information of the memory size occupied by each process in each management area.
In one embodiment, the memory occupied by each page in the memory of the electronic device is equal in size;
the obtaining module 301 may be configured to:
when pages are allocated or released for the processes in the memory of the electronic equipment, recording the number of the pages allocated or released for the processes in each management area;
and determining the memory size occupied by the process in each management area of the memory according to the recorded number of the pages distributed or released for the process in each management area and the information of the memory size occupied by each page.
In one embodiment, the obtaining module 301 may further include:
generating a corresponding relation table, wherein the corresponding relation table comprises corresponding relations of all processes and the memory size occupied by all the processes in all the management areas of the memory;
and acquiring the information of the memory size occupied by each process in the electronic equipment in each management area of the memory of the electronic equipment according to the corresponding relation table.
The present application provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed on a computer, the computer is caused to execute the procedures in the method provided by the present embodiment.
The embodiment of the present application further provides an electronic device, which includes a memory and a processor, where the processor is configured to execute the flow in the device management method provided in this embodiment by calling the computer program stored in the memory.
For example, the electronic device may be a mobile terminal such as a tablet computer or a smart phone. Referring to fig. 5, fig. 5 is a schematic structural diagram of an electronic device according to an embodiment of the present disclosure.
The electronic device 400 may include components such as a display 401, memory 402, processor 403, and the like. Those skilled in the art will appreciate that the electronic device configuration shown in fig. 5 does not constitute a limitation of the electronic device and may include more or fewer components than those shown, or some components may be combined, or a different arrangement of components.
The display 401 may be used to display information such as text, images, and the like.
The memory 402 may be used to store applications and data. The memory 402 stores applications containing executable code. The application programs may constitute various functional modules. The processor 403 executes various functional applications and data processing by running an application program stored in the memory 402.
The processor 403 is a control center of the electronic device, connects various parts of the whole electronic device by using various interfaces and lines, and performs various functions of the electronic device and processes data by running or executing an application program stored in the memory 402 and calling data stored in the memory 402, thereby performing overall monitoring of the electronic device.
In this embodiment, the processor 403 in the electronic device loads the executable code corresponding to the processes of one or more application programs into the memory 402 according to the following instructions, and the processor 403 runs the application programs stored in the memory 402, so as to execute:
acquiring information of the memory size occupied by each process in the electronic equipment in each management area of the memory of the electronic equipment;
when a memory recovery process is triggered, determining a target management area, wherein the target management area is a management area for triggering the memory recovery process because the allocable memory is smaller than a preset threshold value;
selecting a target process according to a preset strategy, and recovering the memory occupied by the target process by the memory recovery process, wherein the preset strategy is as follows:
determining the process with the lowest priority as a target process;
and if the number of the processes with the lowest priority is at least two, determining the process occupying the largest memory in the target management area in the processes with the lowest priority as a target process according to the information of the memory size occupied by each process in each management area.
Referring to fig. 6, the electronic device 400 may include a display 401, a memory 402, a processor 403, an input unit 404, an output unit 405, a speaker 406, and the like.
The display 401 may be used to display information such as text, images, and the like.
The memory 402 may be used to store applications and data. The memory 402 stores applications containing executable code. The application programs may constitute various functional modules. The processor 403 executes various functional applications and data processing by running an application program stored in the memory 402.
The processor 403 is a control center of the electronic device, connects various parts of the whole electronic device by using various interfaces and lines, and performs various functions of the electronic device and processes data by running or executing an application program stored in the memory 402 and calling data stored in the memory 402, thereby performing overall monitoring of the electronic device.
The input unit 404 may be used to receive input numbers, character information, or user characteristic information, such as a fingerprint, and generate keyboard, mouse, joystick, optical, or trackball signal inputs related to user settings and function control.
The output unit 405 may be used to display information input by or provided to a user and various graphical user interfaces of the electronic device, which may be made up of graphics, text, icons, video, and any combination thereof.
The speaker 406 may be used to play sound signals.
Furthermore, the electronic device may also include components such as a battery, a microphone, and the like. The battery is used to supply power to the various modules of the electronic device and the microphone may be used to pick up sound signals in the surrounding environment.
In this embodiment, the processor 403 in the electronic device loads the executable code corresponding to the processes of one or more application programs into the memory 402 according to the following instructions, and the processor 403 runs the application programs stored in the memory 402, so as to execute:
acquiring information of the memory size occupied by each process in the electronic equipment in each management area of the memory of the electronic equipment;
when a memory recovery process is triggered, determining a target management area, wherein the target management area is a management area for triggering the memory recovery process because the allocable memory is smaller than a preset threshold value;
selecting a target process according to a preset strategy, and recovering the memory occupied by the target process by the memory recovery process, wherein the preset strategy is as follows:
determining the process with the lowest priority as a target process;
and if the number of the processes with the lowest priority is at least two, determining the process occupying the largest memory in the target management area in the processes with the lowest priority as a target process according to the information of the memory size occupied by each process in each management area.
In one embodiment, the processor 403 may further perform: when a page is allocated to a process or released in a memory of the electronic equipment, recording information of a management area to which the page allocated to the process or the released page belongs; and determining the size of the memory occupied by the process in each management area of the memory according to the recorded information of the management area to which the page distributed for the process or the released page belongs.
In one embodiment, the electronic device configures corresponding Adj values for each process, wherein the larger the Adj value corresponding to a process is, the lower the priority of the process is;
the preset strategy is as follows:
determining the process with the maximum Adj value as a target process;
and if the number of the processes with the maximum Adj value is at least two, determining the process with the maximum memory occupied in the target management area in the processes with the maximum Adj value as a target process according to the information of the memory size occupied by each process in each management area.
In one embodiment, the memory occupied by each page in the memory of the electronic device is equal in size.
Then, the processor 403 may execute, when recording the information of the management area to which the page allocated to the process or the released page belongs when the page is allocated to the process or the page is released in the memory of the electronic device, the following steps: when pages are allocated or released for the processes in the memory of the electronic equipment, recording the number of the pages allocated or released for the processes in each management area.
The processor 403 executes the following steps when determining the memory size occupied by the process in each management area of the memory according to the recorded information of the management area to which the page allocated to the process or the released page belongs: and determining the memory size occupied by the process in each management area of the memory according to the recorded number of the pages distributed or released for the process in each management area and the information of the memory size occupied by each page.
In one embodiment, processor 403 may further perform: and generating a corresponding relation table, wherein the corresponding relation table comprises corresponding relations of all processes and the memory size occupied by all the processes in all the management areas of the memory.
Then, when the processor 403 executes the process of obtaining the information of the memory size occupied by each process in the electronic device in each management area of the memory of the electronic device, it may execute: and acquiring the information of the memory size occupied by each process in the electronic equipment in each management area of the memory of the electronic equipment according to the corresponding relation table.
In the above embodiments, the descriptions of the embodiments have respective emphasis, and parts that are not described in detail in a certain embodiment may refer to the above detailed description of the device management method, and are not described herein again.
The device management apparatus provided in the embodiment of the present application and the device management method in the above embodiment belong to the same concept, and any method provided in the embodiment of the device management method may be run on the device management apparatus, and a specific implementation process thereof is described in detail in the embodiment of the device management method, and is not described herein again.
It should be noted that, for the device management method described in the embodiment of the present application, it can be understood by those skilled in the art that all or part of the process of implementing the device management method described in the embodiment of the present application can be completed by controlling the relevant hardware through a computer program, where the computer program can be stored in a computer-readable storage medium, such as a memory, and executed by at least one processor, and during the execution, the process of the embodiment of the device management method can be included. The storage medium may be a magnetic disk, an optical disk, a Read Only Memory (ROM), a Random Access Memory (RAM), or the like.
In the device management apparatus according to the embodiment of the present application, each functional module may be integrated into one processing chip, or each module may exist alone physically, or two or more modules are integrated into one module. The integrated module can be realized in a hardware mode, and can also be realized in a software functional module mode. The integrated module, if implemented in the form of a software functional module and sold or used as a stand-alone product, may also be stored in a computer readable storage medium, such as a read-only memory, a magnetic or optical disk, or the like.
The above detailed description is provided for a device management method, apparatus, storage medium, and electronic device provided in the embodiments of the present application, and specific examples are applied herein to explain the principles and implementations of the present application, and the descriptions of the above embodiments are only used to help understand the method and core ideas of the present application; meanwhile, for those skilled in the art, according to the idea of the present application, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present application.

Claims (10)

1. A device management method applied to an electronic device is characterized by comprising the following steps:
acquiring information of the memory size occupied by each process in the electronic equipment in each management area of the memory of the electronic equipment;
when a memory recovery process is triggered, determining a target management area, wherein the target management area is a management area for triggering the memory recovery process because the allocable memory is smaller than a preset threshold value;
selecting a target process according to a preset strategy, and recovering the memory occupied by the target process by the memory recovery process, wherein the preset strategy is as follows:
determining the process with the lowest priority as a target process;
and if the number of the processes with the lowest priority is at least two, determining the process occupying the largest memory in the target management area in the processes with the lowest priority as a target process according to the information of the memory size occupied by each process in each management area.
2. The device management method according to claim 1, wherein the method further comprises:
when a page is allocated to a process or released in a memory of the electronic equipment, recording information of a management area to which the page allocated to the process or the released page belongs;
and determining the size of the memory occupied by the process in each management area of the memory according to the recorded information of the management area to which the page distributed for the process or the released page belongs.
3. The device management method according to claim 1, wherein the electronic device configures corresponding Adj values for the processes, wherein a larger Adj value for a process indicates a lower priority for the process;
the preset strategy is as follows:
determining the process with the maximum Adj value as a target process;
and if the number of the processes with the maximum Adj value is at least two, determining the process with the maximum memory occupied in the target management area in the processes with the maximum Adj value as a target process according to the information of the memory size occupied by each process in each management area.
4. The device management method according to claim 2, wherein the size of the memory occupied by each page in the memory of the electronic device is equal;
when a page is allocated to a process or a page is released in the memory of the electronic device, the recording information of the management area to which the page allocated to the process or the page released from the process belongs includes: when pages are allocated or released for the processes in the memory of the electronic equipment, recording the number of the pages allocated or released for the processes in each management area;
the determining, according to the recorded information of the management area to which the page allocated to the process or the released page belongs, the size of the memory occupied by the process in each management area of the memory includes: and determining the memory size occupied by the process in each management area of the memory according to the recorded number of the pages distributed or released for the process in each management area and the information of the memory size occupied by each page.
5. The device management method of claim 4, wherein the method further comprises:
generating a corresponding relation table, wherein the corresponding relation table comprises corresponding relations of all processes and the memory size occupied by all the processes in all the management areas of the memory;
the obtaining of the information of the memory size occupied by each process in the electronic device in each management area of the memory of the electronic device includes: and acquiring the information of the memory size occupied by each process in the electronic equipment in each management area of the memory of the electronic equipment according to the corresponding relation table.
6. An apparatus for managing devices, applied to an electronic device, the apparatus comprising:
the acquisition module is used for acquiring the information of the memory size occupied by each process in the electronic equipment in each management area of the memory of the electronic equipment;
the memory recovery system comprises a determining module, a judging module and a judging module, wherein the determining module is used for determining a target management area when a memory recovery process is triggered, and the target management area is a management area which triggers the memory recovery process because an allocable memory is smaller than a preset threshold value;
the recovery module is configured to select a target process according to a preset policy, and recover, by the memory recovery process, a memory occupied by the target process, where the preset policy is:
determining the process with the lowest priority as a target process;
and if the number of the processes with the lowest priority is at least two, determining the process occupying the largest memory in the target management area in the processes with the lowest priority as a target process according to the information of the memory size occupied by each process in each management area.
7. The device management apparatus of claim 6, wherein the obtaining module is further configured to:
when a page is allocated to a process or released in a memory of the electronic equipment, recording information of a management area to which the page allocated to the process or the released page belongs;
and determining the size of the memory occupied by the process in each management area of the memory according to the recorded information of the management area to which the page distributed for the process or the released page belongs.
8. The device management apparatus according to claim 6, wherein the electronic device configures corresponding Adj values for the processes, wherein a larger Adj value for a process indicates a lower priority for the process;
the preset strategy is as follows:
determining the process with the maximum Adj value as a target process;
and if the number of the processes with the maximum Adj value is at least two, determining the process with the maximum memory occupied in the target management area in the processes with the maximum Adj value as a target process according to the information of the memory size occupied by each process in each management area.
9. A computer-readable storage medium, on which a computer program is stored, which, when executed on a computer, causes the computer to carry out the method according to any one of claims 1 to 5.
10. An electronic device comprising a memory, a processor, wherein the processor executes the method of any one of claims 1 to 5 by invoking a computer program stored in the memory.
CN202010197370.4A 2020-03-19 2020-03-19 Device management method, device, storage medium and electronic device Pending CN111414254A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010197370.4A CN111414254A (en) 2020-03-19 2020-03-19 Device management method, device, storage medium and electronic device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010197370.4A CN111414254A (en) 2020-03-19 2020-03-19 Device management method, device, storage medium and electronic device

Publications (1)

Publication Number Publication Date
CN111414254A true CN111414254A (en) 2020-07-14

Family

ID=71494426

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010197370.4A Pending CN111414254A (en) 2020-03-19 2020-03-19 Device management method, device, storage medium and electronic device

Country Status (1)

Country Link
CN (1) CN111414254A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111858057A (en) * 2020-07-24 2020-10-30 Oppo(重庆)智能科技有限公司 Distribution method and device of running memory, computer equipment and storage medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103365784A (en) * 2013-06-27 2013-10-23 华为技术有限公司 Method and device for memory recycle and allocation
CN107688497A (en) * 2017-07-25 2018-02-13 努比亚技术有限公司 A kind of internal memory regulation and control method, equipment and computer-readable recording medium
CN108073458A (en) * 2017-12-28 2018-05-25 努比亚技术有限公司 Method for recovering internal storage, mobile terminal and computer readable storage medium
CN108132842A (en) * 2017-12-15 2018-06-08 天津津航计算技术研究所 A kind of embedded software internal storage management system
CN109144718A (en) * 2018-07-06 2019-01-04 北京比特大陆科技有限公司 A kind of memory allocation method, memory release method and relevant device
CN110221921A (en) * 2019-06-13 2019-09-10 深圳Tcl新技术有限公司 EMS memory management process, terminal and computer readable storage medium

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103365784A (en) * 2013-06-27 2013-10-23 华为技术有限公司 Method and device for memory recycle and allocation
CN107688497A (en) * 2017-07-25 2018-02-13 努比亚技术有限公司 A kind of internal memory regulation and control method, equipment and computer-readable recording medium
CN108132842A (en) * 2017-12-15 2018-06-08 天津津航计算技术研究所 A kind of embedded software internal storage management system
CN108073458A (en) * 2017-12-28 2018-05-25 努比亚技术有限公司 Method for recovering internal storage, mobile terminal and computer readable storage medium
CN109144718A (en) * 2018-07-06 2019-01-04 北京比特大陆科技有限公司 A kind of memory allocation method, memory release method and relevant device
CN110221921A (en) * 2019-06-13 2019-09-10 深圳Tcl新技术有限公司 EMS memory management process, terminal and computer readable storage medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111858057A (en) * 2020-07-24 2020-10-30 Oppo(重庆)智能科技有限公司 Distribution method and device of running memory, computer equipment and storage medium
CN111858057B (en) * 2020-07-24 2022-04-15 Oppo(重庆)智能科技有限公司 Distribution method and device of running memory, computer equipment and storage medium

Similar Documents

Publication Publication Date Title
US11531625B2 (en) Memory management method and apparatus
CN110888746B (en) Memory management method and device, storage medium and electronic equipment
EP3388946B1 (en) Memory collection method and device
CN111352861B (en) Memory compression method and device and electronic equipment
CN111078406B (en) Memory management method and device, storage medium and electronic equipment
CN110096336B (en) Data monitoring method, device, equipment and medium
US20220221998A1 (en) Memory management method, electronic device and non-transitory computer-readable medium
CN111158910B (en) Memory management method and device, storage medium and electronic equipment
CN111078586B (en) Memory recovery method and device, storage medium and electronic equipment
CN110764906B (en) Memory recovery processing method and device, electronic equipment and storage medium
CN108205473B (en) Memory processing method and device, computer device and computer readable storage medium
CN108205498B (en) Memory recovery method and device, computer device and computer readable storage medium
CN110895492B (en) Device control method, device, storage medium and electronic device
CN111274039B (en) Memory recycling method and device, storage medium and electronic equipment
CN108228449B (en) Terminal device control method and device, terminal device and computer readable storage medium
US20190155641A1 (en) Method and apparatus for collecting information, and method and apparatus for releasing memory
US20190370009A1 (en) Intelligent swap for fatigable storage mediums
CN111966492A (en) Memory recovery method and device, electronic equipment and computer readable storage medium
CN108205501B (en) Memory recovery method and device, computer device and computer readable storage medium
CN108228339B (en) Memory recovery method and device, terminal equipment and computer readable storage medium
CN115421909A (en) Memory management method and device, electronic equipment and storage medium
CN111831411A (en) Task processing method and device, storage medium and electronic equipment
CN111414254A (en) Device management method, device, storage medium and electronic device
WO2021147330A1 (en) Memory swapping method and apparatus
CN111522659B (en) Space use method and device

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