CN113626203A - Memory environment real-time optimization method and system for android system - Google Patents

Memory environment real-time optimization method and system for android system Download PDF

Info

Publication number
CN113626203A
CN113626203A CN202110995021.1A CN202110995021A CN113626203A CN 113626203 A CN113626203 A CN 113626203A CN 202110995021 A CN202110995021 A CN 202110995021A CN 113626203 A CN113626203 A CN 113626203A
Authority
CN
China
Prior art keywords
memory
optimization
recovery
threshold value
environment
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.)
Granted
Application number
CN202110995021.1A
Other languages
Chinese (zh)
Other versions
CN113626203B (en
Inventor
叶戈
许华
吴开钢
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guangdong Unionman Technology Co Ltd
Original Assignee
Guangdong Unionman Technology 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 Guangdong Unionman Technology Co Ltd filed Critical Guangdong Unionman Technology Co Ltd
Priority to CN202110995021.1A priority Critical patent/CN113626203B/en
Publication of CN113626203A publication Critical patent/CN113626203A/en
Application granted granted Critical
Publication of CN113626203B publication Critical patent/CN113626203B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • 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
    • G06F9/5038Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals considering the execution order of a plurality of tasks, e.g. taking priority or time dependency constraints into consideration
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/50Indexing scheme relating to G06F9/50
    • G06F2209/5021Priority
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Telephone Function (AREA)
  • Stored Programmes (AREA)

Abstract

The embodiment of the invention provides a memory environment real-time optimization method and system for an android system. The method comprises the following steps: obtaining system memory information; judging whether the system meets the optimization condition according to the memory environment optimization condition content and the memory information, and if so, optimizing the memory environment of the system according to a recovery strategy corresponding to the optimization condition; the optimization condition content comprises the following steps: optimizing conditions, memory recycling levels and priorities of the optimizing conditions, wherein the optimizing conditions comprise: the method comprises the steps of (1) a memory occupancy rate threshold value, a residual memory size threshold value, a background quantity, an important process list, an important process quantity threshold value, a memory residual rate threshold value, a CPU occupancy rate threshold value and an individual process occupied memory threshold value; the memory recovery levels correspond to the recovery strategies one by one. The method can provide richer memory environment optimization conditions, so that a user can conveniently set different memory environment optimization conditions according to requirements, and the important process list is favorable for protecting necessary services or the background of the system.

Description

Memory environment real-time optimization method and system for android system
Technical Field
The invention relates to the technical field of computer control, in particular to a real-time optimization method and a real-time optimization system for a memory environment of an android system.
Background
The existing android systems have a memory recovery mechanism, which specifically comprises memory recovery and kernel-level recovery. When the device is in use, the upper layer application occupies the memory resource of the device, and when a plurality of applications are opened and not closed or closed and the resources are not released in time, the memory can be more and more occupied. On the other hand, a phenomenon generally exists in the current application market: the application becomes more and more huge, the functions are more and more, the occupied resources are more and more, the application itself does not have a starting point for saving resources, the management of the resources is not emphasized, the user operation is blocked or the loading is slow and the like after a plurality of applications are used, and the user experience is seriously influenced.
In the native recovery mechanism of the Android system, the following variables (hereinafter, memory variables are used for substitution) are mainly recovered in the influence mechanism:
1) mProcessLimit (classified as emptyProcessLimit and cachedProcessLimit): determining the number of backstage through a global variable in a process management service (ActivityManagerService), wherein the default is 24;
2) oom _ score _ adj: the actual priority of the corresponding process, according to the change of the activity of the process (foreground and background)
3) /sys/module/lowmemorykiller/parameters/adj: one of the main set values of the low memory recycling process (LowMemoryKiller) sets the level or priority of process cleaning;
4) /sys/module/lowmemorykiller/parameters/minfree: one of the main set values of LowMemoryKiller is a memory threshold, and the process corresponding to the priority is cleared when the current page reaches the threshold.
In an actual application scene, memory changes are more complex, and the main variables in the existing android system recovery strategy are fixed values and are not flexible enough, so that the memory strategy cannot be customized, the memory strategy cannot be changed according to the real-time memory changes, and the use of the actual scene cannot be adapted. And the important process list cannot be controlled, and necessary services or background processes of the system cannot be protected.
Disclosure of Invention
The embodiment of the invention aims to provide a real-time optimization method and a real-time optimization system for a memory environment of an android system, which can provide richer optimization conditions for the memory environment so that a user can set different optimization conditions for the memory environment according to requirements, the different optimization conditions correspond to different optimization levels, the different optimization levels correspond to different optimization strategies, an important process list is provided in the optimization conditions, the necessary service of the user or the background of the system is protected, and the necessary service of the user and the background of the system are prevented from being removed in the optimization process.
In order to achieve the above object, an embodiment of the present invention provides a method for optimizing a memory environment of an android system in real time, where the method includes:
obtaining system memory information;
judging whether the system meets the optimization condition according to the memory environment optimization condition content and the memory information, and if so, optimizing the memory environment of the system according to a recovery strategy corresponding to the optimization condition;
the optimization condition content comprises: optimizing conditions, memory recycling levels and priorities of the optimizing conditions, wherein the optimizing conditions comprise: the method comprises the steps of (1) a memory occupancy rate threshold value, a residual memory size threshold value, a background quantity, an important process list, an important process quantity threshold value, a memory residual rate threshold value, a CPU occupancy rate threshold value and an individual process occupied memory threshold value; the memory recovery levels correspond to the recovery strategies one by one.
Further, the method further comprises:
before obtaining the system memory information, obtaining the configuration of the user to the memory environment optimization condition content and the configuration to the recovery strategy. The user can configure the optimization conditions, the memory recovery levels corresponding to different optimization conditions and the priorities of different optimization conditions. Different optimization conditions and priorities of the different optimization conditions can provide more condition combinations for users, and more practical scenes can be suitable.
Optionally, the recycling policy includes: a memory threshold, a process limit threshold, and a user scoring threshold for each application.
Optionally, the system memory information includes: the system memory occupancy rate, the system residual memory size, the system residual memory rate, the background process quantity, the background process list, the memory occupied by each process and the CPU occupancy rate. The acquired memory information corresponds to the optimization conditions, and whether the memory environment can be optimized is judged according to the optimization conditions.
Optionally, the obtaining system memory information includes:
and obtaining system memory information through the api. The api is a middle interface of the android system, and the memory information can be acquired by calling the api without changing the system structure.
Optionally, the obtaining system memory information includes:
and obtaining system memory information through a command. The system memory information obtained by the command is not easy to disguise.
Further, the priority of the optimization condition is used for limiting the sequence of each optimization condition in the process of judging whether the system meets the optimization condition;
the judging whether the system accords with the optimization condition according to the memory optimization condition content and the memory information, if so, optimizing the memory environment of the system according to the recovery strategy corresponding to the optimization condition, and the method comprises the following steps:
judging whether the memory information meets the corresponding optimization conditions step by step from high to low according to the priority:
if yes, stopping executing next-stage judgment, and determining the memory recovery grade according to the corresponding optimization condition; determining a recovery strategy according to the memory recovery grade, and optimizing the system memory environment according to the recovery strategy;
if not, continuously judging whether the next-level optimization condition is met or not until all the optimization conditions are traversed, and if not, ending the current round of optimization. In the optimization process of the memory environment, the optimization conditions of different priorities are judged in different orders, the user sets the optimization condition most concerned by the user as the highest priority according to the needs of the user during configuration, and other secondary optimization conditions are arranged in order to meet different requirements of the user.
Optionally, the determining a recycling policy according to the memory recycling level, and optimizing a system memory environment according to the recycling policy includes:
determining a recovery strategy according to the memory recovery grade;
and assigning a value to the low memory recovery process of the system according to the process limit threshold corresponding to the recovery strategy and the user scoring threshold of each application, so that the low memory recovery process optimizes the system memory environment according to the recovery strategy. The android system is provided with a low memory recovery process, richer optimization conditions are set under the condition that the low memory recovery process is not removed, and when the optimization conditions are met, system data can reach the corresponding index for memory cleaning of the low memory recovery process through an assignment mode, so that memory recovery is realized through the low memory recovery process of the android system.
A second aspect of the present invention provides a real-time optimization system for a memory environment of an android system, including:
the memory information acquisition unit is used for acquiring system memory information;
the memory environment optimization unit is used for judging whether the system meets the optimization conditions or not according to the memory environment optimization condition content and the memory information, and if so, optimizing the system memory environment according to a recovery strategy corresponding to the optimization conditions;
the configuration unit is used for acquiring the configuration of the content of the memory environment optimization condition and the configuration of the recovery strategy of a user;
the optimization condition content comprises: optimizing conditions, memory recycling levels and priorities, wherein the optimizing conditions comprise: the method comprises the steps of (1) a memory occupancy rate threshold value, a residual memory size threshold value, a background quantity, an important process list, an important process quantity threshold value, a memory residual rate threshold value, a CPU occupancy rate threshold value and an individual process occupied memory threshold value; the memory recovery levels correspond to the recovery strategies one by one. The system provides rich memory optimization condition content configuration functions, and a user can flexibly configure the memory according to the requirements and is more suitable for actual use scenes.
In another aspect, the present invention provides a machine-readable storage medium having stored thereon instructions for causing a machine to execute the method for real-time optimization of a memory environment of an android system described herein.
By the technical scheme, richer memory environment optimization conditions can be provided, so that a user can set different memory environment optimization conditions according to requirements, different optimization conditions correspond to different optimization levels, different optimization levels correspond to different optimization strategies, an important process list is provided in the optimization conditions, necessary services of the user or a background of a system are protected, and the necessary services of the user and the background of the system are prevented from being removed in the optimization process.
Additional features and advantages of embodiments of the invention will be set forth in the detailed description which follows.
Drawings
The accompanying drawings, which are included to provide a further understanding of the embodiments of the invention and are incorporated in and constitute a part of this specification, illustrate embodiments of the invention and together with the description serve to explain the embodiments of the invention without limiting the embodiments of the invention. In the drawings:
fig. 1 is a flowchart of a method for optimizing a memory environment of an android system in real time according to an embodiment of the present invention;
fig. 2 is a flowchart of a real-time optimization method for a memory environment of an android system according to another embodiment of the present invention;
fig. 3 is a block diagram of a system for optimizing a memory environment in real time for an android system according to an embodiment of the present invention.
Detailed Description
The following detailed description of embodiments of the invention refers to the accompanying drawings. It should be understood that the detailed description and specific examples, while indicating embodiments of the invention, are given by way of illustration and explanation only, not limitation.
Example one
Fig. 1 is a flowchart of a method for optimizing a memory environment of an android system in real time according to an embodiment of the present invention. As shown in fig. 1, the method includes:
acquiring the configuration of a user on the content of the memory environment optimization condition and the configuration on a recovery strategy;
obtaining system memory information through the api;
judging whether the system meets the optimization condition according to the memory environment optimization condition content and the memory information, and if so, optimizing the memory environment of the system according to a recovery strategy corresponding to the optimization condition;
the optimization condition content comprises: optimizing conditions, memory recycling levels and priorities of the optimizing conditions, wherein the optimizing conditions comprise: the method comprises the steps of (1) a memory occupancy rate threshold value, a residual memory size threshold value, a background quantity, an important process list, an important process quantity threshold value, a memory residual rate threshold value, a CPU occupancy rate threshold value and an individual process occupied memory threshold value; the memory recovery levels correspond to the recovery strategies one by one.
The user can configure the optimization conditions, the memory recovery levels corresponding to different optimization conditions and the priorities of different optimization conditions autonomously. Different optimization conditions and priorities of the different optimization conditions can provide more condition combinations for users, and more practical scenes can be suitable.
In this embodiment, the recycling policy includes: a memory threshold, a process limit threshold, and a user scoring threshold for each application.
In this embodiment, the system memory information includes: the system memory occupancy rate, the system residual memory size, the system residual memory rate, the background process quantity, the background process list, the memory occupied by each process and the CPU occupancy rate. The acquired memory information corresponds to the optimization conditions, and whether the memory environment can be optimized is judged according to the optimization conditions.
In this embodiment, system memory information is obtained through the api. The api is a middle interface of the android system, and the memory information can be acquired by calling the api without changing the system structure. In some embodiments the api may be get Memory Info in Activity Manager.
In this embodiment, the priorities of the optimization conditions are used to define the order of each optimization condition in the process of determining whether the system meets the optimization conditions, the user sets the optimization condition most concerned by the user as the highest priority according to the needs of the user during configuration, and other secondary optimization conditions are arranged in order;
the judging whether the system accords with the optimization condition according to the memory optimization condition content and the memory information, if so, optimizing the memory environment of the system according to the recovery strategy corresponding to the optimization condition, and the method comprises the following steps:
judging whether the memory information meets the corresponding optimization conditions step by step from high to low according to the priority:
if yes, stopping executing next-stage judgment, and determining the memory recovery grade according to the corresponding optimization condition; determining a recovery strategy according to the memory recovery grade, and optimizing the system memory environment according to the recovery strategy;
if not, continuously judging whether the next-level optimization condition is met or not until all the optimization conditions are traversed, and if not, ending the current round of optimization. In the optimization process of the memory environment, the optimization conditions of different priorities are judged in different orders, so that different requirements of users are met.
It should be noted that, in this embodiment, the low memory recycling process lowmemkiller carried by the android system is removed, and after it is determined that the recycling condition is satisfied, the process conforming to the recycling policy is directly removed to achieve the purpose of recycling.
In one embodiment, the memory occupancy threshold is in five levels, which are: 10%, 30%, 40%, 50%, 75%; the remaining memory size threshold is five levels, which are respectively: 80M, 150M, 250M, 350M, 500M; the number of the background is as follows: 3, 4, 5, 6, 7; the list of important processes includes: 10 first processes, 10 second processes and … … decimal processes; the important city entering quantity threshold is as follows: 1, 2, 3, 4, 5; the memory remaining threshold is five levels, which are respectively: 10%, 20%, 40%, 60%, 75%; the CPU occupancy rate threshold is five grades, which are respectively: 10%, 20%, 40%, 60%, 75%; the memory occupied by the individual process is as follows: 100M, 110M, 130M, 160M, 200M.
The memory recovery grade comprises five grades which are respectively as follows:
a first stage: the memory occupancy rate threshold is 10%, the size threshold of the residual memory is 500M, the number of the background is equal to 3, the number of the important processes is 1, the threshold of the residual memory is 75%, the CPU occupancy rate threshold is 10%, and the single process occupies any one of the memory thresholds of 100M;
and a second stage: the memory occupancy rate threshold is 30%, the size threshold of the residual memory is 350M, the number of the background is equal to 4, the number of the important processes is 2, the threshold of the residual memory is 60%, the CPU occupancy rate threshold is 20%, and the single process occupies any one of the memory thresholds 110M;
and a third stage: the memory occupancy rate threshold is 40%, the size threshold of the residual memory is 250M, the number of the background is 5, the number of the important processes is 3, the threshold of the residual memory is 40%, the CPU occupancy rate threshold is 40%, and the single process occupies any one of the memory thresholds 130M;
fourth stage: the memory occupancy rate threshold is 60%, the residual memory size threshold is 150M, the number of the background is equal to 6, the number of the important processes is 4, the residual memory threshold is 20%, the CPU occupancy rate threshold is 60%, and the single process occupies any one of the memory thresholds 160M;
and a fifth stage: the memory occupancy rate threshold is 75%, the residual memory size threshold is 80M, the number of the background is equal to 7, the number of the important processes is 5, the residual memory threshold is 10%, the CPU occupancy rate threshold is 75%, and the single process occupies any one of the memory thresholds of 200M.
The priority is as follows: the memory occupancy rate threshold value > the size threshold value of the residual memory > the background quantity > the important process list > the quantity threshold value of the important process > the memory residual rate threshold value > the CPU occupancy rate threshold value > the memory occupancy rate threshold value of the single process.
In the recycling strategy, the memory threshold/sys/module/lowmemorykiller/parameters/minfree is five levels, which are respectively: 1024, 2048, 3072, 3584, 4096;
the process limit threshold MAX _ CACHED _ APPS-mpocesslimit is a system default value,
the user rating threshold/sys/module/lowmemorykiller/parameters/adj of each application are respectively: 0,58, 176, 529, 1000.
The first gear reclamation strategy is: a memory threshold value of 4096, a user rating threshold value of 1000 for each application; the second gear reclamation strategy is: a memory threshold 3584, a user rating threshold 529 for each application; the third gear reclamation strategy is: a memory threshold 3072, a user rating threshold 176 for each application; the fourth gear reclamation strategy is: a memory threshold 2048, a user rating threshold 58 for each application; the fifth gear reclamation strategy is: memory threshold 1024, user score threshold 0 for each application. The first file recovery strategy corresponds to the first-level memory recovery level, and so on. In the above recycling policies, when the first-file recycling policy indicates that the available memory is lower than 4096 × 4K, the application with the user rating threshold oom _ score _ adj > -1000 of each application is removed, and the other recycling policies are analogized in turn.
It should be noted that, the values of the items in the above embodiments are only used for illustration, and the specific values may be set according to empirical data or user requirements.
The obtaining of the system memory information through the api includes: the occupancy rate of the system memory is 20%, the size of the system residual memory is 750M, the rate of the system residual memory is 75%, the number of background processes is 3, and the background processes comprise: the fifteenth process occupies the memory 90M, the twentieth process occupies the memory 75M, and the twenty-first process occupies the memory 85M; the CPU occupancy rate is 8%.
After the system acquires the system memory information, the system judges according to the optimization condition, firstly judges the memory occupancy rate threshold according to the priority, and the system memory occupancy rate is 20 percent of the first-level memory recovery grade, so that a first-level recovery strategy corresponding to the first-level memory recovery grade needs to be executed, and the application with the user grading threshold value more than or equal to 1000 is cleared and closed.
It should be noted that, in the above embodiment, since the optimization condition of the first priority is already satisfied, the subsequent condition does not need to be determined, and when the optimization condition of the previous priority is not satisfied, the determination of the next-stage optimization condition needs to be continued.
Example two
Fig. 2 is a flowchart of a method for optimizing a memory environment of an android system in real time according to an embodiment of the present invention. As shown in fig. 2, the method includes:
acquiring the configuration of a user on the content of the memory environment optimization condition and the configuration on a recovery strategy;
obtaining system memory information through a command;
judging whether the system meets the optimization condition according to the memory environment optimization condition content and the memory information, and if so, optimizing the memory environment of the system according to a recovery strategy corresponding to the optimization condition;
the optimization condition content comprises: optimizing conditions, memory recycling levels and priorities of the optimizing conditions, wherein the optimizing conditions comprise: the method comprises the steps of (1) a memory occupancy rate threshold value, a residual memory size threshold value, a background quantity, an important process list, an important process quantity threshold value, a memory residual rate threshold value, a CPU occupancy rate threshold value and an individual process occupied memory threshold value; the memory recovery levels correspond to the recovery strategies one by one.
The user can configure the optimization conditions, the memory recovery levels corresponding to different optimization conditions and the priorities of different optimization conditions autonomously. Different optimization conditions and priorities of the different optimization conditions can provide more condition combinations for users, and more practical scenes can be suitable.
In this embodiment, the recycling policy includes: a memory threshold, a process limit threshold, and a user scoring threshold for each application.
In this embodiment, the system memory information includes: the system memory occupancy rate, the system residual memory size, the system residual memory rate, the background process quantity, the background process list, the memory occupied by each process and the CPU occupancy rate. The acquired memory information corresponds to the optimization conditions, and whether the memory environment can be optimized is judged according to the optimization conditions.
In this embodiment, the system memory information obtained by the command is not easily disguised. The command may be cat/proc/meminfo in some embodiments; dumpsys meminfo; top; ps.
In this embodiment, the priorities of the optimization conditions are used to define the order of each optimization condition in the process of determining whether the system meets the optimization conditions, the user sets the optimization condition most concerned by the user as the highest priority according to the needs of the user during configuration, and other secondary optimization conditions are arranged in order;
the judging whether the system accords with the optimization condition according to the memory optimization condition content and the memory information, if so, optimizing the memory environment of the system according to the recovery strategy corresponding to the optimization condition, and the method comprises the following steps:
judging whether the memory information meets the corresponding optimization conditions step by step from high to low according to the priority:
if yes, stopping executing next-stage judgment, and determining the memory recovery grade according to the corresponding optimization condition; determining a recovery strategy according to the memory recovery grade, and optimizing the system memory environment according to the recovery strategy;
if not, continuously judging whether the next-level optimization condition is met or not until all the optimization conditions are traversed, and if not, ending the current round of optimization. In the optimization process of the memory environment, the optimization conditions of different priorities are judged in different orders, so that different requirements of users are met.
It should be noted that, in this embodiment, a low memory reclamation process lowmemkiller on the android system is reserved. Therefore, in this embodiment, determining a recycle policy according to the memory recycle level, and optimizing the system memory environment according to the recycle policy includes:
determining a recovery strategy according to the memory recovery grade;
and assigning a value to the low memory recovery process of the system according to the process limit threshold corresponding to the recovery strategy and the user scoring threshold of each application, so that the low memory recovery process optimizes the system memory environment according to the recovery strategy. The android system is provided with a low memory recovery process, richer optimization conditions are set under the condition that the low memory recovery process is not removed, and when the optimization conditions are met, system data can reach the corresponding index for memory cleaning of the low memory recovery process through an assignment mode, so that memory recovery is realized through the low memory recovery process of the android system.
Specifically, the process is cleared by modifying the process limit threshold, mpocesslimit, and oom _ score _ adj of the corresponding process to make it reach the low memory reclamation process lowmemkiller condition. The common way is that when recovery is needed, oom _ score _ adj of the corresponding process is adjusted to 1000, or the adjustment is: when the minimum memory corresponding to the memory threshold minfree is used, the maximum adj can achieve the purpose of recovering the background process. And the system cache is reduced by modifying the size of MAX _ CACHED _ APPS, so that the system cache is smoother.
It should be noted that the modification of the memory variable is configured according to the configuration file lowmemkiller _ duration.
It should be noted that: oom _ score _ adj is not recoverable when it is 0, since this represents a foreground process that needs protection or otherwise clears the visual interface directly.
In one embodiment, the memory occupancy threshold is in five levels, which are: 10%, 30%, 40%, 50%, 75%; the remaining memory size threshold is five levels, which are respectively: 80M, 150M, 250M, 350M, 500M; the number of the background is as follows: 3, 4, 5, 6, 7; the list of important processes includes: 10 first processes, 10 second processes and … … decimal processes; the important city entering quantity threshold is as follows: 1, 2, 3, 4, 5; the memory remaining threshold is five levels, which are respectively: 10%, 20%, 40%, 60%, 75%; the CPU occupancy rate threshold is five grades, which are respectively: 10%, 20%, 40%, 60%, 75%; the memory occupied by the individual process is as follows: 100M, 110M, 130M, 160M, 200M.
The memory recovery grade comprises five grades which are respectively as follows:
a first stage: the memory occupancy rate threshold is 10%, the size threshold of the residual memory is 500M, the number of the background is equal to 3, the number of the important processes is 1, the threshold of the residual memory is 75%, the CPU occupancy rate threshold is 10%, and the single process occupies any one of the memory thresholds of 100M;
and a second stage: the memory occupancy rate threshold is 30%, the size threshold of the residual memory is 350M, the number of the background is equal to 4, the number of the important processes is 2, the threshold of the residual memory is 60%, the CPU occupancy rate threshold is 20%, and the single process occupies any one of the memory thresholds 110M;
and a third stage: the memory occupancy rate threshold is 40%, the size threshold of the residual memory is 250M, the number of the background is 5, the number of the important processes is 3, the threshold of the residual memory is 40%, the CPU occupancy rate threshold is 40%, and the single process occupies any one of the memory thresholds 130M;
fourth stage: the memory occupancy rate threshold is 60%, the residual memory size threshold is 150M, the number of the background is equal to 6, the number of the important processes is 4, the residual memory threshold is 20%, the CPU occupancy rate threshold is 60%, and the single process occupies any one of the memory thresholds 160M;
and a fifth stage: the memory occupancy rate threshold is 75%, the residual memory size threshold is 80M, the number of the background is equal to 7, the number of the important processes is 5, the residual memory threshold is 10%, the CPU occupancy rate threshold is 75%, and the single process occupies any one of the memory thresholds of 200M.
The priority is as follows: the memory occupancy rate threshold value is less than the residual memory size threshold value, less than the background quantity, less than the important process list, less than the important process quantity threshold value, less than the memory residual rate threshold value, less than the CPU occupancy rate threshold value and less than the single process occupancy memory threshold value.
In the recycling strategy, the memory threshold/sys/module/lowmemorykiller/parameters/minfree is five levels, which are respectively: 1024, 2048, 3072, 3584, 4096;
the process limit threshold MAX _ CACHED _ APPS-mpocesslimit is a system default value,
the user rating threshold/sys/module/lowmemorykiller/parameters/adj of each application are respectively: 0,58, 176, 529, 1000.
The first gear reclamation strategy is: a memory threshold value of 4096, a user rating threshold value of 1000 for each application; the second gear reclamation strategy is: a memory threshold 3584, a user rating threshold 529 for each application; the third gear reclamation strategy is: a memory threshold 3072, a user rating threshold 176 for each application; the fourth gear reclamation strategy is: a memory threshold 2048, a user rating threshold 58 for each application; the fifth gear reclamation strategy is: memory threshold 1024, user score threshold 0 for each application. The first file recovery strategy corresponds to the first-level memory recovery level, and so on. In the above recycling policies, when the first-file recycling policy indicates that the available memory is lower than 4096 × 4K, the application with the user rating threshold oom _ score _ adj > -1000 of each application is removed, and the other recycling policies are analogized in turn.
It should be noted that, the values of the items in the above embodiments are only used for illustration, and the specific values may be set according to empirical data or user requirements.
The system memory information obtained by the command includes: the occupancy rate of the system memory is 20%, the size of the system residual memory is 750M, the rate of the system residual memory is 75%, the number of background processes is 3, and the background processes comprise: the fifteenth process occupies the memory 90M, the twentieth process occupies the memory 75M, and the twenty-first process occupies the memory 85M; the CPU occupancy rate is 8%.
After the system acquires the system memory information, judging according to optimization conditions, and according to priority, firstly judging that an individual process occupies a memory threshold value which is 90M at most and does not accord with any optimization conditions; then judging the CPU occupancy rate threshold value, wherein the CPU occupancy rate is 8%, and the CPU occupancy rate does not accord with any optimization condition; and then judging the memory surplus rate threshold, wherein the memory surplus rate threshold is 75%, and the memory surplus rate threshold accords with the first-level memory recovery level, so that a first-file recovery strategy corresponding to the first-level memory recovery level needs to be executed, and clearing and closing the application with the user scoring threshold more than or equal to 1000 by adjusting oom _ score _ adj of the corresponding process to be 1000.
EXAMPLE III
Fig. 3 is a block diagram of a system for optimizing a memory environment in real time for an android system according to an embodiment of the present invention. As shown in fig. 3, the real-time memory environment optimization system includes:
the memory information acquisition unit is used for acquiring system memory information;
the memory environment optimization unit is used for judging whether the system meets the optimization conditions or not according to the memory environment optimization condition content and the memory information, and if so, optimizing the system memory environment according to a recovery strategy corresponding to the optimization conditions;
the configuration unit is used for acquiring the configuration of the content of the memory environment optimization condition and the configuration of the recovery strategy of a user;
the optimization condition content comprises: optimizing conditions, memory recycling levels and priorities, wherein the optimizing conditions comprise: the method comprises the steps of (1) a memory occupancy rate threshold value, a residual memory size threshold value, a background quantity, an important process list, an important process quantity threshold value, a memory residual rate threshold value, a CPU occupancy rate threshold value and an individual process occupied memory threshold value; the memory recovery levels correspond to the recovery strategies one by one. The system provides rich memory optimization condition content configuration functions, and a user can flexibly configure the memory according to the requirements and is more suitable for actual use scenes.
The invention also provides a machine-readable storage medium, which stores instructions for causing a machine to execute the memory environment real-time optimization method for the android system.
Although the embodiments of the present invention have been described in detail with reference to the accompanying drawings, the embodiments of the present invention are not limited to the details of the above embodiments, and various simple modifications can be made to the technical solutions of the embodiments of the present invention within the technical idea of the embodiments of the present invention, and the simple modifications all belong to the protection scope of the embodiments of the present invention.
It should be noted that the various features described in the above embodiments may be combined in any suitable manner without departing from the scope of the invention. In order to avoid unnecessary repetition, the embodiments of the present invention do not describe every possible combination.
Those skilled in the art will understand that all or part of the steps in the method according to the above embodiments may be implemented by a program, which is stored in a storage medium and includes several instructions to enable a single chip, a chip, or a processor (processor) to execute all or part of the steps in the method according to the embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
In addition, any combination of various different implementation manners of the embodiments of the present invention is also possible, and the embodiments of the present invention should be considered as disclosed in the embodiments of the present invention as long as the combination does not depart from the spirit of the embodiments of the present invention.

Claims (10)

1. A real-time optimization method for a memory environment of an android system is characterized by comprising the following steps:
obtaining system memory information;
judging whether the system meets the optimization condition according to the memory environment optimization condition content and the memory information, and if so, optimizing the memory environment of the system according to a recovery strategy corresponding to the optimization condition;
the optimization condition content comprises: optimizing conditions, memory recovery levels and priorities of the optimizing conditions;
the optimization conditions include: the method comprises the steps of (1) a memory occupancy rate threshold value, a residual memory size threshold value, a background quantity, an important process list, an important process quantity threshold value, a memory residual rate threshold value, a CPU occupancy rate threshold value and an individual process occupied memory threshold value; the memory recovery levels correspond to the recovery strategies one by one.
2. The real-time optimization method for the memory environment of the android system of claim 1, further comprising:
before obtaining the system memory information, obtaining the configuration of the user to the memory environment optimization condition content and the configuration to the recovery strategy.
3. The real-time optimization method for the memory environment of the android system as claimed in claim 1, wherein the recycling policy includes: a memory threshold, a process limit threshold, and a user scoring threshold for each application.
4. The real-time optimization method for the memory environment of the android system as claimed in claim 1, wherein the system memory information includes: the system memory occupancy rate, the system residual memory size, the system residual memory rate, the background process quantity, the background process list, the memory occupied by each process and the CPU occupancy rate.
5. The method for optimizing the memory environment of the android system in real time according to claim 4, wherein the obtaining system memory information includes:
and obtaining system memory information through the api.
6. The method for optimizing the memory environment of the android system in real time according to claim 4, wherein the obtaining system memory information includes:
and obtaining system memory information through a command.
7. The real-time optimization method for the memory environment of the android system as claimed in claim 1, wherein the priority of the optimization condition is used to define the sequence of each optimization condition in the process of judging whether the system meets the optimization condition;
the judging whether the system accords with the optimization condition according to the memory optimization condition content and the memory information, if so, optimizing the memory environment of the system according to the recovery strategy corresponding to the optimization condition, and the method comprises the following steps:
judging whether the memory information meets the corresponding optimization conditions step by step from high to low according to the priority:
if yes, stopping executing next-stage judgment, and determining the memory recovery grade according to the corresponding optimization condition; determining a recovery strategy according to the memory recovery grade, and optimizing the system memory environment according to the recovery strategy;
if not, continuously judging whether the next-level optimization condition is met or not until all the optimization conditions are traversed, and if not, ending the current round of optimization.
8. The method according to claim 7, wherein the determining a recycling policy according to the memory recycling level and optimizing the system memory environment according to the recycling policy comprise:
determining a recovery strategy according to the memory recovery grade;
and assigning a value to the low memory recovery process of the system according to the process limit threshold corresponding to the recovery strategy and the user scoring threshold of each application, so that the low memory recovery process optimizes the system memory environment according to the recovery strategy.
9. A real-time optimization system of memory environment for an android system, comprising:
the memory information acquisition unit is used for acquiring system memory information;
the memory environment optimization unit is used for judging whether the system meets the optimization conditions or not according to the memory environment optimization condition content and the memory information, and if so, optimizing the system memory environment according to a recovery strategy corresponding to the optimization conditions;
the configuration unit is used for acquiring the configuration of the content of the memory environment optimization condition and the configuration of the recovery strategy of a user;
the optimization condition content comprises: optimizing conditions, memory recycling levels and priorities, wherein the optimizing conditions comprise: the method comprises the steps of (1) a memory occupancy rate threshold value, a residual memory size threshold value, a background quantity, an important process list, an important process quantity threshold value, a memory residual rate threshold value, a CPU occupancy rate threshold value and an individual process occupied memory threshold value; the memory recovery levels correspond to the recovery strategies one by one.
10. A machine-readable storage medium having stored thereon instructions for causing a machine to perform the method for real-time optimization of a memory environment for an android system of any of claims 1-8 herein.
CN202110995021.1A 2021-08-27 2021-08-27 Memory environment real-time optimization method and system for android system Active CN113626203B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110995021.1A CN113626203B (en) 2021-08-27 2021-08-27 Memory environment real-time optimization method and system for android system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110995021.1A CN113626203B (en) 2021-08-27 2021-08-27 Memory environment real-time optimization method and system for android system

Publications (2)

Publication Number Publication Date
CN113626203A true CN113626203A (en) 2021-11-09
CN113626203B CN113626203B (en) 2024-02-13

Family

ID=78388106

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110995021.1A Active CN113626203B (en) 2021-08-27 2021-08-27 Memory environment real-time optimization method and system for android system

Country Status (1)

Country Link
CN (1) CN113626203B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115437783A (en) * 2022-08-17 2022-12-06 荣耀终端有限公司 Searching and killing method, electronic equipment and readable storage medium

Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104503840A (en) * 2014-12-15 2015-04-08 北京奇虎科技有限公司 Method and device for optimizing terminal resources
CN104503887A (en) * 2014-12-15 2015-04-08 北京奇虎科技有限公司 Method and device for showing state of computing equipment
US20160055013A1 (en) * 2013-04-02 2016-02-25 Beijing Qihoo Technology Company Limited System optimizing method and apparatus
CN106648943A (en) * 2016-09-22 2017-05-10 郑州云海信息技术有限公司 Memory optimization method for performance test of smart rack system
CN107145389A (en) * 2017-03-09 2017-09-08 深圳市先河系统技术有限公司 A kind of system process monitoring method and computing device
CN107220076A (en) * 2016-09-27 2017-09-29 华为技术有限公司 A kind of method for recovering internal storage and device
CN110175075A (en) * 2019-05-21 2019-08-27 深圳市君和睿通科技股份有限公司 Android system Memory Optimize Method and device
US20200117387A1 (en) * 2018-10-10 2020-04-16 Micron Technology, Inc. Dynamic background scan optimization in a memory sub-system
CN111198759A (en) * 2018-11-16 2020-05-26 深圳市优必选科技有限公司 Memory optimization method, system, terminal equipment and readable storage medium
US20200349067A1 (en) * 2019-05-05 2020-11-05 Microsoft Technology Licensing, Llc Memory management for serverless databases

Patent Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20160055013A1 (en) * 2013-04-02 2016-02-25 Beijing Qihoo Technology Company Limited System optimizing method and apparatus
CN104503840A (en) * 2014-12-15 2015-04-08 北京奇虎科技有限公司 Method and device for optimizing terminal resources
CN104503887A (en) * 2014-12-15 2015-04-08 北京奇虎科技有限公司 Method and device for showing state of computing equipment
CN106648943A (en) * 2016-09-22 2017-05-10 郑州云海信息技术有限公司 Memory optimization method for performance test of smart rack system
CN107220076A (en) * 2016-09-27 2017-09-29 华为技术有限公司 A kind of method for recovering internal storage and device
CN107145389A (en) * 2017-03-09 2017-09-08 深圳市先河系统技术有限公司 A kind of system process monitoring method and computing device
US20200117387A1 (en) * 2018-10-10 2020-04-16 Micron Technology, Inc. Dynamic background scan optimization in a memory sub-system
CN111198759A (en) * 2018-11-16 2020-05-26 深圳市优必选科技有限公司 Memory optimization method, system, terminal equipment and readable storage medium
US20200349067A1 (en) * 2019-05-05 2020-11-05 Microsoft Technology Licensing, Llc Memory management for serverless databases
CN110175075A (en) * 2019-05-21 2019-08-27 深圳市君和睿通科技股份有限公司 Android system Memory Optimize Method and device

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
夏厦;李俊;: "基于缓存竞争优化的Linux进程调度策略", 计算机工程, no. 04 *

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115437783A (en) * 2022-08-17 2022-12-06 荣耀终端有限公司 Searching and killing method, electronic equipment and readable storage medium

Also Published As

Publication number Publication date
CN113626203B (en) 2024-02-13

Similar Documents

Publication Publication Date Title
CN108495195B (en) Network live broadcast ranking list generation method, device, equipment and storage medium
US9734082B2 (en) Temporal standby list
CN105760199A (en) Method and equipment for loading application resource
CN113626203A (en) Memory environment real-time optimization method and system for android system
CN113867959A (en) Training task resource scheduling method, device, equipment and medium
CN108108089A (en) A kind of picture loading method and device
CN115269190A (en) Memory allocation method and device, electronic equipment, storage medium and product
CN112214288B (en) Pod scheduling method, device, equipment and medium based on Kubernetes cluster
US9996470B2 (en) Workload management in a global recycle queue infrastructure
CN112765046A (en) Method, apparatus and computer program product for reclaiming storage space
CN113784334A (en) Card switching method and device
CN111522659B (en) Space use method and device
CN113806594A (en) Business data processing method, device, equipment and storage medium based on decision tree
CN112650449A (en) Release method and release system of cache space, electronic device and storage medium
CN109522113B (en) Memory management method and device
CN116185624A (en) Garbage collection method and device for hard disk, computer equipment and storage medium
CN112035253B (en) Linux system page cache recovery method and related device
CN112925472A (en) Request processing method and device, electronic equipment and computer storage medium
CN115951832A (en) Method and system for merging intelligent small files aiming at object storage
CN114298294B (en) Neural network memory optimization method and device based on hardware accelerator
US10884950B2 (en) Importance based page replacement
EP2077498B1 (en) Memory management system and method for a mobile device
CN115134300A (en) Exchange equipment rule cache management method facing software defined network
CN110688226B (en) Cache recovery method, device and equipment and readable storage medium
CN116450328A (en) Memory allocation method, memory allocation device, computer equipment and 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
GR01 Patent grant
GR01 Patent grant