Memory cleaning method and device, equipment and storage medium
By monitoring the memory resources and application requirements of smart devices, identifying and cleaning up the background running programs, the problem of insufficient device memory causes the application to fail to start or crash, and improves the user experience.
Patent Information
- Application Number
- CN202411373447.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-29
- Publication Date
- 2025-03-07
AI Technical Summary
When smart devices are out of memory, the application may fail to start or crash, affecting the user experience.
By monitoring the user to click on the target application, the amount of memory resources available to the device and the memory requirements of the target application are obtained. When the memory is insufficient, the application status is used to identify the background running program to be cleaned and cleaned to free up memory.
Effectively ensure the smooth start and smooth operation of the target application, while maximizing the background programs that users may need, improving the user experience.
Smart Images

Figure CN119576519A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of application management technology, and in particular to a memory cleaning method, device, equipment and storage medium. Background Art
[0002] With the development of technology, smart devices such as smartphones and tablets have become indispensable. In order to allow users to enjoy more functions, many applications and services will be installed on these devices. However, when these programs and services are running at the same time, they will occupy a large amount of storage space and running memory of smart devices, just like a room in your home is full of things, making it difficult to walk. As a result, smart devices will become slow and unsmooth when used, affecting the overall user experience. Even when the device memory is extremely insufficient, the application may not open or crash. This problem needs to be solved urgently. Summary of the invention
[0003] The embodiment of the present invention provides a memory cleaning method, which aims to solve the problem that the application cannot be opened or crashes when the device memory is extremely insufficient. The available memory resources of the device and the target memory requirement of the target application can be obtained by monitoring when the user clicks on the target application. When the available memory resources of the device are insufficient, the application status in the device is used to accurately identify the background running programs to be cleaned up, which can effectively release memory resources, ensure the smooth startup and smooth operation of the target application, and retain the background programs that the user may need to the maximum extent, thereby improving the user experience.
[0004] In a first aspect, an embodiment of the present invention provides a memory cleaning method, the method comprising:
[0005] When detecting that a user clicks on a target application, obtaining available memory resources of a device and a target memory requirement required by the target application;
[0006] If the available memory resource of the device is less than the target memory requirement, obtaining the application status in the device, the application status including the memory usage corresponding to the background running program;
[0007] Based on the application state, determining a memory cleaning strategy, the memory cleaning strategy including at least one background running program to be cleaned up;
[0008] The background running programs to be cleaned are cleaned up by using the memory cleaning strategy, so that the available memory resources of the device are greater than the target memory resources.
[0009] Optionally, the step of determining a memory cleanup strategy based on the application state includes:
[0010] Based on the memory usage corresponding to the background running program, determining whether there is a single application program in the background running program whose memory usage is greater than the target memory requirement;
[0011] If there is a single application whose memory usage is greater than the target memory requirement, the single application is determined as the background running program to be cleared;
[0012] If there is no single application whose memory usage is greater than the target memory requirement, at least two background running programs to be cleared are determined from the background running programs.
[0013] Optionally, the step of determining at least two background running programs to be cleared from the background running programs includes:
[0014] Combining the background running programs to obtain a plurality of application combinations, wherein the total memory usage corresponding to each application combination is greater than the target memory requirement;
[0015] The background running programs to be cleaned up are determined from the plurality of application programs.
[0016] Optionally, the step of combining the background running programs to obtain a combination of multiple application programs includes:
[0017] Determine the type of the background running program;
[0018] Based on the principle that the types of the background running programs are different and the goal that the total memory usage corresponding to each application combination is greater than the target memory requirement, the background running programs are selected for combination to obtain a plurality of the application combinations.
[0019] Optionally, the application state further includes the background running time corresponding to the background running program, and the step of determining the background running program to be cleared from the plurality of application combinations includes:
[0020] Determining the total background running time of each application combination according to the background running time corresponding to the background running program;
[0021] Based on the total background running time, the background running programs to be cleaned up are determined from the plurality of application combinations.
[0022] Optionally, the step of determining the background running program to be cleaned up in the combination of multiple application programs includes:
[0023] Determine the total memory usage corresponding to each application combination according to the memory usage corresponding to the background running program;
[0024] Based on the total memory usage, the background running programs to be cleaned up are determined from the plurality of application combinations.
[0025] Optionally, the application state further includes a background running time corresponding to a background running program, and the step of determining a memory cleanup strategy based on the application state includes:
[0026] Building a memory clearing model based on the background running time corresponding to the background running program, the memory usage corresponding to the background running program, and the type corresponding to the background running program;
[0027] Solving the memory clearing model to obtain an optimal clearing solution for the background running program;
[0028] Based on the optimal clearing solution, at least one background running program to be cleared is determined.
[0029] In a second aspect, an embodiment of the present invention further provides a memory cleaning device, the memory cleaning device comprising:
[0030] A first acquisition module is used to monitor when a user clicks on a target application and acquire the available memory resources of the device and the target memory requirement required by the target application;
[0031] A second acquisition module is used to acquire the application status in the device if the available memory resource of the device is less than the target memory requirement, wherein the application status includes the memory usage corresponding to the background running program;
[0032] A processing module, configured to determine a memory cleaning strategy based on the application state, wherein the memory cleaning strategy includes at least one background running program to be cleaned up;
[0033] The cleaning module is used to clean up the background running programs to be cleaned up according to the memory cleaning strategy, so that the available memory resources of the device are greater than the target memory resources.
[0034] In a third aspect, an embodiment of the present invention provides an electronic device, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the memory cleaning method provided in the embodiment of the present invention when executing the computer program.
[0035] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the memory cleaning method provided in the embodiment of the invention are implemented.
[0036] In an embodiment of the present invention, when it is detected that a user clicks on a target application, the available memory resource amount of the device and the target memory requirement amount required by the target application are obtained; if the available memory resource amount of the device is less than the target memory requirement amount, the application state in the device is obtained, and the application state includes the memory occupancy amount corresponding to the background running program; based on the application state, a memory cleanup strategy is determined, and the memory cleanup strategy includes at least one background running program to be cleaned; the background running program to be cleaned is cleaned by the memory cleanup strategy, so that the available memory resource amount of the device is greater than the target memory resource amount. The present invention obtains the available memory resource amount of the device and the target memory requirement amount required by the target application when the user clicks on the target application. When the available memory resource amount of the device is insufficient, the application state in the device is used to accurately identify the background running program to be cleaned, which can effectively release memory resources, ensure the smooth startup and smooth operation of the target application, and can also retain the background programs that the user may need to the maximum extent, thereby improving the user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0038] Figure 1 is a flow chart of a memory cleaning method provided by an embodiment of the present invention;
[0039] Figure 2 It is a structural schematic diagram of a memory cleaning device provided by an embodiment of the present invention;
[0040] Figure 3 It is a structural schematic diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0041] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0042] like Figure 1 As shown, Figure 1 : is a method flow chart of a memory cleaning method provided by an embodiment of the present invention. The memory cleaning method comprises the steps of:
[0043] 101. When it is detected that the user clicks on the target application, the available memory resources of the device and the target memory requirement required by the target application are obtained.
[0044] In an embodiment of the present invention, the above-mentioned device is a smart device, such as a smart phone, a tablet computer, an interactive robot, etc. The above-mentioned smart device has an application installed therein, and the application can run on the front end or hang in the background. The above-mentioned smart device can interact with the user through the display screen, and the application icon of each application is displayed on the screen. The user can click the application image by touch or an external device to open the corresponding application.
[0045] When it is detected that the user clicks on the target application, the amount of available memory resources of the current device can be obtained. Specifically, the amount of available memory resources can be obtained by calling the API interface provided by the operating system. It should be noted that each application will occupy corresponding memory resources after startup, and will also occupy part of the memory resources when suspended in the background. Therefore, the amount of available memory resources of the above-mentioned device is used to indicate the remaining amount of memory resources in the device. When the remaining amount of memory resources in the device is not enough to start other applications that require larger memory resources, the memory cleaning method in this embodiment is started.
[0046] The target memory requirement required for starting and running the target application can be estimated based on the application's operating parameters. In a possible embodiment, the target memory requirement can also be calculated based on the application's historical operating data, current task requirements, and possible memory consumption patterns.
[0047] 102. If the available memory resource of the device is less than the target memory requirement, obtain the application status in the device.
[0048] In the embodiment of the present invention, the above application status can be understood as a set of information including multiple dimensions, which can include the memory usage corresponding to the background running program. The above application status can be obtained through the task management module of the operating system or similar system services. In addition to the memory usage, the application status may also include the running time and type of the program (such as shopping program, entertainment program, service program, etc.).
[0049] After obtaining the available memory resources of the device and the target memory requirement of the target application, the available memory resources can be compared with the target memory requirement. If the available memory resources are less than the target memory requirement, it can be said that the current memory is insufficient to support the normal operation of the target application. At this time, it is necessary to further obtain the application status in the device in order to decide how to release the device's memory.
[0050] Furthermore, the background running program is an application program suspended in the background, and the application state may include the memory usage corresponding to the background running program, and may also include the background running time of the background running program and the type of the background running program. The application state may be obtained based on the log file of the corresponding background running program. The memory usage may be the amount of memory resources occupied by the application when it is suspended in the background.
[0051] 103. Determine a memory cleanup strategy based on the application state.
[0052] In an embodiment of the present invention, the above-mentioned application status may include the memory usage corresponding to the background running programs. The background running programs whose memory usage is greater than or equal to the target memory requirement may be formed into a list and provided to the user for selection. The user selects one or more background running programs from the list, and the one or more background running programs selected by the user are used as the background running programs to be cleaned, thereby obtaining a memory cleaning strategy, which includes at least one background running program to be cleaned.
[0053] In a possible embodiment, background running programs whose memory usage is greater than or equal to the target memory requirement can be formed into a first list, and background running programs whose memory usage is less than the target memory requirement can be formed into a second list. The first list and the second list are provided to the user for selection. The user selects one or more background running programs in the first list or the second list, and the one or more background running programs selected by the user are used as the background running programs to be cleaned, so as to obtain a memory cleaning strategy, and the memory cleaning strategy includes at least one background running program to be cleaned.
[0054] Of course, it should be noted that, based on the above application status, other existing methods can also be used to determine the memory cleanup strategy of the device.
[0055] 104. Clean up background running programs in the device through a memory cleaning strategy, so that the amount of available memory resources to be cleaned is greater than the target memory resource amount.
[0056] In an embodiment of the present invention, after obtaining the memory clearing strategy, the background running programs to be cleared in the memory clearing strategy are cleared to release memory resources. The released amount of memory resources is added to the original amount of available memory resources to obtain new available memory resources. The new available memory resources are greater than the target amount of memory resources. Memory resources corresponding to the target amount of memory resources are allocated from the new available memory resources to start and run the target application.
[0057] In an embodiment of the present invention, when it is detected that a user clicks on a target application, the available memory resource amount of the device and the target memory requirement amount required by the target application are obtained; if the available memory resource amount of the device is less than the target memory requirement amount, the application state in the device is obtained, and the application state includes the memory occupancy amount corresponding to the background running program; based on the application state, a memory cleaning strategy is determined, and the memory cleaning strategy includes at least one background running program to be cleaned; the background running program to be cleaned is cleaned by the memory cleaning strategy, so that the available memory resource amount of the device is greater than the target memory resource amount. The present invention obtains the available memory resource amount of the device and the target memory requirement amount required by the target application when the user clicks on the target application. When the available memory resource amount of the device is insufficient, the application state in the device is used to selectively identify the background running program to be cleaned, which can effectively release memory resources, ensure the smooth startup and smooth operation of the target application, and can also retain the background programs that the user may need to the maximum extent, thereby improving the user experience.
[0058] It is understandable that in the specific implementation of this application, application data, user data and other related data are involved. When the embodiments in this application are applied to specific products or technologies, user permission or consent is required, and the collection, use and processing of relevant data, as well as model training, deployment and use, must comply with relevant laws, regulations and standards of relevant countries and regions.
[0059] Optionally, in the step of determining a memory clearing strategy based on the application status, it can be determined whether there is a single application in the background running programs whose memory usage is greater than the target memory requirement based on the memory usage corresponding to the background running programs; if there is a single application whose memory usage is greater than the target memory requirement, the single application is determined as the background running program to be cleared; if there is no single application whose memory usage is greater than the target memory requirement, at least two background running programs to be cleared are determined among the background running programs.
[0060] In the embodiment of the present invention, when the available memory resource amount of the device is less than the target memory requirement amount, the application state in the device is further obtained, and the application state includes the memory usage corresponding to the background running program.
[0061] The memory usage of a single application can be detected. Specifically, all programs running in the background can be traversed, and the memory usage of each background program can be detected to find out whether there is a background program whose memory usage alone exceeds the memory required by the target application. If there is a background program whose memory usage alone exceeds the memory required by the target application, then the background program will be directly determined as the background program to be cleaned up. This can be simple and direct, and a large amount of memory resources can be quickly released.
[0062] If there are multiple background running programs whose memory usage exceeds the memory required by the target application, these background running programs can be put into a list and provided to the user for selection, and the background running program selected by the user is determined as the background running program to be cleaned up. In the list, the background running programs can be sorted by the size of the memory usage, which can more intuitively display the memory usage of each background running program, facilitate user selection, and improve user experience. Of course, in this case, the background running time of the background running program can also be obtained, and the background running programs can be sorted by the length of the background running time, which can more intuitively display the idle time of each background running program, facilitate user selection, and improve user experience.
[0063] If the memory usage of no single background program exceeds the target memory requirement, you can consider cleaning up multiple background programs to free up enough memory. Specifically, you can combine multiple background programs to find the best combination that meets the memory cleaning requirement.
[0064] Specifically, the memory usage of background programs can be obtained through the operating system API interface or a specific memory monitoring tool (log file). Memory usage information is usually counted in units of processes and includes key indicators such as the current memory usage and peak memory usage of background programs.
[0065] When traversing background running programs, you can first sort the background running programs according to the memory usage, and then check the memory usage of each background running program in turn. This can help you find the background running programs with large memory usage more quickly and improve traversal efficiency.
[0066] Optionally, in the step of determining at least two background running programs to be cleaned up among the background running programs, the background running programs can be combined to obtain multiple application combinations, and the total memory usage corresponding to each application combination is greater than the target memory requirement; among the multiple application combinations, the background running programs to be cleaned up are determined.
[0067] In an embodiment of the present invention, the above combination processing refers to combining multiple background running programs according to certain rules or conditions to form multiple possible application combinations. Each application combination represents a group of background running programs, and the total memory usage of each application combination must be greater than the target memory requirement required by the target application. The total memory usage of the application combination is the sum of the memory usage of all background running programs in the application combination. The application combination includes at least two background running programs.
[0068] Specifically, all programs running in the background can be classified. The basis for classification can be the function, purpose, importance, etc. of the program. The purpose of classification is to be able to match the programs more reasonably in subsequent combinations and avoid clearing out key programs that have a greater impact on user experience.
[0069] Based on the classification, application combinations are generated. The goal of the combination is to ensure that the total memory usage of each combination is greater than the target memory requirement. This can be achieved by traversing all possible combinations, or by using greedy algorithms, dynamic programming, etc. to quickly find combinations that meet the conditions.
[0070] After generating multiple application combinations, you can further filter them to determine the final programs to be cleaned up. The basis for filtering can be at least one of the total memory usage of the combination, the program's running time, and the program type. For example, you can give priority to cleaning up those program combinations that have a large memory usage and a long running time.
[0071] In a possible embodiment, the type of program also needs to be considered when combining and filtering. For example, some system-level background services or key applications may not be suitable for cleaning, even if they occupy a large amount of memory. Therefore, a whitelist or blacklist can be maintained to specify which applications can be cleaned and which applications need to be retained.
[0072] Optionally, in the step of combining the background running programs to obtain multiple application combinations, the types of the background running programs can be determined; based on the principle that the types of background running programs are different and with the goal that the total memory usage corresponding to each application combination is greater than the target memory requirement, background running programs are selected for combination to obtain multiple application combinations.
[0073] In an embodiment of the present invention, the type of the program running in the background can be determined according to the type label of the application program, and the type label of the application program can be obtained according to the application store or user customization. All programs running in the background can be classified. The basis for classification can be the function, purpose, importance, etc. of the program.
[0074] In order to avoid the loss of comprehensiveness of application types or the decline of user experience due to the cleaning of applications of the same type, the combination can be carried out according to the principle of different types. Specifically, when building an application combination, an application combination should contain different types of background running programs to ensure diversity and comprehensiveness after cleaning. For example, the background running programs in an application combination cannot be applications of the same type. For example, two shopping applications cannot be combined as an application, which will cause the two shopping applications to be cleared together. If the two shopping applications are cleared together, when the user still wants to shop, the shopping software needs to be restarted, which affects the user's shopping experience. Therefore, combining according to the principle of different types can guarantee the user experience to a certain extent.
[0075] After determining the diversity of the combination types, the combination whose total memory usage is greater than the target memory requirement can be screened out from all possible combinations according to the target memory requirement. The memory usage of each background running program is calculated, the memory usage is combined and added, and the combination whose total memory usage is greater than the target memory requirement is determined as a qualified application combination.
[0076] In order to achieve efficient combinatorial processing, it is necessary to design an intelligent algorithm that can quickly generate combinations that meet the conditions based on memory usage and type diversity. This may involve optimization techniques such as greedy algorithms and dynamic programming to ensure that the optimal solution or a near-optimal solution is found within a limited time.
[0077] In a possible embodiment, considering the handling of abnormal situations, for example, if a critical system process that cannot be cleaned up is encountered, or an application program that is explicitly marked as uncleanable by the user, it will not be added to the application program combination.
[0078] By combining the background running programs, memory resources can be effectively released without affecting the user experience, ensuring the smooth operation of the target application.
[0079] Optionally, the application status also includes the background running time corresponding to the background running programs. In the step of determining the background running programs to be cleared among multiple application combinations, the total background running time of each application combination can be determined according to the background running time corresponding to the background running programs; based on the total background running time, the background running programs to be cleared are determined among multiple application combinations.
[0080] In the embodiment of the present invention, the background running time corresponding to the background running program may represent the length of time the background running program is suspended in the background, which may be the current time minus the time when the application enters the background suspension. Each background running program may correspond to a background running time.
[0081] After determining multiple application combinations, the background running time corresponding to all background running programs in the application combination is added up to obtain the total background running time corresponding to the background running programs. The total background running time indicates that the longer the application combination is suspended in the background, the further it indicates that the background running programs in the application combination are applications that have not been interacted with by the user for a long time and are in an idle state, and the background running programs in the application combination have a higher priority as cleanup objects.
[0082] The application combination with the longest total background running time may be determined as the target application combination, and the background running programs in the target application combination may be used as the background running programs to be cleaned up.
[0083] It is also possible to sort based on the total memory usage corresponding to the application combination and the corresponding total memory usage size. Among the selected multiple combinations, the total background running time corresponding to the application combination and the length of the corresponding total background running time are used to further determine the background running programs to be cleaned up, and the selected combinations to be cleaned up are recommended to the user for selection. Specifically, the application combinations whose total memory usage is greater than the target memory requirement can be sorted in order from small to large, and the first N application combinations are selected. Among the first N application combinations, M background running programs to be cleaned up are further selected in order from long to short according to the total background running time corresponding to the application combination, and the selected M combinations to be cleaned up are recommended to the user for selection, where M and N are integers greater than or equal to 1, and M is less than or equal to N.
[0084] In this embodiment, by comprehensively considering the memory usage and running time of background applications, an efficient and intelligent memory cleaning strategy is provided for smart devices.
[0085] Optionally, in the step of determining background running programs to be cleaned up among multiple application combinations, the total memory usage corresponding to each application combination can be determined according to the memory usage corresponding to the background running programs; based on the total memory usage, background running programs to be cleaned up are determined among multiple application combinations.
[0086] In the embodiment of the present invention, each of the above application combinations includes at least two background running programs, and the total memory usage of each application combination is greater than the target memory requirement. The application combination whose total memory usage is closest to the target memory requirement can be selected, which can minimize the interference with the background running programs while meeting the memory requirement of the target application.
[0087] Specifically, the difference between the total memory usage and the target memory requirement can be calculated, and the application combination with the smallest difference can be determined as the target application combination. The background running programs in the target application combination can be determined as the background running programs to be cleared.
[0088] In a possible embodiment, multiple application combinations may be sorted to obtain multiple sorted application combinations; the sorted multiple application combinations are displayed to the user to obtain the target application combination determined by the user; the background running programs in the target application combination are determined as the background running programs to be cleared. Specifically, the total memory usage corresponding to each application combination may be determined based on the memory usage corresponding to the background running programs; based on the size of the total memory usage, the multiple application combinations are sorted to obtain multiple sorted application combinations.
[0089] In a possible embodiment, a user's sorting habit is obtained; a sorting method is determined based on the user's sorting habit; and a plurality of application combinations are sorted according to the sorting method to obtain a plurality of sorted application combinations.
[0090] In this embodiment, by accurately calculating the total memory usage of each application combination and comparing and selecting the optimal application combination, memory resources can be effectively released to meet the needs of the target application.
[0091] Optionally, the application status also includes the background running time corresponding to the background running programs. In the step of determining the memory clearing strategy based on the application status, a memory clearing model can be constructed based on the background running time corresponding to the background running programs, the memory usage corresponding to the background running programs, and the type of the background running programs. The memory clearing model is solved to obtain the optimal clearing solution for the background running programs. Based on the optimal clearing solution, at least one background running program to be cleared is determined.
[0092] In an embodiment of the present invention, the application status may include multiple information such as the background running time corresponding to the background running program, the memory usage corresponding to the background running program, and the type of the background running program. The background running time, memory usage, and type may be comprehensively considered to find the best cleanup strategy.
[0093] The memory clearing model may be constructed based on at least one of the background running time corresponding to the background running program, the memory usage corresponding to the background running program, and the type corresponding to the background running program. For example, the memory clearing model may be constructed based on the background running time corresponding to the background running program; the memory clearing model may be constructed based on the memory usage corresponding to the background running program; the memory clearing model may be constructed based on the type corresponding to the background running program; and the memory clearing model may be constructed based on a combination of two or three of the background running time corresponding to the background running program, the memory usage corresponding to the background running program, and the type corresponding to the background running program.
[0094] Specifically, this can be achieved by constructing an optimization problem, where the goal is to minimize the number of cleanup programs or the total memory usage while satisfying the constraints of the target memory requirement. Specifically, optimization algorithms such as greedy algorithms and dynamic programming can be used to find the optimal solution or approximate optimal solution. When formulating a cleanup strategy, factors such as program running time and user habits can also be considered to ensure the rationality and user-friendliness of the cleanup strategy.
[0095] Based on the above-mentioned background running time, memory usage and type, a mathematical model that considers multi-dimensional factors can be used to reflect the impact of different programs on system resources and the amount of memory that may be released after cleaning.
[0096] In the memory clearing model, reasonable weights are assigned to memory usage, runtime, and type to determine the importance of memory usage, runtime, and type. For example, memory usage has a higher weight, while runtime and program type are adjusted according to specific circumstances. It is understandable that in the memory clearing model, when the weight of one of the memory usage, runtime, and type is 0, the memory clearing model can be regarded as a memory clearing model of the combination of two items. When the weight of two of the memory usage, runtime, and type is 0, the memory clearing model can be regarded as a single-item memory clearing model. When the weights of all items in memory usage, runtime, and type are not 0, the memory clearing model can be regarded as a memory clearing model of the combination of three items.
[0097] A memory clearing model can be constructed and solved using a greedy algorithm, dynamic programming or machine learning algorithm. The goal of the solution is to find an optimal or near-optimal clearing solution, that is, to minimize the impact on users and the system while meeting memory requirements. Data such as memory usage, running time and type are input into the memory clearing model for processing, and mathematical tools (such as Matlab / Maple / Mathematics, etc.) can be used for solving. The solution result is a list of programs to be cleared and the expected amount of memory released after the program list is cleared. The program list includes at least one background running program to be cleared, and the program list is the optimal clearing solution.
[0098] In a possible embodiment, the cleaning operation can be automatically or prompted to the user according to the solution result. After the cleaning operation is completed, the memory usage can be evaluated again to verify whether the cleaning effect meets the expectations. If not, the memory clearing model parameters or algorithms can be adjusted to perform secondary cleaning.
[0099] like Figure 2 As shown, an embodiment of the present invention provides a memory cleaning device, the memory cleaning device comprising:
[0100] The first acquisition module 201 is used to monitor the user clicking on the target application and acquire the available memory resources of the device and the target memory requirement required by the target application;
[0101] A second acquisition module 202 is used to acquire the application status in the device if the available memory resource of the device is less than the target memory requirement, wherein the application status includes the memory usage corresponding to the background running program;
[0102] The processing module 203 is used to determine a memory cleaning strategy based on the application state, wherein the memory cleaning strategy includes at least one background running program to be cleaned up;
[0103] The cleaning module 204 is used to clean up the background running programs in the device according to the memory cleaning strategy, so that the amount of available memory resources to be cleaned is greater than the target memory resource amount.
[0104] Optionally, the processing module 203 is also used to determine whether there is a single application in the background running program whose memory usage is greater than the target memory requirement based on the memory usage corresponding to the background running program; if there is a single application whose memory usage is greater than the target memory requirement, the single application is determined as the background running program to be cleared; if there is no single application whose memory usage is greater than the target memory requirement, at least two background running programs to be cleared are determined in the background running program.
[0105] Optionally, the processing module 203 is also used to combine the background running programs to obtain multiple application combinations, and the total memory usage corresponding to each application combination is greater than the target memory requirement; among the multiple application combinations, the background running programs to be cleaned are determined.
[0106] Optionally, the processing module 203 is also used to determine the type of the background running program; based on the principle that the types of the background running programs are different and with the goal that the total memory usage corresponding to each application combination is greater than the target memory requirement, the background running programs are selected for combination to obtain a plurality of the application combinations.
[0107] Optionally, the application status also includes the background running time corresponding to the background running program, and the processing module 203 is further used to determine the total background running time of each application combination according to the background running time corresponding to the background running program; based on the total background running time, the background running programs to be cleaned up are determined in the multiple application combinations.
[0108] Optionally, the processing module 203 is also used to determine the total memory occupancy corresponding to each application combination based on the memory occupancy corresponding to the background running program; based on the total memory occupancy, determine the background running program to be cleared from multiple application combinations.
[0109] Optionally, the application status also includes the background running time corresponding to the background running program, and the processing module 203 is further used to construct a memory clearing model based on the background running time corresponding to the background running program, the memory occupancy corresponding to the background running program, and the type corresponding to the background running program; solve the memory clearing model to obtain the optimal clearing solution for the background running program; and determine at least one background running program to be cleared based on the optimal clearing solution.
[0110] The memory cleaning device provided in the embodiment of the present invention can implement each process implemented by the memory cleaning method in the above method embodiment and can achieve the same beneficial effect. To avoid repetition, it will not be described here.
[0111] See also Figure 3 , Figure 3 is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention, such as Figure 3 As shown, it includes: a memory 302, a processor 301, and a computer program of a memory cleaning method stored in the memory 302 and executable on the processor 301, wherein:
[0112] The processor 301 is used to call the computer program stored in the memory 302 and execute the following steps:
[0113] When detecting that a user clicks on a target application, obtaining available memory resources of a device and a target memory requirement required by the target application;
[0114] If the available memory resource of the device is less than the target memory requirement, obtaining the application status in the device, the application status including the memory usage corresponding to the background running program;
[0115] Based on the application state, determining a memory cleaning strategy, the memory cleaning strategy including at least one background running program to be cleaned up;
[0116] The background running programs to be cleaned are cleaned up by using the memory cleaning strategy, so that the available memory resources of the device are greater than the target memory resources.
[0117] Optionally, the step of determining a memory cleanup strategy based on the application state performed by the processor 301 includes:
[0118] Based on the memory usage corresponding to the background running program, determining whether there is a single application program in the background running program whose memory usage is greater than the target memory requirement;
[0119] If there is a single application whose memory usage is greater than the target memory requirement, the single application is determined as the background running program to be cleared;
[0120] If there is no single application whose memory usage is greater than the target memory requirement, at least two background running programs to be cleared are determined from the background running programs.
[0121] Optionally, the step of determining at least two background running programs to be cleared from the background running programs executed by the processor 301 includes:
[0122] Combining the background running programs to obtain a plurality of application combinations, wherein the total memory usage corresponding to each application combination is greater than the target memory requirement;
[0123] The background running programs to be cleaned up are determined from the plurality of application programs.
[0124] Optionally, the step of combining the background running programs to obtain a combination of multiple application programs performed by the processor 301 includes:
[0125] Determine the type of the background running program;
[0126] Based on the principle that the types of the background running programs are different and the goal that the total memory usage corresponding to each application combination is greater than the target memory requirement, the background running programs are selected for combination to obtain a plurality of the application combinations.
[0127] Optionally, the application state further includes the background running time corresponding to the background running program, and the step of determining the background running program to be cleared from the plurality of application combinations executed by the processor 301 includes:
[0128] Determining the total background running time of each application combination according to the background running time corresponding to the background running program;
[0129] Based on the total background running time, the background running programs to be cleaned up are determined from the plurality of application combinations.
[0130] Optionally, the step of determining the background running program to be cleaned up in the combination of multiple application programs executed by the processor 301 includes:
[0131] Determine the total memory usage corresponding to each application combination according to the memory usage corresponding to the background running program;
[0132] Based on the total memory usage, the background running programs to be cleaned up are determined from the plurality of application combinations.
[0133] Optionally, the application state further includes a background running time corresponding to the background running program, and the step of determining the memory cleaning strategy based on the application state performed by the processor 301 includes:
[0134] Building a memory clearing model based on the background running time corresponding to the background running program, the memory usage corresponding to the background running program, and the type corresponding to the background running program;
[0135] Solving the memory clearing model to obtain an optimal clearing solution for the background running program;
[0136] Based on the optimal clearing solution, at least one background running program to be cleared is determined.
[0137] It should be noted that the electronic device provided by the embodiment of the present invention can be applied to devices such as smart phones, tablets, computers, servers, etc. that can perform memory cleaning methods.
[0138] The electronic device provided by the embodiment of the present invention can implement each process implemented by the memory cleaning method in the above method embodiment and can achieve the same beneficial effect. To avoid repetition, it will not be described here.
[0139] An embodiment of the present invention also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the various processes of the memory cleaning method provided by the embodiment of the present invention are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0140] A person skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program, and the computer program can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. The computer-readable storage medium can be a disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM).
[0141] The above disclosure is only the preferred embodiment of the present invention, which certainly cannot be used to limit the scope of the present invention. Therefore, equivalent changes made according to the claims of the present invention are still within the scope of the present invention.
Claims
1. A memory cleaning method, characterized in that The method comprises the following steps: When detecting that a user clicks on a target application, obtaining available memory resources of a device and a target memory requirement required by the target application; If the available memory resource of the device is less than the target memory requirement, obtaining the application status in the device, the application status including the memory usage corresponding to the background running program; Based on the application state, determining a memory cleaning strategy, the memory cleaning strategy including at least one background running program to be cleaned up; The background running program to be cleaned is cleaned up by using the memory cleaning strategy so that the available memory resource amount of the device is greater than the target memory resource amount.
2. The memory cleaning method according to claim 1, characterized in that: The step of determining a memory cleanup strategy based on the application state includes: Based on the memory usage corresponding to the background running program, determining whether there is a single application program in the background running program whose memory usage is greater than the target memory requirement; If there is a single application whose memory usage is greater than the target memory requirement, the single application is determined as the background running program to be cleared; If there is no single application whose memory usage is greater than the target memory requirement, at least two background running programs to be cleared are determined from the background running programs.
3. The memory cleaning method according to claim 2, characterized in that: The step of determining at least two background running programs to be cleared from the background running programs comprises: Combining the background running programs to obtain a plurality of application combinations, wherein the total memory usage corresponding to each application combination is greater than the target memory requirement; The background running programs to be cleaned up are determined from the plurality of application programs.
4. The memory cleaning method according to claim 3, characterized in that: The step of combining the background running programs to obtain a combination of multiple application programs comprises: Determine the type of the background running program; Based on the principle that the types of the background running programs are different and the goal that the total memory usage corresponding to each application combination is greater than the target memory requirement, the background running programs are selected for combination to obtain a plurality of the application combinations.
5. The memory cleaning method according to claim 3, characterized in that: The application state also includes the background running time corresponding to the background running program. The step of determining the background running program to be cleared from the plurality of application combinations includes: Determining the total background running time of each application combination according to the background running time corresponding to the background running program; Based on the total background running time, the background running programs to be cleaned up are determined from the plurality of application combinations.
6. The memory cleaning method according to claim 3, characterized in that: The step of determining the background running program to be cleaned up from the combination of multiple application programs includes: Determine the total memory usage corresponding to each application combination according to the memory usage corresponding to the background running program; Based on the total memory usage, the background running programs to be cleaned up are determined from the plurality of application combinations.
7. The memory cleaning method according to claim 1, characterized in that: The application state also includes the background running time corresponding to the background running program. The step of determining the memory cleaning strategy based on the application state includes: Building a memory clearing model based on the background running time corresponding to the background running program, the memory usage corresponding to the background running program, and the type corresponding to the background running program; Solving the memory clearing model to obtain an optimal clearing solution for the background running program; Based on the optimal clearing solution, at least one background running program to be cleared is determined.
8. A memory cleaning device, characterized in that: The memory cleaning device comprises: A first acquisition module is used to monitor when a user clicks on a target application and acquire the available memory resources of the device and the target memory requirement required by the target application; A second acquisition module is used to acquire the application status in the device if the available memory resource of the device is less than the target memory requirement, wherein the application status includes the memory usage corresponding to the background running program; A processing module, configured to determine a memory cleaning strategy based on the application state, wherein the memory cleaning strategy includes at least one background running program to be cleaned up; The cleaning module is used to clean up the background running programs in the device according to the memory cleaning strategy, so that the available memory resource amount of the device is greater than the target memory resource amount.
9. An electronic device, characterized in that: include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps in the memory cleaning method as claimed in any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in the memory cleaning method according to any one of claims 1 to 7 are implemented.