Memory management method and device, electronic equipment and storage medium

By parsing preset configuration files to obtain program grouping rules and memory switching policies when the operating system of an electronic device is started, and grouping and memory management of applications is solved, and the problem of fixed memory management methods in the existing technology is achieved, and more flexible and fine memory management is achieved.

CN119536969APending Publication Date: 2025-02-28GUANGDONG OPPO MOBILE TELECOMMUNICATIONS CORP LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311109911.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-08-30
Publication Date
2025-02-28

AI Technical Summary

Technical Problem

The existing memory management technology lacks differentiated processing, resulting in fixed memory management methods and affecting management results.

Method used

By reading preset configuration files when the operating system of an electronic device is started, parsing the configuration files to obtain program grouping rules and memory switching policies, grouping and memory management of applications based on these rules and policies.

Benefits of technology

It realizes more flexible and fine memory management, and can dynamically adjust according to the characteristics of different applications to improve system performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119536969A_ABST
    Figure CN119536969A_ABST
Patent Text Reader

Abstract

The invention discloses a memory management method and device, electronic equipment and a storage medium, and relates to the technical field of memory management. The method is applied to the electronic equipment, and comprises the following steps: under the condition that an operating system of the electronic equipment is started, reading a preset configuration file from the operating system, analyzing the preset configuration file to obtain a program grouping rule and a memory exchange strategy, grouping a plurality of application programs operated by the electronic equipment based on the program grouping rule, the method comprises the steps of obtaining a plurality of program groups according to a memory exchange strategy, and performing memory management on each program group based on the memory exchange strategy, each program group comprising at least one application program. According to the application, the program grouping rule is set through the configuration file to group the running application programs, and the memory management is performed on the grouped application programs through the memory exchange strategy set by the configuration file, so that the memory management is more flexible and fine.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of memory management technology, and more specifically, to a memory management method, device, electronic device and storage medium. Background Art

[0002] With the development of science and technology, electronic devices are used more and more widely and have more and more functions. They have become one of the necessities in people's daily life. Among them, electronic devices generally perform memory management, but the current memory management technology is not differentiated, resulting in a fixed memory management method and poor memory management effect. Summary of the invention

[0003] In view of the above problems, the present application proposes a memory management method, device, electronic device and storage medium to solve the above problems.

[0004] In a first aspect, an embodiment of the present application provides a memory management method, which is applied to an electronic device, and the method comprises: when the operating system of the electronic device is started, reading a preset configuration file from the operating system; parsing the preset configuration file to obtain program grouping rules and a memory exchange strategy; grouping multiple applications running on the electronic device based on the program grouping rules to obtain multiple program groups, wherein each of the multiple program groups includes at least one application; and performing memory management on each program group based on the memory exchange strategy.

[0005] In a second aspect, an embodiment of the present application provides a memory management device, which is applied to an electronic device, and the device includes: a configuration file reading module, which is used to read a preset configuration file from the operating system when the operating system of the electronic device is started; a configuration file parsing module, which is used to parse the preset configuration file to obtain program grouping rules and memory exchange strategies; an application grouping module, which is used to group multiple applications running on the electronic device based on the program grouping rules to obtain multiple program groups, wherein each of the multiple program groups includes at least one application; and a memory management module, which is used to perform memory management on each program group based on the memory exchange strategy.

[0006] In a third aspect, an embodiment of the present application provides an electronic device, comprising a memory and a processor, wherein the memory is coupled to the processor, the memory stores instructions, and when the instructions are executed by the processor, the processor executes the above method.

[0007] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, in which a program code is stored, and the program code can be called by a processor to execute the above method.

[0008] The memory management method, device, electronic device and storage medium provided in the embodiments of the present application, when the operating system of the electronic device is started, reads a preset configuration file from the operating system, parses the preset configuration file, obtains program grouping rules and memory exchange policies, and groups multiple applications running on the electronic device based on the program grouping rules to obtain multiple program groups, wherein each of the multiple program groups includes at least one application, and performs memory management on each program group based on the memory exchange policy, so that the running applications are grouped by setting the program grouping rules through the configuration file, and the grouped applications are memory managed by the memory exchange policy set in the configuration file, so that memory management can be made more flexible and sophisticated. BRIEF DESCRIPTION OF THE DRAWINGS

[0009] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without paying any creative work.

[0010] Figure 1 A schematic diagram of a memory management method according to an embodiment of the present application is shown;

[0011] Figure 2 A schematic diagram of a memory management method according to an embodiment of the present application is shown;

[0012] Figure 3 A schematic diagram of a memory management method according to an embodiment of the present application is shown;

[0013] Figure 4 A schematic diagram of a memory management method according to an embodiment of the present application is shown;

[0014] Figure 5 A schematic diagram of a memory management method according to an embodiment of the present application is shown;

[0015] Figure 6 A schematic diagram of a memory management method according to an embodiment of the present application is shown;

[0016] Figure 7 A schematic diagram of a memory management method according to an embodiment of the present application is shown;

[0017] Figure 8A module block diagram of a memory management device provided by an embodiment of the present application is shown;

[0018] Fig. 9 A block diagram of an electronic device according to an embodiment of the present application for executing a memory management method according to an embodiment of the present application is shown;

[0019] Fig.10 A storage unit for storing or carrying program codes for implementing a memory management method according to an embodiment of the present application is shown. DETAILED DESCRIPTION

[0020] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application.

[0021] Among them, in Android or other Linux-based operating systems, Swap is a traditional memory swap strategy. It allows the operating system to "swap out" the data in the memory to the hard disk (or other storage media) to free up memory space for other processes to use. When the "swapped out" data is needed again, the operating system will "swap it back" from the hard disk to the memory to achieve the purpose of using the data.

[0022] The following are the main mechanisms of Linux swap management:

[0023] 1. Swap Space: This is a special hard disk partition that is used by the operating system as a Swap storage space. The size of the Swap Space is generally set by the system administrator during system installation or configuration, and can usually be reasonably determined based on the system's RAM size and application requirements.

[0024] 2. Swapiness: This is a system parameter that controls the operating system's reliance on Swap. The value of Swapiness ranges from 0 to 100. A higher value indicates that the operating system is more inclined to swap data out to Swap Space, while a lower value indicates that the system is more inclined to keep data in memory as much as possible.

[0025] 3. Page Replacement Algorithm: Swap management in Linux systems is mainly based on a page replacement algorithm called "Least Recently Used" (LRU). Simply put, the LRU algorithm records the last time each memory page was accessed. When swapping is required, the system will select the page that has not been accessed for the longest time to swap out, because such a page is least likely to be needed again in the near future.

[0026] 4. Swap In & Swap Out: When the system memory is insufficient, Linux will trigger Swap Out to swap out the selected memory page to Swap Space. When a swapped out page is needed again, the system will trigger Swap In to swap the page from Swap Space back to the memory.

[0027] 5. Overcommit and OOM Killer: The Linux system allows memory "overcommit", that is, the total amount of memory requested by the application can exceed the sum of physical RAM and Swap Space. When the over-allocated memory is really needed, if there is not enough memory space, the system will trigger the "Out Of Memory Killer" (OOM Killer) process, automatically ending certain processes to free up memory space.

[0028] The inventors have found through research that although Swap can provide additional space when memory is insufficient, over-reliance on Swap may seriously affect system performance because the hard disk read and write speed is much lower than the random access memory (RAM). In addition, current memory management technology treats all applications equally without considering their impact on users; pages of important applications may be replaced inappropriately, affecting performance; there is a lack of differentiated memory management for different applications, and fine-grained memory management cannot be achieved; current memory management technology cannot dynamically adjust its memory management strategy according to the status of the application.

[0029] In view of the above problems, the inventors have discovered after long-term research and proposed the memory management method, device, electronic device and storage medium provided in the embodiments of the present application. The running applications are grouped by setting program grouping rules in the configuration file, and the memory exchange strategy set in the configuration file is used to manage the memory of the grouped applications, which can make the memory management more flexible and sophisticated. Among them, the specific memory management method is described in detail in the subsequent embodiments.

[0030] See also Figure 1 , Figure 1 The flowchart of the memory management method provided by an embodiment of the present application is shown. The method is used to group running applications by setting program grouping rules through a configuration file, and to manage the memory of the grouped applications through a memory exchange policy set in the configuration file, so that the memory management can be more flexible and sophisticated. In a specific embodiment, the memory management method is applied to Figure 8The memory management device 200 and the electronic device 100 ( Fig. 9 ). The following will take an electronic device as an example to illustrate the specific process of this embodiment. Of course, it can be understood that the electronic device used in this embodiment may include a smart phone, a tablet computer, a wearable electronic device, etc., which is not limited here. Figure 1 The process shown is described in detail, and the memory management method may specifically include the following steps:

[0031] Step S110: when the operating system of the electronic device is started, read a preset configuration file from the operating system.

[0032] In this embodiment, when the operating system of the electronic device is started, a preset configuration file can be read from the operating system of the electronic device. Optionally, the preset configuration file can specify program grouping rules and memory exchange strategies.

[0033] In some implementations, the electronic device may predefine a configuration file as a preset configuration file, and add the preset configuration file to the operating system of the electronic device. Accordingly, when the operating system of the electronic device is started, the preset configuration file may be read from the operating system.

[0034] As an implementable manner, when the electronic device adds a preset configuration file to the operating system of the electronic device, the location where the preset configuration file is added can be recorded. Based on this, when the operating system of the electronic device is started, the preset configuration file can be read from the operating system based on the location where the preset configuration file is added. For example, the path for obtaining the preset configuration file can be determined based on the location where the preset configuration file is added, and when the operating system of the electronic device is started, the preset configuration file can be read from the operating system based on the path.

[0035] In some implementations, it is possible to detect whether the operating system of the electronic device is started. If it is detected that the operating system of the electronic device is started, a preset configuration file can be read from the operating system of the electronic device; if it is detected that the operating system of the electronic device is not started, it is possible to continue to detect whether the operating system of the electronic device is started. As an implementable method, a listener can be registered in the electronic device, and the listener can be used to detect whether the operating system of the electronic device is started.

[0036] Step S120: parsing the preset configuration file to obtain program grouping rules and memory swap strategies.

[0037] In this embodiment, when a preset configuration file is read, the preset configuration file can be parsed to obtain a program grouping rule and a memory swap strategy Swap. The program grouping rule is used to indicate grouping of applications running on the electronic device, and the memory swap strategy is used to indicate swapping out or swapping in memory data for applications in different groups.

[0038] In some embodiments, when a preset configuration file is read, the preset configuration file can be parsed by a file parsing technique to obtain program grouping rules and memory exchange strategies. As an implementable manner, the electronic device can be pre-set with multiple file parsing techniques. When a preset configuration file is read, a target file parsing technique can be selected from multiple file parsing techniques based on the preset configuration file, and the preset configuration file can be parsed by the target file parsing technique to obtain program grouping rules and memory exchange strategies. Optionally, selecting a target file parsing technique from multiple file parsing techniques based on the preset configuration file may include: selecting a target file parsing technique from multiple file parsing techniques based on the format of the preset configuration file; selecting a target file parsing technique from multiple file parsing techniques based on the data volume of the preset configuration file, etc., which is not limited here.

[0039] In some implementations, the number of the program grouping rules may be one or more. The number of the memory swap policies may be one or more.

[0040] Step S130: Grouping the multiple application programs running on the electronic device based on the program grouping rule to obtain multiple program groups, wherein each of the multiple program groups includes at least one application program.

[0041] In this embodiment, when a program grouping rule is obtained, multiple application programs running on the electronic device can be grouped based on the program grouping rule to obtain multiple program groups. It can be understood that each of the multiple program groups includes at least one application program.

[0042] As an example, if the number of applications running on the electronic device is 5, the 5 applications can be grouped based on the program grouping rule to obtain multiple 3 program groups, where the first program group of the 3 program groups includes 2 applications, the second program group includes 2 applications, and the third program group includes 1 application.

[0043] In some implementations, when a program grouping rule is obtained, the application programs running on the electronic device can be detected, and the multiple application programs running on the detected electronic device can be grouped based on the program grouping rule to obtain multiple program groups. Optionally, the application programs running on the electronic device can include: an application program running in the foreground of the electronic device, an application program running in the background of the electronic device, an application program running in the foreground and background of the electronic device, etc., which is not limited here.

[0044] As an implementable manner, the program grouping rule may include the name of the application, and this grouping rule provides the possibility for fine-grained memory management, and the user can set different name grouping rules according to their own needs. Therefore, grouping multiple applications running on an electronic device based on the program grouping rule may include: grouping multiple applications running on an electronic device based on the name of the application. As an example, grouping multiple applications running on an electronic device based on the name of the application may include: grouping multiple applications running on an electronic device based on the package name of the application; or, grouping multiple applications running on an electronic device based on the process name of the process included in the application.

[0045] As an implementable manner, the program grouping rule may include an identification code of an application, wherein the identification code may be used to uniquely identify the application. This grouping rule provides the possibility for fine-grained memory management, and users can set different identification code grouping rules according to their needs. Therefore, grouping multiple applications running on an electronic device based on the program grouping rule may include: grouping multiple applications running on an electronic device based on the identification code of the application. As an example, grouping multiple applications running on an electronic device based on the identification code of the application may include: grouping multiple applications running on an electronic device based on the UID of the application.

[0046] As an implementable method, the program grouping rule may include the version number of the application program. It is understandable that different versions of the application program may have different memory usage characteristics. Therefore, the method of grouping multiple applications running on the electronic device based on the version number of the application program can make it possible to distinguish and manage different versions of the application program, which can improve the memory management effect. Therefore, grouping multiple applications running on the electronic device based on the program grouping rule may include: grouping multiple applications running on the electronic device based on the version number of the application program.

[0047] As an implementable manner, the program grouping rule may include a wildcard of the application program, and this grouping rule provides the possibility for complex grouping rules, such as including all applications starting with a certain prefix into a unified group for unified management. Therefore, grouping multiple applications running on the electronic device based on the program grouping rule may include: grouping multiple applications running on the electronic device based on the wildcard of the application program.

[0048] As an implementable manner, the program grouping rule may include a combination of at least two of the application name, the application identification code, the application version number, and the application wildcard, which will not be described in detail here.

[0049] In some embodiments, grouping multiple applications running on an electronic device may include grouping multiple applications in an include or exclude manner. For example, when grouping multiple applications running on an electronic device by application name, if it is an include operation, then applications containing a certain specific name will be included in the same group; if it is an exclude operation, then applications not containing a certain specific name will be included in the same group.

[0050] Step S140: performing memory management on each program group based on the memory swap strategy.

[0051] In this embodiment, when multiple program groups are obtained, content management can be performed on each of the multiple program groups based on the memory exchange strategy, so that the configuration file is used to manage the memory grouping and memory exchange strategy, which can make the memory management more flexible and refined. It can be understood that when multiple applications running on an electronic device are divided into multiple program groups and memory management is performed on each program group based on the memory exchange strategy, fine division management of the application can be achieved, avoiding improper replacement of important applications and causing improper impact on the operation of the application.

[0052] In some implementations, the number of the memory swap policies may be one or more. If the number of memory management policies is one, then, when multiple program groups are obtained, the multiple program groups may be separately memory managed based on the one memory management policy; if the number of memory management policies is multiple, then, when multiple program groups are obtained, the multiple program groups may be separately memory managed based on the multiple memory management policies, wherein the multiple memory management policies may be the same or different, which is not limited here.

[0053] As a detailed implementation, this embodiment can also group multiple processes in an application and perform memory management on the grouped processes. In some implementations, when the operating system of the electronic device is started, a preset configuration file is read from the operating system, the preset configuration file is parsed, a process grouping rule and a memory swap strategy are obtained, and multiple processes running on the electronic device are grouped based on the process grouping rule to obtain multiple process groups, wherein each of the multiple process groups includes at least one process, and memory management is performed on each process group based on the memory swap strategy.

[0054] A memory management method provided in an embodiment of the present application, when the operating system of an electronic device is started, reads a preset configuration file from the operating system, parses the preset configuration file, obtains program grouping rules and memory exchange strategies, groups multiple application programs running on the electronic device based on the program grouping rules, obtains multiple program groups, wherein each of the multiple program groups includes at least one application program, and performs memory management on each program group based on the memory exchange strategy, thereby grouping the running application programs by setting the program grouping rules through the configuration file, and performing memory management on the grouped application programs by using the memory exchange strategy set in the configuration file, which can make memory management more flexible and sophisticated.

[0055] See also Figure 2 , Figure 2 The flowchart of the memory management method provided by an embodiment of the present application is shown in FIG. Figure 2 The process shown is described in detail, and the memory management method may specifically include the following steps:

[0056] Step S210: when the operating system of the electronic device is started, start a target program, wherein the target program is used to group application programs and perform memory management on the grouped application programs.

[0057] In this embodiment, the electronic device may pre-create a target program, wherein the target program may be a memory grouping parsing service program, and the target program is used to group applications and perform memory management on the grouped applications. Optionally, the target program is in a closed state (not started state) by default.

[0058] In some implementations, when the operating system of the electronic device is started, a target program may be started simultaneously to group the application programs and perform memory management on the grouped application programs through the target program.

[0059] Step S220: reading the preset configuration file from the operating system through the target program.

[0060] In some embodiments, when the target program is started, the preset configuration file can be read from the operating system through the target program. Subsequently, the preset configuration file is parsed by the target program to obtain program grouping rules and memory swap strategies, and multiple applications running on the electronic device are grouped by the target program based on the program grouping rules. Finally, the memory of each program group is managed by the target program based on the memory swap strategy.

[0061] Step S230: parsing the preset configuration file through the target program to obtain program grouping rules and memory swap strategies.

[0062] Step S240: grouping the multiple application programs running on the electronic device based on the program grouping rule through the target program to obtain multiple program groups, wherein each program group in the multiple program groups includes at least one application program.

[0063] Step S250: performing memory management on each program group through the target program based on the memory swap strategy.

[0064] For the detailed description of step S230 to step S250 , please refer to step S120 to step S140 , which will not be repeated here.

[0065] The memory management method provided by an embodiment of the present application starts a target program when the operating system of the electronic device is started, wherein the target program is used to group the application programs and perform memory management on the grouped application programs, reads a preset configuration file from the operating system through the target program, parses the preset configuration file through the target program, obtains program grouping rules and memory exchange strategies, and groups multiple application programs running on the electronic device based on the program grouping rules through the target program to obtain multiple program groups, wherein each of the multiple program groups includes at least one application program, and manages each program group based on the memory exchange strategy through the target program. Compared to Figure 1 The memory management method shown in the figure, this embodiment also starts the target program to group the application programs and perform memory management on the grouped application programs, thereby improving the grouping and internal management effects.

[0066] See also Figure 3 , Figure 3 The flowchart of the memory management method provided by an embodiment of the present application is shown. The method is applied to an electronic device. In this embodiment, the number of memory exchange strategies is multiple, and the multiple memory exchange strategies are different. Figure 3 The process shown is described in detail, and the memory management method may specifically include the following steps:

[0067] Step S310: when the operating system of the electronic device is started, read a preset configuration file from the operating system.

[0068] Step S320: Parse the preset configuration file to obtain program grouping rules and memory swap strategies.

[0069] Step S330: Grouping the multiple application programs running on the electronic device based on the program grouping rule to obtain multiple program groups, wherein each program group in the multiple program groups includes at least one application program.

[0070] For the detailed description of step S310 to step S330 , please refer to step S110 to step S130 , which will not be repeated here.

[0071] Step S340: Determine a memory swap strategy that is compatible with each program group from the multiple memory swap strategies.

[0072] Optionally, there are multiple memory swap policies, and the multiple memory swap policies are different. For example, the triggering conditions of the multiple memory swap policies are different, the execution times of the multiple memory swap policies are different, the memory swap amounts of the multiple memory swap policies are different, etc., which are not limited here.

[0073] In some implementations, when multiple memory swap strategies and multiple program groups are obtained, a memory swap strategy adapted to each of the multiple program groups can be determined from the multiple memory swap strategies. Based on this, different memory swap strategies can be set for each program group, providing a more flexible memory management mechanism, and customized management can be performed according to the characteristics of each program group.

[0074] As an example, assume that the multiple memory exchange policies include a first memory exchange policy, a second memory exchange policy, and a third memory exchange policy, wherein the first memory exchange policy, the second memory exchange policy, and the third memory exchange policy are different, and the multiple program groups include a first program group, a second program group, and a third program group. Then, from the first memory exchange policy, the second memory exchange policy, and the third memory exchange policy, a first memory exchange policy adapted to the first program group, a second memory exchange policy adapted to the second program group, and a third memory exchange policy adapted to the third program group can be determined.

[0075] In some embodiments, when multiple memory swap strategies and multiple program groups are obtained, the corresponding characteristics of the multiple program groups (such as video playback characteristics, instant messaging characteristics, information query characteristics, etc.) can be obtained, and based on the corresponding characteristics of the multiple program groups, a memory swap strategy adapted to each program group can be determined from the multiple memory swap strategies.

[0076] In some embodiments, when multiple memory swap strategies and multiple program groups are obtained, the number of applications included in each of the multiple program groups can be obtained, and based on the number of applications included in each of the multiple program groups, a memory swap strategy adapted to each program group can be determined from the multiple memory swap strategies.

[0077] In some embodiments, when multiple memory swap strategies and multiple program groups are obtained, the operating frequencies of the applications included in each of the multiple program groups can be obtained, and based on the operating frequencies of the applications included in each of the multiple program groups, a memory swap strategy adapted to each program group can be determined from the multiple memory swap strategies.

[0078] In some embodiments, when multiple memory swap strategies and multiple program groups are obtained, the running times of the applications included in each of the multiple program groups can be obtained, and based on the running times of the applications included in each of the multiple program groups, a memory swap strategy adapted to each program group can be determined from the multiple memory swap strategies.

[0079] Step S350: performing memory management on each program group based on a memory swap strategy adapted to each program group.

[0080] In this embodiment, after determining the memory swap strategy adapted to each program group, memory management can be performed on each program group based on the memory swap strategy adapted to each program group, thereby achieving customized memory management for different program groups and improving the memory management effects of different program groups.

[0081] The memory management method provided by an embodiment of the present application reads a preset configuration file from the operating system when the operating system of the electronic device is started, parses the preset configuration file, obtains program grouping rules and memory exchange strategies, groups multiple application programs running on the electronic device based on the program grouping rules, obtains multiple program groups, wherein each of the multiple program groups includes at least one application program, determines a memory exchange strategy adapted to each program group from the memory exchange strategy, and performs memory management on each program group based on the memory exchange strategy adapted to each program group. Compared to Figure 1 The memory management method shown in the figure, this embodiment can also set different memory exchange strategies for memory management according to the characteristics of each program group, thereby providing a more flexible memory management mechanism and improving the memory management effect.

[0082] See also Figure 4 , Figure 4The flowchart of the memory management method provided by an embodiment of the present application is shown. The method is applied to an electronic device. For each program group in a plurality of program groups, the following will be directed to Figure 4 The process shown is described in detail, and the memory management method may specifically include the following steps:

[0083] Step S410: when the operating system of the electronic device is started, read a preset configuration file from the operating system.

[0084] Step S420: Parse the preset configuration file to obtain program grouping rules and memory swap strategies.

[0085] Step S430: Grouping the multiple application programs running on the electronic device based on the program grouping rule to obtain multiple program groups, wherein each program group in the multiple program groups includes at least one application program.

[0086] For the detailed description of step S410 to step S430 , please refer to step S110 to step S130 , which will not be repeated here.

[0087] Step S440: If the running state of at least one application program included in the program group changes, triggering execution of the memory swap policy on the program group.

[0088] In this embodiment, when multiple applications running on an electronic device are divided into multiple program groups, the running state of at least one application included in each program group can be detected for each of the multiple program groups to determine whether the running state of at least one application included in each program group has changed. If it is determined that the running state of one or more applications in at least one application included in the program group has changed, it can be determined to trigger the execution of a memory swap strategy for the program group; if it is determined that the running state of at least one application included in the program group has not changed, it can be determined not to trigger the execution of a memory swap strategy for the program group.

[0089] In some implementations, triggering execution of a memory swap policy for the program group may include: swapping out data pages corresponding to the program group from the memory to the Swap Space, or swapping data pages corresponding to the program group from the Swap Space into the memory.

[0090] In some implementations, the memory swap policy can use the policy execution method in Linux, such as updating LRU, identifying the working set, removing active pages, removing inactive pages, specifying the swap destination, etc. This provides a rich memory management policy that can meet various memory usage scenarios.

[0091] As an implementable manner, the change in the running state of at least one application included in the program group may include: at least one application included in the program group switches from running in the foreground of the electronic device to running in the background of the electronic device. It is understandable that because the memory usage characteristics of the application running in the foreground of the electronic device and the application running in the background of the electronic device are often different, different management strategies can be applied to the application running in the foreground of the electronic device and the application running in the background of the electronic device, that is, triggering the execution of the memory exchange strategy. As an implementable manner, when multiple applications running on the electronic device are divided into multiple program groups, for each of the multiple program groups, it is possible to detect whether at least one application included in it switches from running in the foreground of the electronic device to running in the background of the electronic device. For example, a listening program can be registered to detect whether at least one application switches from running in the foreground of the electronic device to running in the background of the electronic device.

[0092] As another practicable manner, the change in the running state of at least one application included in the program group may include: at least one application included in the program group switches from running in the foreground of the electronic device to stopping running. It is understandable that, because the memory usage characteristics of the application running in the foreground of the electronic device and the application stopped running in the electronic device are often different, different management strategies can be applied to the application running in the foreground of the electronic device and the application not running in the electronic device, that is, triggering the execution of the memory exchange strategy. As an practicable manner, when multiple applications running on the electronic device are divided into multiple program groups, for each of the multiple program groups, it is possible to detect whether at least one application included therein switches from running in the foreground of the electronic device to stopping running in the electronic device. For example, a listening program can be registered to detect whether at least one application switches from running in the foreground of the electronic device to stopping running in the electronic device.

[0093] As another practicable manner, the change in the running state of at least one application included in the program group may include: at least one application included in the program group switches from running in the background of the electronic device to running in the foreground of the electronic device. It is understandable that because the memory usage characteristics of the application running in the background of the electronic device and the application running in the foreground of the electronic device are often different, different management strategies can be applied to the application running in the background of the electronic device and the application running in the foreground of the electronic device, that is, triggering the execution of the memory exchange strategy. As an practicable manner, when multiple applications running on the electronic device are divided into multiple program groups, for each of the multiple program groups, it is possible to detect whether at least one application included in it switches from running in the background of the electronic device to running in the foreground of the electronic device. For example, a monitoring program can be registered to detect whether at least one application switches from running in the background of the electronic device to running in the foreground of the electronic device.

[0094] Step S450: If the running state of at least one application program included in the program group changes, triggering execution of the memory swap strategy for the program group after waiting for a preset time.

[0095] In this embodiment, when multiple applications running on an electronic device are divided into multiple program groups, for each of the multiple program groups, the running state of at least one application included in each program group can be detected to determine whether the running state of at least one application included in each program group has changed. If it is determined that the running state of one or more applications in at least one application included in the program group has changed, it can be determined to trigger the execution of a memory swap strategy for the program group after waiting for a preset time; if it is determined that the running state of at least one application included in the program group has not changed, it can be determined not to trigger the execution of a memory swap strategy for the program group. It can be understood that waiting for a preset time to trigger the execution of a memory swap strategy for the program group can prevent unnecessary memory management overhead generated when applications are frequently switched.

[0096] In some embodiments, triggering execution of a memory swap strategy for the program group after waiting for a preset period of time may include: swapping out data pages corresponding to the program group from the memory to the Swap Space after waiting for a preset period of time, or swapping data pages corresponding to the program group from the Swap Space into the memory after waiting for a preset period of time.

[0097] Among them, either step S440 or step S450 can be selected to be executed.

[0098] Step S460: Determine the number of error pages corresponding to at least one application program included in the program group.

[0099] After executing the memory swap strategy, the page refault value corresponding to the application can be monitored. When it exceeds the set threshold, the current memory swap strategy can be stopped, thereby preventing performance degradation caused by excessive memory swapping.

[0100] In this embodiment, after executing the memory swap strategy, the number of error pages corresponding to at least one application included in the program group can be determined. As a way, the electronic device can register a counter, and after executing the memory swap strategy, the number of error pages corresponding to at least one application included in the program group can be determined by the counter.

[0101] As an example, assuming that the program group includes a first application, a second application, and a third application, and the first application corresponds to 3 error pages, the second application corresponds to 2 error pages, and the third application corresponds to 0 error pages. Then, it can be determined that the number of error pages corresponding to at least one application included in the program group is 5.

[0102] In some embodiments, the electronic device may be pre-set with a duration as a preset duration. After executing the memory swap strategy, the number of error pages corresponding to at least one application included in the program group within the preset duration may be determined. Optionally, the preset duration may be fixed after being set, or the preset duration may be dynamically changed after being set, which is not limited here.

[0103] Step S470: If the number of error pages exceeds the number threshold, stop executing the memory swap strategy for the program group.

[0104] In some embodiments, the electronic device may pre-set and store a quantity threshold value, which is used as a basis for judging the number of error pages. Therefore, in this embodiment, when the number of error pages is obtained, the number of error pages can be compared with the quantity threshold value to determine whether the number of error pages exceeds the data threshold value. If it is determined that the number of error pages exceeds the quantity threshold value, the memory swap strategy can be stopped for the program group to prevent performance degradation caused by excessive memory swapping. If it is determined that the number of error pages does not exceed the quantity threshold value, the memory swap strategy can continue to be executed on the program group to improve the memory management effect.

[0105] A memory management method provided in an embodiment of the present application reads a preset configuration file from the operating system when the operating system of the electronic device is started, parses the preset configuration file, obtains program grouping rules and memory exchange strategies, groups multiple applications running on the electronic device based on the program grouping rules, and obtains multiple program groups, wherein each of the multiple program groups includes at least one application, and if the running state of at least one application included in the program group changes, the memory exchange strategy is triggered to be executed on the program group, or if the running state of at least one application included in the program group changes, the memory exchange strategy is executed on the program group after waiting for a preset period of time, and the number of error pages corresponding to at least one application included in the program group is determined. If the number of error pages exceeds a quantity threshold, the memory exchange strategy is stopped to be executed on the program group. Compared to Figure 1 The memory management method shown in this embodiment also triggers the execution of a memory swap strategy when the state of an application in a program group changes to adapt to the state change of the application; or, triggers the execution of a memory swap strategy after waiting for a preset time to prevent unnecessary memory management overhead generated when the application is frequently switched. In addition, after executing the memory swap strategy, if the number of error pages corresponding to the application included in the program group exceeds a quantity threshold, the execution of the memory swap strategy is stopped to reduce the impact on the operation of the application.

[0106] See also Figure 5 , Figure 5 The flowchart of the memory management method provided by an embodiment of the present application is shown in FIG. Figure 5 The process shown is described in detail, and the memory management method may specifically include the following steps:

[0107] Step S510: when the operating system of the electronic device is started, read a preset configuration file from the operating system.

[0108] Step S520: Parse the preset configuration file to obtain program grouping rules and memory swap strategies.

[0109] Step S530: Grouping the multiple application programs running on the electronic device based on the program grouping rule to obtain multiple program groups, wherein each program group in the multiple program groups includes at least one application program.

[0110] For the detailed description of step S510 to step S530 , please refer to step S110 to step S130 , which will not be repeated here.

[0111] Step S540: Obtain the memory occupancy rate of the electronic device.

[0112] In this embodiment, the memory occupancy rate of the electronic device may be obtained.

[0113] In some implementations, the memory occupancy rate of the electronic device may be obtained in real time, at time intervals, at time points, or according to other rules, which are not limited here.

[0114] Optionally, if the memory occupancy rate of the electronic device is obtained at time intervals, the memory occupancy rate of the electronic device may be obtained at fixed time intervals, or the memory occupancy rate of the electronic device may be obtained at exponentially increasing time intervals.

[0115] In some implementations, the electronic device may obtain the memory capacity in advance, and then obtain the memory occupancy of the electronic device, and determine the memory occupancy rate of the electronic device based on the memory occupancy and the memory capacity.

[0116] Step S550: If the memory occupancy rate reaches an occupancy rate threshold, triggering execution of the memory swap strategy for at least one program group among the multiple program groups.

[0117] In some embodiments, the electronic device may pre-set and store an occupancy threshold value, and the occupancy threshold value is used as a basis for judging the memory occupancy of the electronic device. Therefore, in this embodiment, when the memory occupancy of the electronic device is obtained, the memory occupancy rate and the occupancy threshold value may be compared to determine whether the memory occupancy rate reaches the occupancy threshold value. Among them, if it is determined that the memory occupancy rate reaches the occupancy threshold value, it is determined that the memory occupancy of the electronic device is too high, and the data in the memory of the electronic device may be swapped out to the Swap Space to reduce the memory occupancy of the electronic device, that is, triggering the execution of a memory exchange strategy for at least one program group in the multiple program groups to dynamically adjust the memory exchange strategy. If it is determined that the memory occupancy rate does not reach the occupancy threshold value, it is determined that the memory occupancy of the electronic device is low, and the memory exchange strategy may not be executed for multiple program groups.

[0118] The memory management method provided by an embodiment of the present application reads a preset configuration file from the operating system when the operating system of the electronic device is started, parses the preset configuration file, obtains program grouping rules and memory swap strategies, groups multiple application programs running on the electronic device based on the program grouping rules, obtains multiple program groups, wherein each of the multiple program groups includes at least one application program, obtains the memory occupancy rate of the electronic device, and triggers the execution of the memory swap strategy for at least one of the multiple program groups if the memory occupancy rate reaches the occupancy rate threshold. Compared to Figure 1The memory management method shown in this embodiment also triggers the execution of a memory swap strategy when the memory occupancy rate of the electronic device reaches an occupancy rate threshold, thereby avoiding the impact of excessive memory occupancy rate on the operation of the electronic device and improving the operation effect of the electronic device.

[0119] See also Figure 6 , Figure 6 The flowchart of the memory management method provided by an embodiment of the present application is shown in FIG. Figure 6 The process shown is described in detail, and the memory management method may specifically include the following steps:

[0120] Step S610: when the operating system of the electronic device is started, read a preset configuration file from the operating system.

[0121] Step S620: Parse the preset configuration file to obtain program grouping rules and memory swap strategies.

[0122] Step S630: Grouping the multiple application programs running on the electronic device based on the program grouping rule to obtain multiple program groups, wherein each program group in the multiple program groups includes at least one application program.

[0123] For the detailed description of step S610 to step S630 , please refer to step S110 to step S130 , which will not be repeated here.

[0124] Step S640: If there is a newly-added running application on the electronic device, the newly-added running application is added to a first target program group based on the program grouping rule, wherein the first target program group is any one of the multiple program groups.

[0125] In this embodiment, newly created (newly running) applications can also be monitored to determine whether the newly created applications meet the grouping conditions. If so, the newly created applications can be included in the corresponding program group. As an implementable method, it is possible to detect whether there are newly running applications on the electronic device. Optionally, it is possible to detect whether there are newly added applications running in the foreground of the electronic device, and to detect whether there are newly added applications running in the background of the electronic device. If it is detected that there are newly added applications running in the foreground of the electronic device or there are newly added applications running in the background of the electronic device, it can be determined that there are newly running applications on the electronic device.

[0126] In some implementations, the electronic device may register a monitor, and the monitor may be used to detect whether there is a newly-running application on the electronic device.

[0127] If a newly-added running application is detected in the electronic device, the newly-added running application can be added to a first target program group based on the program grouping rule, wherein the first target program group is any one of the multiple program groups. That is, if a newly-added running application is detected in the electronic device, the newly-added running application can be added to a divided program group based on the program grouping rule.

[0128] As an implementable method, if it is detected that there is a newly running application on the electronic device, the characteristics of the newly running application can be determined, and the characteristics corresponding to each of the multiple program groups can be determined, and the characteristics of the newly running application can be compared with the characteristics corresponding to each of the multiple program groups to determine whether the characteristics corresponding to each of the multiple program groups include characteristics that match the characteristics of the newly running application. If so, the newly running application is added to the program group in the multiple program groups that matches its characteristics.

[0129] Step S650: If there is a newly-added application program in the electronic device, the newly-added application program is divided into a second target program group based on the program grouping rule, wherein the second target program group is different from the plurality of program groups.

[0130] If a newly-added running application is detected in the electronic device, the newly-added running application can be added to the second target program group based on the program grouping rule, wherein the second target program group is different from the plurality of program groups. That is, if a newly-added running application is detected in the electronic device, the newly-added running application can be separately classified into a new program group based on the program grouping rule.

[0131] As an implementable method, if it is detected that there is a newly running application on the electronic device, the characteristics of the newly running application can be determined, and the characteristics corresponding to each of the multiple program groups can be determined, and the characteristics of the newly running application can be compared with the characteristics corresponding to each of the multiple program groups to determine whether the characteristics corresponding to each of the multiple program groups include characteristics that match the characteristics of the newly running application. If not, the newly running application will be divided into a new program group (second target program group).

[0132] Among them, one of step S640 and step S650 is selected to be executed.

[0133] Step S660: Based on the memory swap strategy, memory management is performed on each program group.

[0134] For the detailed description of step S660, please refer to step S140, which will not be repeated here.

[0135] A memory management method provided in an embodiment of the present application reads a preset configuration file from the operating system when the operating system of the electronic device is started, parses the preset configuration file, obtains program grouping rules and memory exchange strategies, and groups multiple applications running on the electronic device based on the program grouping rules to obtain multiple program groups, wherein each of the multiple program groups includes at least one application, and if there is a newly running application on the electronic device, then the newly running application is added to a first target program group based on the program grouping rules, wherein the first target program group is any one of the multiple program groups; or, if there is a newly running application on the electronic device, then the newly running application is divided into a second target program group based on the program grouping rules, wherein the second target program group is different from the multiple program groups. Compared to Figure 1 The memory management method shown in this embodiment also automatically groups the applications when there are newly-added applications running on the electronic device, thereby ensuring the running effect of the newly-added applications.

[0136] See also Figure 7 , Figure 7 The flowchart of the memory management method provided by an embodiment of the present application is shown in FIG. Figure 7 The process shown is described in detail, and the memory management method may specifically include the following steps:

[0137] Step S710: when the operating system of the electronic device is started, read a preset configuration file from the operating system.

[0138] Step S720: Parse the preset configuration file to obtain program grouping rules and memory swap strategies.

[0139] Step S730: Grouping the multiple application programs running on the electronic device based on the program grouping rule to obtain multiple program groups, wherein each program group in the multiple program groups includes at least one application program.

[0140] Step S740: Based on the memory swap strategy, memory management is performed on each program group.

[0141] For the detailed description of step S710 to step S740, please refer to step S110 to step S140, which will not be repeated here.

[0142] Step S750: Update the preset configuration file.

[0143] In this embodiment, the preset configuration file may also be updated, that is, the preset configuration file may be dynamically updated to adjust the memory management policy.

[0144] In some embodiments, the electronic device may automatically update the preset configuration file, or the electronic device may update the preset configuration file in response to an input update instruction. Optionally, if the electronic device automatically updates the preset configuration file, the electronic device may update the preset configuration file at a preset time interval, may update the preset configuration file at a preset time point, may update the preset configuration file when the environment where the electronic device is located meets the preset environment (such as the environment text meets the preset temperature, the environment location meets the preset location, the environment humidity meets the preset humidity, the environment brightness meets the preset brightness, the environment signal strength meets the preset signal strength, etc.), etc., which is not limited here.

[0145] As an implementable manner, updating the preset configuration file may include: receiving an input update instruction, and updating the preset configuration file in response to the update instruction, based on which the memory management strategy may be adjusted according to user needs to improve the user experience. Optionally, the input update instruction may include: an input voice update instruction, an input text update instruction, an input picture update instruction, an input touch update instruction, etc., which are not limited here.

[0146] As one approach, an input update instruction is received, the update instruction is parsed, an update parameter carried by the update instruction is obtained, and in response to the update instruction, a preset configuration file is updated based on the update parameter.

[0147] As another practicable manner, updating the preset configuration file may include: obtaining operation parameters corresponding to multiple applications running on the electronic device, and updating the preset configuration file based on the operation parameters, based on which the memory management strategy can be adjusted according to the real-time behavior of the application, and the operation effect of the application can be improved. Optionally, the operation parameters corresponding to the application may include: the operation fluency corresponding to the application, the display content corresponding to the application, the type of display content corresponding to the application, the loading speed corresponding to the application, etc., which are not limited here.

[0148] The memory management method provided in an embodiment of the present application reads a preset configuration file from the operating system of the electronic device when the operating system of the electronic device is started, parses the preset configuration file, obtains program grouping rules and memory swap strategies, groups multiple application programs running on the electronic device based on the program grouping rules, obtains multiple program groups, wherein each of the multiple program groups includes at least one application program, performs memory management on each program group based on the memory swap strategy, and updates the preset configuration file. Figure 1 The memory management method shown in this embodiment also updates the configuration file, so that the memory management strategy can be adjusted in real time to improve the memory management effect.

[0149] In some implementations, the memory management method provided in this embodiment can be applied to cloud computing scenarios to improve the operating efficiency of the server by finely managing the memory usage of the virtual machine.

[0150] In some implementations, the memory management method provided in this embodiment may be applied in embedded systems. Since these systems often have limited memory, the memory management method may be used more effectively for memory resources.

[0151] In some implementations, the memory management method provided in this embodiment can be applied to a gaming device. By performing different memory management on different scenes within the game, the running efficiency of the game can be improved.

[0152] In some implementations, the memory management method provided in this embodiment can be applied in a real-time system to ensure real-time performance by performing memory management with priority on real-time tasks.

[0153] In some implementations, the memory management method provided in this embodiment can be applied to IoT devices. By performing different memory management on different devices, the overall network performance can be improved.

[0154] See also Figure 8 , Figure 8 The module block diagram of the memory management device provided by an embodiment of the present application is shown. The memory management device 200 is applied to the above electronic device. Figure 8 The block diagram shown in the figure is used to illustrate that the memory management device 200 includes: a configuration file reading module 210, a configuration file parsing module 220, an application grouping module 230 and a memory management module 240, wherein:

[0155] The configuration file reading module 210 is used to read a preset configuration file from the operating system when the operating system of the electronic device is started.

[0156] Furthermore, the configuration file reading module 210 includes: a target program starting submodule and a configuration file reading submodule, wherein:

[0157] The target program startup submodule is used to start the target program when the operating system of the electronic device is started, wherein the target program is used to group the application programs and perform memory management on the grouped application programs.

[0158] The configuration file reading submodule is used to read the preset configuration file from the operating system through the target program.

[0159] The configuration file parsing module 220 is used to parse the preset configuration file to obtain program grouping rules and memory swap strategies.

[0160] The application grouping module 230 is used to group the multiple applications running on the electronic device based on the program grouping rule to obtain multiple program groups, wherein each of the multiple program groups includes at least one application.

[0161] Furthermore, the application grouping module 230 includes: a first grouping submodule, a second grouping submodule, a third grouping submodule and a fourth grouping submodule, wherein:

[0162] The first grouping submodule is used to group multiple applications running on the electronic device based on the names of the applications.

[0163] The second grouping submodule is used to group the multiple applications running on the electronic device based on the identification codes of the applications.

[0164] The third grouping submodule is used to group the multiple applications running on the electronic device based on the version numbers of the applications.

[0165] The fourth grouping submodule is used to group multiple applications running on the electronic device based on wildcards of the applications.

[0166] The memory management module 240 is used to perform memory management on each program group based on the memory swap policy.

[0167] Furthermore, the number of the memory exchange strategies is multiple, and the multiple memory exchange strategies are different. The memory management module 240 includes: a memory exchange strategy determination submodule and a first memory management submodule, wherein:

[0168] The memory swap strategy determination submodule is used to determine a memory swap strategy adapted to each program group from the multiple memory swap strategies.

[0169] The first memory management submodule is used to perform memory management on each program group based on a memory swap strategy adapted to each program group.

[0170] Further, for each program group, the memory management module 240 includes: a second memory management submodule and a third memory management submodule, wherein:

[0171] The second memory management submodule is configured to trigger execution of the memory swap strategy on the program group if the running state of at least one application program included in the program group changes.

[0172] Furthermore, the second memory management submodule includes: a first state change determination unit, a second state change determination unit and a third state change determination unit, wherein:

[0173] The first state change determining unit is used to switch at least one application program included in the program group from running in the foreground of the electronic device to running in the background of the electronic device.

[0174] The second state change determining unit is used to switch at least one application program included in the program group from running in the foreground of the electronic device to stopping running.

[0175] The third state change determining unit is used to switch at least one application program included in the program group from running in the background of the electronic device to running in the foreground of the electronic device.

[0176] The third memory management submodule is used to trigger the execution of the memory swap strategy for the program group after waiting for a preset time if the running state of at least one application program included in the program group changes.

[0177] Furthermore, the memory management module 240 further includes: a quantity determination submodule and a stop submodule, wherein:

[0178] The quantity determination submodule is used to determine the quantity of error pages corresponding to at least one application program included in the program group.

[0179] The stop submodule is used to stop executing the memory swap strategy on the program group if the number of error pages exceeds a number threshold.

[0180] Furthermore, the memory management module 240 includes: a memory occupancy acquisition submodule and a fourth memory management submodule, wherein:

[0181] The memory occupancy rate acquisition submodule is used to acquire the memory occupancy rate of the electronic device.

[0182] Furthermore, the memory occupancy acquisition submodule includes: a first memory occupancy acquisition unit and a second memory occupancy acquisition unit, wherein:

[0183] The first memory occupancy rate acquisition unit is used to acquire the memory occupancy rate of the electronic device at fixed time intervals.

[0184] The second memory occupancy rate acquisition unit is used to acquire the memory occupancy rate of the electronic device at an exponentially increasing time interval.

[0185] The fourth memory management submodule is configured to trigger execution of the memory swap strategy on at least one program group among the multiple program groups if the memory occupancy reaches an occupancy threshold.

[0186] Furthermore, the memory management device 200 further includes: a first grouping module and a second grouping module, wherein:

[0187] The first grouping module is used to add a newly running application to a first target program group based on the program grouping rule if there is a newly running application in the electronic device, wherein the first target program group is any one of the multiple program groups.

[0188] The second grouping module is used to classify a newly-running application program into a second target program group based on the program grouping rule if the electronic device has a newly-running application program, wherein the second target program group is different from the multiple program groups.

[0189] Furthermore, the memory management device 200 further includes: an update module, wherein:

[0190] An updating module is used to update the preset configuration file.

[0191] Further, the update module includes: an update instruction receiving submodule and a first update submodule, wherein:

[0192] The update instruction receiving submodule is used to receive input update instructions.

[0193] The first updating submodule is used to update the preset configuration file in response to the updating instruction.

[0194] Furthermore, the update module includes: an operation parameter acquisition submodule and a second update submodule, wherein:

[0195] The operating parameter acquisition submodule is used to acquire operating parameters corresponding to multiple application programs running on the electronic device.

[0196] The second updating submodule is used to update the preset configuration file based on the operating parameters.

[0197] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the above-described devices and modules can refer to the corresponding processes in the aforementioned method embodiments, and will not be repeated here.

[0198] In several embodiments provided in the present application, the coupling between modules may be electrical, mechanical or other forms of coupling.

[0199] In addition, each functional module in each embodiment of the present application can be integrated into a processing module, or each module can exist physically separately, or two or more modules can be integrated into one module. The above integrated modules can be implemented in the form of hardware or software functional modules.

[0200] See also Fig. 9 , which shows a structural block diagram of an electronic device 100 provided in an embodiment of the present application. The electronic device 100 may be an electronic device capable of running applications, such as a smart phone, a tablet computer, an e-book, etc. The electronic device 100 in the present application may include one or more of the following components: a processor 110, a memory 120, and one or more applications, wherein the one or more applications may be stored in the memory 120 and configured to be executed by one or more processors 110, and the one or more programs are configured to execute the method described in the aforementioned method embodiment.

[0201] Among them, the processor 110 may include one or more processing cores. The processor 110 uses various interfaces and lines to connect various parts of the entire electronic device 100, and executes various functions and processes data of the electronic device 100 by running or executing instructions, programs, code sets or instruction sets stored in the memory 120, and calling data stored in the memory 120. Optionally, the processor 110 can be implemented in at least one hardware form of digital signal processing (Digital Signal Processing, DSP), field programmable gate array (Field-Programmable Gate Array, FPGA), and programmable logic array (Programmable Logic Array, PLA). The processor 110 can integrate one or a combination of a central processing unit (Central Processing Unit, CPU), a graphics processing unit (Graphics Processing Unit, GPU) and a modem. Among them, the CPU mainly processes the operating system, user interface and application programs; the GPU is responsible for rendering and drawing the content to be displayed; and the modem is used to process wireless communications. It can be understood that the above-mentioned modem may not be integrated into the processor 110, but may be implemented separately through a communication chip.

[0202] The memory 120 may include a random access memory (RAM) or a read-only memory (ROM). The memory 120 may be used to store instructions, programs, codes, code sets or instruction sets. The memory 120 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for implementing functions (such as a touch function, a sound playback function, an image playback function, etc.), instructions for implementing the following various method embodiments, etc. The data storage area may also store data (such as a phone book, audio and video data, chat record data) created by the electronic device 100 during use.

[0203] See also Fig.10 , which shows a structural block diagram of a computer-readable storage medium provided in an embodiment of the present application. The computer-readable medium 300 stores program codes, which can be called by a processor to execute the method described in the above method embodiment.

[0204] The computer readable storage medium 300 may be an electronic memory such as a flash memory, an EEPROM (electrically erasable programmable read-only memory), an EPROM, a hard disk, or a ROM. Optionally, the computer readable storage medium 300 includes a non-transitory computer-readable storage medium. The computer readable storage medium 300 has storage space for program code 310 that performs any method steps in the above method. These program codes can be read from or written to one or more computer program products. The program code 310 can be compressed, for example, in an appropriate form.

[0205] In summary, the memory management method, device, electronic device and storage medium provided in the embodiments of the present application, when the operating system of the electronic device is started, reads a preset configuration file from the operating system, parses the preset configuration file, obtains program grouping rules and memory exchange policies, and groups multiple applications running on the electronic device based on the program grouping rules to obtain multiple program groups, wherein each of the multiple program groups includes at least one application, and performs memory management on each program group based on the memory exchange policy, so that the running applications are grouped by setting the program grouping rules through the configuration file, and the grouped applications are memory managed by the memory exchange policy set in the configuration file, which can make memory management more flexible and sophisticated.

[0206] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present application.

Claims

1. A memory management method, characterized in that: Applied to electronic equipment, the method comprises: When the operating system of the electronic device is started, reading a preset configuration file from the operating system; Parsing the preset configuration file to obtain program grouping rules and memory swap strategies; Grouping a plurality of application programs running on the electronic device based on the program grouping rule to obtain a plurality of program groups, wherein each of the plurality of program groups includes at least one application program; Based on the memory swap strategy, memory management is performed on each program group.

2. The method according to claim 1, characterized in that When the operating system of the electronic device is started, reading a preset configuration file from the operating system includes: When the operating system of the electronic device is started, a target program is started, wherein the target program is used to group application programs and perform memory management on the grouped application programs; The preset configuration file is read from the operating system through the target program.

3. The method according to claim 1, characterized in that The number of the memory swap strategies is multiple, and the multiple memory swap strategies are different. The memory management of each program group based on the memory swap strategy includes: Determining a memory swap strategy adapted to each program group from the multiple memory swap strategies; Memory management is performed on each program group based on a memory swap strategy adapted to each program group.

4. The method according to claim 1, characterized in that: For each program group, performing memory management on each program group based on the memory swap strategy includes: If the running state of at least one application program included in the program group changes, triggering execution of the memory swap strategy for the program group; or If the running state of at least one application program included in the program group changes, the memory swap strategy is triggered to be executed on the program group after waiting for a preset time.

5. The method according to claim 4, characterized in that The running state of at least one application program included in the program group changes, including: At least one application program included in the program group is switched from running in the foreground of the electronic device to running in the background of the electronic device; or At least one application program included in the program group is switched from running in the foreground of the electronic device to stopping running; or At least one application program included in the program group is switched from running in the background of the electronic device to running in the foreground of the electronic device.

6. The method according to claim 4, characterized in that After executing the memory swap strategy on the program group, the method further includes: determining the number of error pages corresponding to at least one application program included in the program group; If the number of error pages exceeds a number threshold, execution of the memory swap strategy on the program group is stopped.

7. The method according to claim 1, characterized in that The performing memory management on each program group based on the memory exchange strategy includes: Obtaining a memory occupancy rate of the electronic device; If the memory occupancy rate reaches an occupancy rate threshold, the memory swap strategy is triggered to be executed on at least one program group among the multiple program groups.

8. The method according to claim 7, characterized in that The obtaining of the memory occupancy rate of the electronic device includes: Obtaining the memory occupancy rate of the electronic device at fixed time intervals; or The memory occupancy rate of the electronic device is obtained at exponentially increasing time intervals.

9. The method according to claim 1, characterized in that: After grouping the multiple application programs running on the electronic device based on the program grouping rule to obtain multiple program groups, the method further includes: If there is a newly-running application program on the electronic device, adding the newly-running application program to a first target program group based on the program grouping rule, wherein the first target program group is any one of the multiple program groups; or If there is a newly-running application program in the electronic device, the newly-running application program is divided into a second target program group based on the program grouping rule, wherein the second target program group is different from the plurality of program groups.

10. The method according to claim 1, characterized in that The method further comprises: The preset configuration file is updated.

11. The method according to claim 10, characterized in that The updating of the preset configuration file includes: receiving input update instructions; The preset configuration file is updated in response to the update instruction.

12. The method according to claim 10, characterized in that The updating of the preset configuration file includes: Obtaining operating parameters corresponding to a plurality of application programs running on the electronic device; The preset configuration file is updated based on the operating parameters.

13. The method according to any one of claims 1 to 12, characterized in that: The grouping of the plurality of application programs running on the electronic device based on the program grouping rule comprises: Grouping multiple applications running on the electronic device based on the names of the applications; and / or Grouping multiple applications running on the electronic device based on identification codes of the applications; and / or Grouping multiple applications running on the electronic device based on version numbers of the applications; and / or A plurality of applications running on the electronic device are grouped based on wildcards of the applications.

14. A memory management device, characterized in that: Applied to electronic equipment, the device comprises: A configuration file reading module, used for reading a preset configuration file from the operating system when the operating system of the electronic device is started; A configuration file parsing module, used to parse the preset configuration file to obtain program grouping rules and memory exchange strategies; an application grouping module, configured to group the plurality of application programs running on the electronic device based on the program grouping rule to obtain a plurality of program groups, wherein each of the plurality of program groups includes at least one application program; A memory management module is used to perform memory management on each program group based on the memory exchange strategy.

15. An electronic device, characterized in that: The method comprises a memory and a processor, wherein the memory is coupled to the processor, the memory stores instructions, and when the instructions are executed by the processor, the processor executes the method according to any one of claims 1 to 13.

16. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores program codes, which can be called by a processor to execute the method according to any one of claims 1 to 13.