Memory management method, memory management device and electronic equipment
By setting a reasonable priority for small programs in electronic devices and giving priority to cleaning small programs to reduce cold start time, the cold start problem caused by small programs consuming system resources is solved and the user experience is improved.
Patent Information
- Application Number
- CN202310908896.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-21
- Publication Date
- 2025-01-21
AI Technical Summary
In electronic devices, opening the mini program causes too much system resources to consume, which may cause the operating system to clean up the entire application, causing the user to need to start the application again, which takes a long time and affects the user experience.
By setting reasonable priorities in electronic devices and based on the usage status of the mini-programs, when memory is tight, mini-programs are prioritized to be cleaned up, thereby reducing the impact on other processes and improving user experience.
It realizes priority cleaning of small programs when memory is tight, reduces the possibility of cold start, improves user experience, and enhances the keeping of main processes or key processes alive.
Smart Images

Figure CN119336481A_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present application relate to the field of electronic technology, and more specifically, to a memory management method, a memory management device, and an electronic device. Background Art
[0002] In order to ensure that the operating system has a certain amount of free memory, it is inevitable to release memory for foreground applications through strategies such as cleaning up background applications. When using electronic devices, users can obtain convenient and rich services through mini-programs, such as product purchases, games, information queries, etc.
[0003] Opening a mini program causes the application to which the mini program belongs to consume a large amount of system resources. The operating system usually cleans up the application or process based on the status of the application or process. Since the application to which the mini program belongs consumes a large amount of system resources, it may be cleaned up as a whole by the operating system. When the user then opens the corresponding application again, it needs to be opened through a cold start, which takes a long time and reduces the user experience. Summary of the invention
[0004] The embodiments of the present application provide a memory management method and an electronic device, which can set a reasonable priority for a mini-program according to the usage status of the mini-program, so that when the memory is tight, the mini-program can be cleaned up separately, reducing the impact on other processes (such as the main process or key process) of the application to which the mini-program belongs, thereby improving the user experience.
[0005] In a first aspect, a memory management method is provided, which is applied to an electronic device, comprising: when the electronic device is in or is about to be in a first memory shortage state, determining a first priority of each of a plurality of processes, the plurality of processes including applets, the first priority of each of the plurality of processes being lower than the first priority of any other process of an application to which the applet belongs except all applets; and performing memory cleaning on the electronic device according to the first priority of each of the plurality of processes.
[0006] In this embodiment, the first priority of the mini program is lower than the first priority of other processes of the application to which the mini program belongs (other processes may include the main process or key process of the application). Therefore, when memory cleaning is performed according to the first priority, the mini program is cleaned before the main process or key process of the application to which it belongs. The main process or key process is more likely to be kept alive. When the user uses the application again, the possibility of opening it through cold start is reduced, thereby improving the user experience.
[0007] In combination with the first aspect, in some implementations of the first aspect, the method also includes: obtaining usage status of the multiple processes, the usage status of the multiple processes including at least one of the following: the relationship between the multiple processes, the foreground and background running status of each process in the multiple processes, user usage habit data of the multiple processes, the background perception status of the processes running in the background in the multiple processes, the memory occupancy of each process in the multiple processes, the foreground and background running status of each process is used to indicate whether the each process is running in the foreground or the background; wherein, determining the first priority of each process in the multiple processes includes: determining the first priority of each process in the multiple processes according to the usage status of the multiple processes.
[0008] The user's usage habit data for multiple processes includes the operation sequences of the multiple processes and the foreground usage degree of each of the multiple processes, or the user's usage habit data for multiple processes includes the background exit time of each of the multiple processes and the foreground usage degree of each of the multiple processes. The foreground usage degree of each of the multiple processes includes the number of foreground usage times and / or foreground usage time of each of the multiple processes within a preset time.
[0009] For mini-programs and applications, the usage status of the process is determined respectively, and the first priority can be determined according to the usage status. Each indicator in the above usage status can have different weights, and the first priority can be obtained by weighting each indicator. When determining the priority of the process, the present application also refers to the user's usage habits, which can reduce the possibility of cleaning up the processes that the user frequently uses or recently uses (these processes are more likely to be opened again by the user), thereby improving the user experience.
[0010] In combination with the first aspect, in some implementations of the first aspect, the method also includes: determining whether the electronic device is in or is about to be in a first memory-intensive state based on at least one of the following: whether the available memory or expected available memory of the electronic device is lower than a first threshold; whether the number of large processes started by the electronic device within a preset time exceeds a second threshold, and the large process is a process whose memory occupancy exceeds a threshold; whether the electronic device starts a process in the first list.
[0011] The expected available memory is determined based on the current available memory of the electronic device and the memory requested by the currently started process from the electronic device, or based on the current available memory and the average memory occupancy of the currently started process.
[0012] Large processes may include at least one of the following: processes whose average memory occupancy exceeds a threshold when used by the user or a large number of users, processes whose memory currently requested from the electronic device exceeds a threshold, and processes set in a preset list, which stores the identifiers of processes with large memory occupancy. The preset list can be set or updated based on the historical average memory occupancy of the process.
[0013] The first list may be a preset list indicating processes with large memory usage, and the list may include at least one process, such as a camera, a large game, etc. The first list may be updated according to the user's use of each process, for example, the process whose average memory usage / maximum memory usage exceeds the third threshold when used by the user may be added to the first list.
[0014] In an embodiment of the present application, in addition to monitoring the available memory or expected available memory of the electronic device (which can also be replaced by used memory or expected used memory, available memory ratio or expected available memory ratio, used memory ratio or expected used memory ratio), it is also possible to monitor the user's operations and determine that the electronic device is in or is about to be in a first memory-tight state when the number of large processes started within a preset time of the electronic device exceeds a second threshold or a process in the first list is started. In this way, the judgment of the first memory-tight state is close to the user's usage scenario, and the possible memory-tight state can be judged more quickly and corresponding actions can be taken.
[0015] When the electronic device is determined to be in a first memory shortage state according to the number of large processes started within a preset time exceeding the second threshold or the processes in the first list are started, the processes can be cleared in sequence according to the first priority until the available memory or expected available memory of the electronic device exceeds the first threshold. Alternatively, the size of the memory released at one time can be set, for example, the clearing ends when 500M is cleared.
[0016] In combination with the first aspect, in some implementations of the first aspect, the method also includes: when a first event is detected, determining whether the available memory or expected available memory of the electronic device is lower than a first threshold; when the available memory or expected available memory of the electronic device is lower than the first threshold, determining that the electronic device is in or is about to be in a first memory tension state; the first event includes one of the following: the number of large processes started by the electronic device within a preset time exceeds a second threshold, a large process is a process whose memory occupancy exceeds a threshold, and the electronic device starts a process in the first list.
[0017] In this embodiment, it is possible to detect a first event that may cause a substantial decrease in the expected available memory of the electronic device before determining whether the available memory or the expected available memory of the electronic device is lower than a first threshold, thereby performing memory cleaning when it is lower than the threshold. This allows for early response to scenarios where the available memory is reduced while reducing unnecessary cleaning, thereby improving the user experience.
[0018] In combination with the first aspect, in some implementations of the first aspect, the memory cleaning is used to make the available memory or expected available memory of the electronic device greater than or equal to a first threshold; or, the memory cleaning is used to make the electronic device release memory greater than a threshold.
[0019] In combination with the first aspect, in some implementations of the first aspect, the method further includes: when the electronic device is in or is about to be in a second memory-intensive state, determining second priorities of multiple processes; and performing memory cleaning on the electronic device based on the second priorities of the multiple processes.
[0020] The electronic device performs memory cleaning when the electronic device is in a second memory tight state according to a memory cleaning strategy different from that in the first memory tight state. For example, the cleaning in the second memory tight state may be to clean the memory using Android native low memory cleaning logic (low memory killer, LMK). The second priority judgment process and cleaning logic may be different from the priority judgment process and cleaning logic in the first memory tight state, so that the electronic device can perform multi-level memory cleaning.
[0021] In combination with the first aspect, in some implementations of the first aspect, the method also includes: determining whether the electronic device is in or is about to be in a second memory shortage state based on at least one of the following: whether the available memory or expected available memory of the electronic device is lower than a fourth threshold; whether the electronic device starts a number of large processes exceeding a fifth threshold within a preset time; whether the electronic device starts a process in the second list.
[0022] In some embodiments, the same conditions or indicators may be used to judge the first memory stress state and the second memory stress state, for example, both may be determined by whether the available memory or expected available memory of the electronic device is lower than a threshold, but the thresholds for judging the two memory stress states by the available memory or expected available memory may be different; in other embodiments, different conditions or indicators may be used for judgment, for example, the first memory stress state may be judged by the number of large process starts or whether a process in the first list is started, but the second memory stress state may be judged by whether the available memory or expected available memory is lower than a fourth threshold.
[0023] The second list may be a preset list indicating processes with large memory usage, and the list may be updated according to the user's historical usage of each process. For example, processes whose average memory usage exceeds a sixth threshold may be added to the second list.
[0024] If the two memory shortage states are judged using the first list and the second list respectively, the memory occupancy of the processes in the first list may be smaller than that of the processes in the second list, that is, the sixth threshold may be greater than the third threshold mentioned above.
[0025] In combination with the first aspect, in some implementations of the first aspect, the fourth threshold is lower than the first threshold, and the fifth threshold is higher than the second threshold.
[0026] In this embodiment, the judgment condition of the second memory tension state is stricter than the judgment condition of the first memory tension state, so that the first memory tension state is reached first, so that the mini program is cleared before the main process or key process of the application to which the mini program belongs, so that the main process or key process of the application is preserved, thereby improving the user experience.
[0027] In combination with the first aspect, in some implementations of the first aspect, the processes in the first list or the processes in the second list include processes of a camera application and / or processes of a game application.
[0028] The processes in the first list or the processes in the second list may also include large image processing applications and other applications with large average memory usage, etc., which is not limited in this application.
[0029] In a second aspect, a memory management method is provided, which is applied to an electronic device, including: determining whether the electronic device is in or is about to be in a first memory-tight state based on whether the number of large processes started by the electronic device within a preset time exceeds a second threshold or whether the electronic device starts a process in a first list, the large process being a process whose memory occupancy exceeds a threshold; and performing memory cleaning on the electronic device when the electronic device is in or is about to be in the first memory-tight state.
[0030] In this embodiment, when determining whether the electronic device is in a memory shortage state, a determination method close to the user's usage scenario is adopted, so that the first memory shortage state is monitored and processed in a timely manner.
[0031] In combination with the second aspect, in some implementations of the second aspect, determining whether the electronic device is in or is about to be in a first memory-tight state based on whether the number of large processes launched by the electronic device within a preset time exceeds a second threshold or whether the electronic device launches a process in a first list includes: when the number of large processes launched by the electronic device within a preset time exceeds a second threshold or the electronic device launches a process in the first list, determining whether the available memory or expected available memory of the electronic device is lower than a first threshold; when the available memory or expected available memory of the electronic device is lower than the first threshold, determining that the electronic device is in the first memory-tight state.
[0032] According to a third aspect, a memory management device is provided, comprising a memory monitoring module for determining whether the electronic device is in or is about to be in a first memory shortage state according to whether the number of large processes started by the electronic device within a preset time exceeds a second threshold or whether the electronic device starts a process in a first list, wherein the large process is a process whose memory occupancy exceeds a threshold; and a memory control module for clearing the memory of the electronic device when the electronic device is in or is about to be in the first memory shortage state.
[0033] In combination with the third aspect, in some implementations of the third aspect, the memory monitoring module is specifically used to: determine whether the available memory or expected available memory of the electronic device is lower than a first threshold when the number of large processes started by the electronic device within a preset time exceeds a second threshold or the electronic device starts a process in a first list; when the available memory or expected available memory of the electronic device is lower than the first threshold, determine that the electronic device is in a first memory tension state.
[0034] In a fourth aspect, a memory management device is provided, comprising a module for implementing the memory management method as described in the first aspect and any possible implementation thereof or the second aspect and any possible implementation thereof.
[0035] In a fifth aspect, an electronic device is provided, comprising: one or more processors; one or more memories; the one or more memories storing one or more computer programs, the one or more computer programs comprising instructions, which, when executed by the one or more processors, enable the memory management method described in the first aspect and any possible implementation thereof or the second aspect and any possible implementation thereof to be executed.
[0036] In a sixth aspect, a chip is provided, comprising a processor and a communication interface, wherein the communication interface is used to receive a signal and transmit the signal to the processor, and the processor processes the signal so that the memory management method described in the first aspect and any possible implementation thereof or the second aspect and any possible implementation thereof is executed.
[0037] In the seventh aspect, a readable storage medium is provided, wherein instructions are stored in the readable storage medium. When the instructions are executed on a device, the memory management method described in the first aspect and any possible implementation thereof or the second aspect and any possible implementation thereof is executed.
[0038] In an eighth aspect, a program product is provided, the program product comprising a program code, and when the program code runs on a device, the memory management method as described in the first aspect and any possible implementation thereof or the second aspect and any possible implementation thereof is executed. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] Figure 1 It is a hardware structure diagram of the electronic device provided in the embodiment of the present application.
[0040] Figure 2 It is a schematic diagram of the software structure of the electronic device provided in the embodiment of the present application.
[0041] Figure 3 It is a schematic flowchart of a memory management method provided in an embodiment of the present application.
[0042] Figure 4 It is a schematic block diagram of a memory management device provided in an embodiment of the present application.
[0043] Figure 5 It is a schematic block diagram of a memory management device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0044] The technical solutions in the embodiments of the present application will be described below in conjunction with the accompanying drawings.
[0045] Figure 11 shows a schematic diagram of the structure of the electronic device 100. The electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195. The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.
[0046] It is to be understood that the structure illustrated in the embodiment of the present application does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.
[0047] The processor 110 may include one or more processing units, for example, the processor 110 may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.
[0048] The controller may be the nerve center and command center of the electronic device 100. The controller may generate an operation control signal according to the instruction operation code and the timing signal to complete the control of fetching and executing instructions.
[0049] The processor 110 may also be provided with a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory may store instructions or data that the processor 110 has just used or cyclically used. If the processor 110 needs to use the instruction or data again, it may be directly called from the memory. This avoids repeated access, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.
[0050] The software system of the electronic device 100 may adopt a layered architecture, an event-driven architecture, a micro-core architecture, a micro-service architecture, or a cloud architecture. The embodiment of the present application takes the Android system of the layered architecture as an example to exemplify the software structure of the electronic device 100.
[0051] The embodiments of the present application can be applied to different operating systems, such as operating system, operating system, Operating system, etc., the following mainly takes the Android operating system as an example to introduce the software structure block diagram of the electronic device provided in the embodiment of the present application.
[0052] Figure 2 It is a software structure diagram of the electronic device of the embodiment of the present application. The layered architecture divides the software into several layers, each layer has a clear role and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into four layers, from top to bottom, namely, the application layer, the application framework layer, the Android runtime (Android runtime) and the system library, and the kernel layer. The application layer can include a series of application packages.
[0053] The application package may include applications such as camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, short message, etc.
[0054] The mini-programs, applications, etc. of the embodiments of the present application may be located at the application layer.
[0055] The application framework layer provides an application programming interface (API) and a programming framework for the applications in the application layer. The application framework layer includes some predefined functions.
[0056] The memory management and control module, priority determination module, and memory monitoring module of the embodiment of the present application may be located at the application framework layer.
[0057] like Figure 2As shown, the application framework layer may include window manager service (WMS), content provider, activity manager service (AMS), package manager service (PMS), view system, phone manager, resource manager, notification manager, etc.
[0058] The window manager is used to manage window programs. The window manager can obtain the display screen size, determine whether there is a status bar, lock the screen, capture the screen, etc.
[0059] Content providers are used to store and retrieve data and make it accessible to applications. The data may include videos, images, audio, calls made and received, browsing history and bookmarks, phone books, etc.
[0060] Activity management services are used to manage activities, such as activity lifecycle management.
[0061] In the embodiment of the present application, the activity management service can obtain various parameters of the usage status of the process, and can determine the first priority of each process according to these parameters.
[0062] Package management services can be used to manage the installation and uninstallation of applications.
[0063] The view system includes visual controls, such as controls for displaying text, controls for displaying images, etc. The view system can be used to build applications. A display interface can be composed of one or more views. For example, a display interface including a text notification icon can include a view for displaying text and a view for displaying images.
[0064] The phone manager is used to provide communication functions for electronic devices, such as the management of call status (including answering, hanging up, etc.).
[0065] The resource manager provides various resources for applications, such as localized strings, icons, images, layout files, video files, and so on.
[0066] The notification manager enables applications to display notification information in the status bar. It can be used to convey notification-type messages and can disappear automatically after a short stay without user interaction. For example, the notification manager is used to notify download completion, message reminders, etc. The notification manager can also be a notification that appears in the system top status bar in the form of a chart or scroll bar text, such as notifications of applications running in the background, or a notification that appears on the screen in the form of a dialog window. For example, a text message is displayed in the status bar, a prompt sound is emitted, an electronic device vibrates, an indicator light flashes, etc.
[0067] Android runtime includes core libraries and virtual machines. Android runtime is responsible for scheduling and management of the Android system.
[0068] The core library consists of two parts: one part is the function that needs to be called by the Java language, and the other part is the Android core library.
[0069] The application layer and the application framework layer run in a virtual machine. The virtual machine executes the Java files of the application layer and the application framework layer as binary files. The virtual machine is used to perform functions such as object life cycle management, stack management, thread management, security and exception management, and garbage collection.
[0070] The system library may include multiple functional modules, such as surface manager, media libraries, 3D graphics processing library (such as OpenGL ES), 2D graphics engine (such as SGL), etc.
[0071] The surface manager is used to manage the display subsystem and provide the fusion of 2D and 3D layers for multiple applications.
[0072] The media library supports playback and recording of a variety of commonly used audio and video formats, as well as static image files, etc. The media library can support a variety of audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.
[0073] The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, compositing, and layer processing.
[0074] A 2D graphics engine is a drawing engine for 2D drawings.
[0075] The kernel layer is the layer between hardware and software. The kernel layer contains at least display driver, camera driver, audio driver, and sensor driver.
[0076] Before introducing the technical solution of the present application, some professional terms that may be involved in the present application solution are briefly introduced below.
[0077] Activity: A component that can contain a user interface and is mainly used to interact with users, such as making calls, taking photos, sending emails, and viewing maps. Most of the content that users can see in an application is provided by the activity component. In an application, multiple activities can be included.
[0078] Task: usually refers to a collection of related activities, which are arranged in a stack in the order in which they are opened. The home screen of an electronic device is usually the starting point of the task.
[0079] Foreground: A foreground service performs actions that the user notices. For example, an audio app uses a foreground service to play an audio track. A foreground service often needs to display a notification. A foreground service continues to run even if the user stops interacting with the app.
[0080] Background: Background services perform actions that are not directly noticed by the user. For example, if an app uses a service to compress its storage space, this service is usually a background service.
[0081] With the development of computer technology, mini programs have emerged. Mini programs are applications that run in applications through HTML5 technology, can be used without installation, and can be developed according to user needs. When users open mini programs through applications, since the applications themselves have many services and need to consume a certain amount of memory, opening mini programs causes the applications to consume more system resources.
[0082] The operating system usually cleans up applications or processes based on their status. If these applications, including mini-programs, are cleaned up because they consume a lot of system resources, when the user opens the corresponding application again, the cold start time is long and the user experience is reduced.
[0083] The technical solution provided in the embodiment of the present application can set a reasonable priority for the mini-program, so that the mini-program is cleaned up before the main process or key process of the application to which the mini-program belongs, making it more likely that the main process or key process will be preserved, thereby improving the user experience.
[0084] Figure 3 A schematic flow chart of a memory management method provided in an embodiment of the present application is shown, and the memory management method includes the following steps:
[0085] S310, when the electronic device is in or is about to be in a first memory shortage state, determining a first priority of each process in a plurality of processes, the plurality of processes including mini-programs, the first priority of each mini-program in the plurality of processes being lower than the first priority of any other process of the application to which the mini-program belongs except all mini-programs.
[0086] S320, clearing the memory of the electronic device according to the first priority of each process in the multiple processes.
[0087] In S310, the electronic device determines the first priority of the processes in the running state in the electronic device when the electronic device is in or about to be in the first memory shortage state. These processes may include other processes of the application except the applet, and may also include the applet, wherein the applet needs to be run in the environment provided by the corresponding application, for example, at least one applet can be run in the environment provided by the application.
[0088] The process running in the electronic device may include at least one applet. When there are multiple applet in the running process, the multiple applet may run in an environment provided by the same application or in environments provided by at least two applications.
[0089] For any mini-program, the environment provided by the application to which it belongs may include other mini-programs. However, through the first priority judgment scheme of the embodiment of the present application, the first priority of the mini-program is lower than the first priority of all processes of the application to which it belongs except all mini-programs (all processes except mini-programs may include the main process or key process of the application). For example, if the environment of application A includes mini-programs 1 and 2, then for mini-program 1, its priority is lower than all processes of application A except mini-programs 1 and 2. In addition to mini-programs 1 and 2, application A may also include one or more processes, that is, the first priority of mini-program 1 is lower than the first priority of the one or more processes.
[0090] Mini Program 2 is similar to Mini Program 1. However, the first priority of Mini Program 1 and Mini Program 2 requires a specific analysis based on the specific status of the two Mini Programs, which will be introduced in detail later.
[0091] The first priority may be obtained by determining the priority of the process in the first priority system, and the second priority mentioned later may be obtained by determining the priority of the process in the second priority system. Different priority judgment systems may have different priorities for the same process obtained by priority judgment, resulting in different processes that are prioritized for cleaning during memory cleaning. When the priority of a process is low, it will be prioritized for cleaning during memory cleaning. Since the priority of a mini-program is lower than the priority of the main process or key process of the application to which the mini-program belongs, the mini-program will be cleared before the main process or key process of the application to which it belongs during memory cleaning. As a result, the available memory of the electronic device may be restored to above the memory waterline (available memory threshold) due to the cleaning of the mini-program, and the main process or key process of the application to which the mini-program belongs is more likely to be preserved.
[0092] S310 may be executed by a first priority determination module in the electronic device.
[0093] In an embodiment of the present application, the first priority of each of the multiple processes can be determined based on the acquired usage status of the multiple processes, wherein the usage status of the multiple processes may include at least one of the following: the relationship between the multiple processes, the foreground and background running status of each of the multiple processes, the user's usage habit data for the multiple processes, the background perception status of the processes running in the background among the multiple processes, and the memory usage of each of the multiple processes, wherein the foreground and background running status of the process is used to indicate whether the process is running in the foreground or the background.
[0094] Before S310, the electronic device may monitor the usage status of the process. Specifically, the usage status of the process may be monitored and acquired by a status acquisition module in the electronic device.
[0095] The process relationship may include a subordinate relationship between processes, for example, a small program and other processes of the application to which it belongs have a subordinate relationship. The process relationship may also include a dependency relationship, for example, the operation of one process needs to call another process, and the two processes have a dependency relationship.
[0096] The type of the process can be determined through the process relationship, for example, the process belongs to a process without a mini-program, a process with a mini-program, a mini-program, etc. Specifically, the type of the process can be determined through the process name field (ProcessName).
[0097] The user's usage habit data for multiple processes may include the operation sequence of multiple processes or the background exit time of multiple processes, and the foreground usage level of each process in the multiple processes (which may include the number of foreground usage times and / or foreground usage time within a preset time).
[0098] The following describes a method for determining process relationships, the foreground and background running status of processes, process usage habit data, the background perception status of processes, and the memory usage of processes in an embodiment of the present application.
[0099] The subordinate relationship of a process can be obtained through the process name. For example, for application A, the name of its mini-program can be "com.A.mm:appbrand0", and the name of the main process of application A can not include the "appbrand0" suffix. For different applications, the name settings of their main processes and mini-programs may use different specifications, or the main process of the application and the mini-program can be distinguished by other methods, which will not be repeated here.
[0100] The foreground and background running status of a process can be obtained by monitoring the life cycle of all activities in the process. Taking the mini program as an example, the foreground and background running status of the mini program can be obtained through its life cycle. The mini program life cycle is divided into the application life cycle, the page life cycle and the component life cycle. The application life cycle includes: onLaunch, onShow, onHide, onError, onPageNotFound, onUnhandledRejection, onThemeChange, where onShow means that the mini program is displayed in the foreground, and onHide means that the mini program enters the background. The page life cycle includes: onLoad, onShow, onReady, onHide, onUnload, where onShow is the method triggered when the mini program enters the foreground from the background, and onHide is the method triggered when the mini program runs in the background or jumps to other pages. The component life cycle includes: created, attached, ready, moved, detached, error.
[0101] The user's usage habit data for multiple processes may include operation sequences or background exit time and foreground usage level.
[0102] The process operation sequence may indicate the order in which multiple processes are opened, and processes opened earlier by the user are more likely to be no longer used.
[0103] The background exit time of a process is the duration of the background running state when the mini program is running in the background. It can be obtained by obtaining the current time and the time when the mini program exits the background.
[0104] The degree of foreground usage of a process within a preset time can indicate how frequently a user uses the process, for example, by the total time the user uses the process in the foreground within a preset time or by the number of times the process is run in the foreground within a preset time.
[0105] The background perception state of a process may include a perceptible state and an imperceptible state. The perceptible state means that the process is perceptible to the user even though it is running in the background, such as the audio playing state or the visible state. A process in a visible state may be called a visible process. A visible process is a process that is not running in the foreground but is still visible to the user, such as clock, weather, input method, etc. The background perception state of a process can be obtained through its running state data.
[0106] The memory usage of a process is the memory currently occupied by the process or it may also be the average memory usage (or maximum memory usage, etc.) of the process. For example, when a process is just started, it may not have requested enough memory from the system, or it may request allocated memory from the electronic device for the process.
[0107] In the embodiment of the present application, the main process of the application may also be divided into a process with a mini-program and a process without a mini-program, and different weights may be given when determining the first priority.
[0108] When determining the first priority of a process according to the usage status of the process, the contribution of the above-mentioned various indicators to the first priority may be different (different weights).
[0109] Exemplarily, the first priority of the process running in the foreground is higher than the first priority of the process running in the background, so the process running in the background is cleared before the process running in the foreground.
[0110] If both processes are running in the background, the first priority of the process in the perceptible state is higher than the first priority of the process in the background non-perceptible state. For example, when a process is playing audio in the background and is in the background perceptible state, the first priority of the process is higher and more difficult to be cleaned up, thereby reducing the possibility of interruptions to the user when playing audio.
[0111] If two processes are both running in the background and are not perceptible to the background, the first priority of the process with a higher foreground usage or a shorter background exit time can be set higher. If the foreground usage is high, the user uses the process more frequently; if the background exit time is short, the user has used the process in the foreground a short time ago and is more likely to use it again.
[0112] If other indicators are similar, the first priority of processes that occupy a large amount of memory can be made lower than the first priority of processes that occupy a small amount of memory. This way, after processes that occupy a large amount of memory are cleared, the available memory of the electronic device can be restored to below the threshold waterline as soon as possible, thereby reducing the impact on user use.
[0113] The above is only a schematic illustration of a first priority judgment method, and the importance of the above indicators can also be adjusted according to actual conditions. For example, in order to restore the available memory of the electronic device to below the threshold waterline as soon as possible, the importance of the process memory usage can be increased.
[0114] In addition, in addition to the above-mentioned indicators, other indicators can also be referred to when determining the first priority, such as the purpose of the process, that is, whether the process belongs to a media process, a document process, a session process or a game process, etc. For example, the priority of the session process can be made higher, thereby reducing the impact on the user's session; for example, whether the process has a background service, for example, if the process is in the background downloading state, the priority of the process can be higher.
[0115] No matter how the method of determining the first priority changes, the first priority of the mini program is ultimately lower than the priority of other processes (including main processes or key processes) of the application to which the mini program belongs. Therefore, the mini program is cleared before the main process or key process of the application to which the mini program belongs, reducing the possibility of the main process or key process of the application to which the mini program belongs being cleared, increasing the possibility of the main process or key process of the application to which the mini program belongs being preserved, and improving the user experience.
[0116] When the technical solution of the embodiment of the present application is applied, the first priority of multiple processes in the application can be determined according to the process granularity. When performing memory cleaning, the other processes of the application except the applet can be determined as a whole (for example, the priority of other processes is set to the same priority level when cleaning) to determine whether they need to be cleaned, and each applet determines whether it needs to be cleaned separately, so that the order of cleaning the processes of the application from first to last is: the applet of the application, the other processes of the application except the applet. Exemplarily, an application has five processes: process 1 is its main process, process 2 and process 3 are service processes, and process 4 and process 5 are both applet. The determination of the first priority can be determined according to the determination described above, and the priority of the applet is lower than the priority of other processes of the application except the applet. Exemplarily, the priority from high to low is: process 1, process 2, process 3, process 4, process 5. When performing memory cleaning, the priorities of process 1, process 2, and process 3 can be set to a level as a whole, so that the order of cleaning from first to last is: process 5, process 4, (process 1, process 2, process 3). In this way, if there are dependencies between other processes in the application besides the applet, for example, process 1 depends on process 2 to run, then after process 2 is cleaned up, process 1 will also not be able to run normally. Cleaning up other processes as a whole can reduce the possibility of a process not being able to run normally due to individual cleaning.
[0117] Of course, this application does not limit the other processes of the application except the applet to be cleaned as a whole. For example, if there are independent processes in other processes, they can also be cleaned separately through certain cleaning strategies. However, no matter what solution is used to clean the other processes (individually or as a whole), the priority of the other processes determined by the technical solution of the embodiment of this application is higher than the priority of the applet, so the applet is cleaned before other processes.
[0118] In an embodiment of the present application, the current available memory (remaining memory) or expected available memory of the system can be monitored periodically or non-periodically, and when the available memory or expected available memory of the electronic device is lower than a first threshold, it is determined that the electronic device is in a first memory shortage state. For example, when the available memory or expected available memory of the electronic device is lower than 1G, it can be determined that the electronic device is in a first memory shortage state, and then the usage status of the process is obtained and the first priority of the process is determined, and then the memory is cleaned according to the first priority.
[0119] The monitoring system available memory can also be changed to the monitoring system used memory or expected used memory, used memory ratio or expected used memory ratio, available memory ratio or expected available memory ratio, etc. Correspondingly, the judgment conditions of the first memory tension state are changed to used memory or expected used memory, used memory ratio or expected used memory ratio greater than a threshold, and remaining memory ratio or expected remaining memory ratio less than a threshold. Among them, available memory is the size of the free memory remaining in the electronic device, used memory is the size of the memory used by the electronic device; the available memory ratio is the ratio of the remaining memory of the electronic device to the total memory, and the used memory ratio is the ratio of the used memory of the electronic device to the total memory.
[0120] If the electronic device determines whether the electronic device is about to be in the first memory shortage state by monitoring the expected available memory, the expected available memory ratio, the expected memory usage, and the expected memory usage ratio, then the electronic device not only needs to monitor the currently used or currently remaining memory, but also needs to combine the startup of the monitoring process and the expected memory occupancy of the process to determine whether it is about to be in the first memory shortage state. Taking the expected available memory as an example, the expected available memory is determined based on the current available memory of the electronic device and the memory occupancy of the current startup process (the average memory occupancy of the current startup memory or the memory allocated by the current startup process). Specifically, it can be the difference between the current available memory and the memory occupancy of the current startup process.
[0121] When performing memory cleaning, the process with the lowest priority can be cleaned up first according to the first priority. If the available memory or expected available memory is still lower than the first threshold, the process with the second lowest priority can be further cleaned up, and the memory can be cleaned up step by step until the available memory or expected available memory of the electronic device is greater than or equal to the first threshold. Alternatively, it can also be stipulated that the cleaning will be stopped when the memory greater than the threshold is released at one time under the first priority system, for example, the cleaning will be stopped after 300M is cleaned up at one time. In order to make memory identification faster and closer to the actual user usage scenario, the user's operation can be monitored, and when any of the following items is met, it is determined that the electronic device is in or is about to be in the first memory tension state: the available memory or expected available memory of the electronic device is lower than the first threshold; the number of large processes started within a preset time exceeds the second threshold, and the large process is a process whose average memory occupancy (or maximum memory occupancy) exceeds the threshold; the electronic device starts the process in the first list.
[0122] Among them, the number of processes started within the preset time may include the sum of the number of other processes and applets of the application started within the preset time, and the present application only considers large processes that have a greater impact on the system memory, for example, when the process uses an average memory occupation of more than 50M, the process is a large process. In this way, for example, when a user continuously starts an application (the number of non-applet processes of an application may be one or more) and continuously starts an applet, it may cause the number of large processes to exceed the threshold, and then it can be determined that the electronic device is in or is about to be in the first memory tension state. The electronic device can monitor the activity switching and the process name to determine whether the number of large processes started within the preset time exceeds the preset threshold. A large process list can be set according to the user's usage habits, and the processes with an average memory occupation exceeding the threshold can be placed in the list; it is not limited to determining whether a process is a large process only through the list. If the memory requested by the process to the electronic device is greater than the preset threshold, the process can also be regarded as a large process. In this way, the electronic device can determine as soon as possible whether it is in or is about to be in the first memory tension state and release the memory.
[0123] The processes in the first list may include processes of camera applications, processes of large-scale game applications, processes of large-scale image / video processing applications, etc. The memory occupancy (or maximum memory occupancy) of the processes in the first list when running may be greater than the third threshold value. The memory occupancy may be obtained by the electronic device based on the average memory occupancy statistics when the user usually uses the process, or may be obtained based on the average memory occupancy statistics of a large number of users using the process, or may be determined based on the memory requested by the process to the electronic device. The use of the processes in the first list is generally accompanied by a significant reduction (or a trend of significant reduction) in the available memory of the electronic device. If it is possible to determine that the electronic device is in or is about to be in the first memory tension state when starting the processes in the list, and to perform memory cleaning in accordance with the technical solution provided in the embodiment of the present application, the system memory can be released as soon as possible, and processes that have a smaller impact on the user, such as small programs that are not obvious to the user, can be cleaned up, thereby reducing the impact on the user while increasing the running speed of the electronic device.
[0124] It should be understood that in the embodiment of the present application, when the electronic device is determined to be in the first memory shortage state by the number of large processes continuously started by the user exceeding the second threshold or the user starting the process in the first list, the currently started process may not have applied for memory from the system at this time, but because the embodiment of the present application can estimate the expected memory occupancy of the process in combination with the average memory occupancy of the process used by the user or a large number of users, it can be predicted that the first memory shortage state is about to occur and the first memory shortage state can be processed in advance. In this way, the impact on user use can be minimized as much as possible.
[0125] The monitoring of the number of large processes started within a preset time and the monitoring of whether a large process is started can be combined with the monitoring of available memory. After detecting that the number of processes started within the preset time exceeds the second threshold or the user starts a process in the preset list, the process with the lowest priority can be cleared according to the first priority, and then it is determined whether the available memory or expected available memory of the electronic device is lower than the first threshold. If it is higher, the cleaning will not continue. If it is still lower than the first threshold, the processes can continue to be cleaned in order of priority until the available memory or expected available memory of the electronic device is higher than the first threshold.
[0126] In the embodiment of the present application, in order to more accurately and timely determine whether the electronic device is in a memory shortage state, the user's operation can also be monitored (monitoring the first event), and the monitoring result can be used as the basis for triggering the monitoring of the memory of the electronic device. Specifically, it can be monitored whether the user starts a large process exceeding the second threshold number within a preset time and whether the user starts a process in the first list. When the first event is detected, it can be determined whether the available memory or expected available memory of the electronic device is lower than the first threshold. If it is lower than the first threshold, the first priority of the process is determined and the memory is cleaned according to the first priority. For example, the first threshold is 1G (calculated as 1000M), the current available memory is 1300M, if the user starts a process in the first list, the average memory occupancy of the process is 200M, so combined with the current available memory and the average memory occupancy of the process, the expected available memory of the electronic device is 1100M, which is higher than the first threshold, then the electronic device is not in or is not about to be in the first memory shortage state; and if the average memory occupancy of the process started by the user is 350M, then the expected available memory of the electronic device is 950M, and it is about to be in the first memory shortage state. In this way, after detecting a scenario that may cause the available memory of the electronic device to be significantly reduced, the available memory of the electronic device is monitored again, and a determination is made whether to perform memory cleaning based on the available memory result. This can timely and effectively restore the available memory of the electronic device to a reasonable position as soon as possible, reduce the impact of unnecessary cleaning on user use, and provide the user with a better operating experience.
[0127] The method for determining the first memory shortage state introduced in the embodiment of the present application can be implemented independently, for example, it can be executed in conjunction with any priority determination scheme and memory cleaning strategy.
[0128] The above-mentioned determination of whether the electronic device is in or about to be in the first memory stress state may be implemented by a memory monitoring module.
[0129] The technical solutions of the embodiments of the present application described above can be implemented alone or in combination with other memory management methods. For example, different trigger conditions can be set for different memory management methods, so that different methods can be used to clean up the memory of the operating system.
[0130] Taking the native low memory killer (LMK) logic of the Android operating system as an example, when the electronic device is in the second memory shortage state, it will start cleaning from the low priority process according to the second priority of the process. The second priority of the process is arranged in the following order from high to low.
[0131] The foreground process includes the activity that the user is interacting with and the service bound to the foreground activity.
[0132] Visible process, visible process includes activities that are in the foreground and do not contain any foreground components, but are still visible.
[0133] Service process, which includes services that have been started.
[0134] Background processes include invisible activities.
[0135] Empty process, an empty process is a process without any activity.
[0136] That is to say, when the electronic device is in the second memory shortage state, the second priorities of multiple processes can be determined, and memory cleaning can be performed according to the second priorities.
[0137] The determination condition of the second memory shortage state may be different from the determination condition of the first memory shortage state.
[0138] Exemplarily, the judgment condition of the second memory shortage state is stricter than the judgment condition of the first memory shortage state. Specifically, it can be determined that the electronic device is in the second memory shortage state in the following ways: determining whether the electronic device is in or about to be in the second memory shortage state according to whether the available memory or expected available memory of the electronic device is lower than a fourth threshold, wherein the fourth threshold is lower than the first threshold; determining whether the electronic device is in or about to be in the second memory shortage state according to whether the number of large processes started by the electronic device within a preset time exceeds a fifth threshold, wherein the fifth threshold is greater than the second threshold, and a large process is a process whose memory occupancy exceeds the threshold; determining whether the electronic device starts a process in the second list to determine whether the electronic device is in or about to be in the second memory shortage state.
[0139] The processes in the second list may also be similar to the processes in the first list, and may be determined by the historical average memory usage exceeding a sixth threshold (the sixth threshold may be greater than the third threshold).
[0140] Similar to determining the first memory shortage state, when detecting the occurrence of the second event, it is also possible to determine whether the available memory or expected available memory of the electronic device is lower than a fourth threshold, and when it is lower than the fourth threshold, determine that the electronic device is in or is about to be in a second memory shortage state, and the second event includes one of the following: the number of large processes started within a preset time exceeds a fifth threshold; the electronic device starts a process in the second list.
[0141] In this way, it is necessary to determine that the electronic device is in or about to be in the second memory-intensive state when the electronic device has less available memory or continuously starts a larger number of large processes or starts processes in the second list with more obvious memory usage, and to perform memory cleaning when the electronic device is in or about to be in the second memory-intensive state.
[0142] Exemplarily, different criteria may be used for judging the second memory shortage state and the first memory shortage state. Specifically, it may be determined that the electronic device is in or is about to be in the second memory shortage state when the available memory or expected available memory of the electronic device is lower than a fourth threshold value; and whether the electronic device is in or is about to be in the first memory shortage state may be determined based on whether the number of large processes started by the electronic device within a preset time exceeds the second threshold value or whether the electronic device starts a process in the first list. Optionally, the judgment conditions of available memory being lower than a preset threshold value, the number of large processes started within a preset time exceeding a preset threshold value, and opening a process in a preset list (a process in the list may be a large process whose memory usage exceeds a threshold value) may be arbitrarily combined to judge the first memory shortage state and the second memory shortage state.
[0143] The degree of memory cleaning of the electronic device in the first memory shortage state and the second memory shortage state may be different. For example, in the first memory shortage state, a light cleaning may be performed, mainly cleaning some processes such as small programs that are not obvious to users. In the second memory shortage state, a heavier cleaning than the first memory shortage state may be performed. For example, the memory may be cleaned according to the Android native logic without considering the difference between the small program and other processes of the application to which the small program belongs, for example, directly cleaning the memory of the application as a whole.
[0144] In the embodiment of the present application, when obtaining the indicator for determining the second priority, it can be implemented by the second state acquisition module, and when determining the second priority, it can be implemented by the second priority determination module.
[0145] If the second memory shortage state and the first memory shortage state are judged only in different degrees of strictness, they can be implemented by one module, such as a memory monitoring module. If different judgment conditions are used, they can also be implemented by different modules, such as a first memory monitoring module and a second memory monitoring module.
[0146] Cleaning up the memory according to the second priority may also be implemented by the memory control module.
[0147] Of course, the present application does not limit, for example, the second state acquisition module and the second priority determination module to be one module; or the modules in the first memory tension state and the modules in the second memory tension state are the same module. For example, the indicators for determining the first priority and the second priority are obtained by the state acquisition module, the determination of the first priority and the second priority is completed by the priority determination module, and the judgment of the first memory tension state and the second memory tension state is implemented by the memory monitoring module, and the memory cleaning is implemented by the memory control module.
[0148] Of course, in addition to the first memory tension state and the second memory tension state introduced above, the present application does not limit whether there is a third memory tension state, a fourth memory tension state, etc. The electronic device can set a multi-level memory cleaning strategy according to demand. After each level of memory tension state, different memory cleaning intensities and different priority determination strategies can be corresponding to the strictness of the judgment conditions, so that the memory of the electronic device can be cleaned in a hierarchical manner.
[0149] Figure 4 A memory management device 400 provided in an embodiment of the present application is shown, and the memory management device 400 includes: a first priority determination module 410 and a memory control module 420. Optionally, the memory management device 400 also includes: a state acquisition module 430, a first memory monitoring module 440, a second priority determination module 450 and a second memory monitoring module 460.
[0150] Specifically, the memory management device includes a first priority determination module 410, which is used to determine the first priority of each of multiple processes when the electronic device is in or is about to be in a first memory shortage state. The multiple processes include applets, and the first priority of each applet in the multiple processes is lower than the first priority of any other process of the application to which the applet belongs except all applets; a memory management module 420, which is used to clean up the memory of the electronic device according to the first priority of each process in the multiple processes.
[0151] In an embodiment of the present application, the device also includes a status acquisition module 430, which is used to obtain the usage status of the multiple processes, and the usage status of the multiple processes includes at least one of the following: the relationship between the multiple processes, the foreground and background running status of each process in the multiple processes, the user's usage habit data of the multiple processes, the background perception status of the processes running in the background among the multiple processes, the memory occupancy of each process in the multiple processes, and the foreground and background running status of each process is used to indicate whether each process is running in the foreground or the background; wherein, the first priority determination module 410 is specifically used to: determine the first priority of each process in the multiple processes according to the usage status of the multiple processes.
[0152] In an embodiment of the present application, the device also includes a first memory monitoring module 440, which is used to determine whether the electronic device is in or is about to be in a first memory shortage state based on at least one of the following: whether the available memory or expected available memory of the electronic device is lower than a first threshold; whether the number of large processes started by the electronic device within a preset time exceeds a second threshold, and the large process is a process whose memory occupancy exceeds the threshold; whether the electronic device starts a process in the first list.
[0153] In an embodiment of the present application, the device also includes a first memory monitoring module 440, which is used to: when a first event is detected, determine whether the available memory or expected available memory of the electronic device is lower than a first threshold; when the available memory or expected available memory of the electronic device is lower than the first threshold, determine that the electronic device is in or is about to be in a first memory tension state; the first event includes one of the following: the number of large processes started by the electronic device within a preset time exceeds a second threshold, the large process is a process whose memory occupancy exceeds the preset threshold, and the electronic device starts a process in the first list.
[0154] In an embodiment of the present application, the memory cleaning is used to make the available memory or expected available memory of the electronic device greater than or equal to a first threshold; or, the memory cleaning is used to make the electronic device release memory greater than a threshold.
[0155] In an embodiment of the present application, the device also includes a second priority determination module 450, which is used to determine the second priorities of multiple processes when the electronic device is in or is about to be in a second memory shortage state; the memory management module 420 is also used to clean up the memory of the electronic device according to the second priorities of the multiple processes.
[0156] In an embodiment of the present application, the device also includes a second memory monitoring module 460, which is used to determine whether the electronic device is in or is about to be in a second memory shortage state based on at least one of the following: whether the available memory or expected available memory of the electronic device is lower than a fourth threshold; whether the electronic device starts a number of large processes exceeding a fifth threshold within a preset time; whether the electronic device starts a process in the second list.
[0157] In the embodiment of the present application, the fourth threshold is lower than the first threshold, and the fifth threshold is higher than the second threshold.
[0158] In an embodiment of the present application, the processes in the first list or the processes in the second list include processes of a camera application and / or processes of a game application.
[0159] Figure 5 A memory management device 500 provided in an embodiment of the present application is shown. Figure 5The memory management device 500 shown may correspond to the memory management device described above. Specifically, the memory management device 500 may be Figure 4 A specific example of a memory management device in the embodiment of the present application. The memory management device 500 includes: a processor 520. In an embodiment of the present application, the processor 520 is used to implement corresponding control management operations, for example, the processor 520 is used to support the memory management device 500 to perform the method or operation or function of the aforementioned embodiment. Optionally, the memory management device 500 may also include: a memory 510 and a communication interface 530; the processor 520, the communication interface 530 and the memory 510 may be interconnected or interconnected through a bus 540. Among them, the communication interface 530 is used to support the memory management device to communicate with other devices, etc., and the memory 510 is used to store the program code and data of the memory management device. The processor 520 calls the code or data stored in the memory 510 to implement the corresponding operation. The memory 510 may be coupled to the processor or not. The coupling in the embodiment of the present application is an indirect coupling or communication connection between the memory management device, unit or module, which may be electrical, mechanical or other forms, and is used for information interaction between the memory management device, unit or module.
[0160] Among them, the processor 520 can be a central processing unit, a general-purpose processor, a digital signal processor, an application-specific integrated circuit, a field programmable gate array or other programmable logic device, a transistor logic device, a hardware component or any combination thereof. It can implement or execute various exemplary logic blocks, modules and circuits described in combination with the contents disclosed in this application. The processor can also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a digital signal processor and a microprocessor, and so on. The communication interface 530 can be a transceiver, circuit, bus, module or other type of communication interface. The bus 540 can be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 5 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0161] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0162] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0163] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0164] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0165] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0166] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in the various embodiments of the present application. The aforementioned storage media include: various media that can store program codes, such as USB flash drives, mobile hard disks, read-only memories (ROM), random access memories (RAM), magnetic disks or optical disks.
[0167] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A memory management method, applied to an electronic device, characterized in that: include: When the electronic device is in or about to be in a first memory shortage state, determining a first priority of each of a plurality of processes, the plurality of processes including mini-programs, the first priority of each of the plurality of processes being lower than a first priority of any other process of an application to which the mini-program belongs except all mini-programs; Memory of the electronic device is cleaned up according to the first priority of each process in the multiple processes.
2. The method according to claim 1, characterized in that The method further comprises: Obtaining usage status of the multiple processes, where the usage status of the multiple processes includes at least one of the following: The relationship between the multiple processes, the foreground and background running status of each of the multiple processes, the user's usage habit data of the multiple processes, the background perception status of the processes running in the background among the multiple processes, the memory usage of each of the multiple processes, and the foreground and background running status of each process is used to indicate whether each process is running in the foreground or the background; Wherein, determining the first priority of each process in the plurality of processes includes: A first priority of each of the plurality of processes is determined according to usage status of the plurality of processes.
3. The method according to claim 1 or 2, characterized in that The method further comprises: Determine whether the electronic device is in or is about to be in a first memory stress state according to at least one of the following: Whether the available memory or expected available memory of the electronic device is lower than a first threshold; Whether the number of large processes started by the electronic device within a preset time exceeds a second threshold, the large process being a process whose memory usage exceeds a threshold; Whether the electronic device starts a process in the first list.
4. The method according to claim 1 or 2, characterized in that: The method further comprises: Upon detecting the first event, determining whether the available memory or the expected available memory of the electronic device is below a first threshold; When the available memory or expected available memory of the electronic device is lower than a first threshold, determining that the electronic device is in or is about to be in a first memory shortage state; The first event includes one of the following: the number of large processes started by the electronic device within a preset time exceeds a second threshold, the large process is a process whose memory occupancy exceeds a threshold, and the electronic device starts a process in the first list.
5. The method according to any one of claims 1 to 4, characterized in that The memory cleaning is used to make the available memory or expected available memory of the electronic device greater than or equal to a first threshold; or, the memory cleaning is used to make the electronic device release memory greater than a threshold.
6. The method according to claim 3, characterized in that The method further comprises: When the electronic device is in or about to be in a second memory shortage state, determining a second priority level of the plurality of processes; The memory of the electronic device is cleaned up according to the second priorities of the multiple processes.
7. The method according to claim 6, characterized in that The method further comprises: Determine whether the electronic device is in or about to be in a second memory stress state according to at least one of the following: whether the available memory or expected available memory of the electronic device is lower than a fourth threshold; Whether the number of large processes started by the electronic device within a preset time exceeds a fifth threshold; Whether the electronic device starts a process in the second list.
8. The method according to claim 7, characterized in that The fourth threshold is lower than the first threshold, and the fifth threshold is higher than the second threshold.
9. The method according to claim 3 or 7, characterized in that: The processes in the first list or the processes in the second list include processes of camera applications and / or processes of game applications.
10. A memory management device, applied to an electronic device, characterized in that: include: A first priority determination module, configured to determine, when the electronic device is in or about to be in a first memory shortage state, a first priority of each of a plurality of processes, wherein the plurality of processes include applets, and the first priority of each of the plurality of processes is lower than the first priority of any other process of an application to which the applet belongs except all applets; A memory management and control module is used to clean up the memory of the electronic device according to the first priority of each process in the multiple processes.
11. The device according to claim 10, characterized in that The device further includes a status acquisition module, which is used to acquire the usage status of the multiple processes, and the usage status of the multiple processes includes at least one of the following: The relationship between the multiple processes, the foreground and background running status of each of the multiple processes, the user's usage habit data of the multiple processes, the background perception status of the processes running in the background among the multiple processes, the memory usage of each of the multiple processes, and the foreground and background running status of each process is used to indicate whether each process is running in the foreground or the background; Wherein, the first priority determination module is specifically used to: A first priority of each of the plurality of processes is determined according to usage status of the plurality of processes.
12. The device according to claim 10 or 11, characterized in that The device further includes a first memory monitoring module, configured to determine whether the electronic device is in or about to be in a first memory shortage state according to at least one of the following: Whether the available memory or expected available memory of the electronic device is lower than a first threshold; Whether the number of large processes started by the electronic device within a preset time exceeds a second threshold, the large process being a process whose memory usage exceeds a threshold; Whether the electronic device starts a process in the first list.
13. The device according to claim 10 or 11, characterized in that The device also includes a first memory monitoring module, which is used to: Upon detecting the first event, determining whether the available memory or the expected available memory of the electronic device is below a first threshold; When the available memory or expected available memory of the electronic device is lower than a first threshold, determining that the electronic device is in or is about to be in a first memory shortage state; The first event includes one of the following: the number of large processes started by the electronic device within a preset time exceeds a second threshold, the large process is a process whose memory occupancy exceeds a preset threshold, and the electronic device starts a process in the first list.
14. The device according to any one of claims 10 to 13, characterized in that The memory cleaning is used to make the available memory or expected available memory of the electronic device greater than or equal to a first threshold; or, the memory cleaning is used to make the electronic device release memory greater than a threshold.
15. The device according to claim 12, characterized in that The device further comprises a second priority determination module, configured to determine second priorities of the plurality of processes when the electronic device is in or about to be in a second memory shortage state; The memory management and control module is further used to clean up the memory of the electronic device according to the second priority levels of the multiple processes.
16. The device according to claim 15, characterized in that The device further includes a second memory monitoring module, configured to determine whether the electronic device is in or about to be in a second memory stress state according to at least one of the following: whether the available memory or expected available memory of the electronic device is lower than a fourth threshold; Whether the number of large processes started by the electronic device within a preset time exceeds a fifth threshold; Whether the electronic device starts a process in the second list.
17. The device according to claim 16, characterized in that The fourth threshold is lower than the first threshold, and the fifth threshold is higher than the second threshold.
18. The device according to claim 12 or 16, characterized in that The processes in the first list or the processes in the second list include processes of camera applications and / or processes of game applications.
19. A memory management method, applied to an electronic device, characterized in that: include: Determining whether the electronic device is in or about to be in a first memory shortage state according to whether the number of large processes started by the electronic device within a preset time exceeds a second threshold or whether the electronic device starts a process in the first list, wherein the large process is a process whose memory occupancy exceeds a threshold; When the electronic device is in or about to be in a first memory shortage state, memory cleaning is performed on the electronic device.
20. The method of claim 19, wherein: The determining whether the electronic device is in or is about to be in the first memory shortage state according to whether the number of large processes started by the electronic device within a preset time exceeds a second threshold or whether the electronic device starts a process in the first list includes: When the number of large processes started by the electronic device within a preset time exceeds a second threshold or the electronic device starts a process in the first list, determining whether the available memory or expected available memory of the electronic device is lower than a first threshold; When the available memory or the expected available memory of the electronic device is lower than a first threshold, it is determined that the electronic device is in a first memory shortage state.
21. An electronic device, characterized in that: include: one or more processors; One or more memories; the one or more memories store one or more computer programs, the one or more computer programs include instructions, when the instructions are executed by one or more processors, the memory management method as described in any one of claims 1 to 9 or any one of claims 19 to 20 is executed.
22. A chip, characterized in that: include: A processor and a communication interface, wherein the communication interface is used to receive a signal and transmit the signal to the processor, and the processor processes the signal so that the memory management method as described in any one of claims 1 to 9 or any one of 19 to 20 is executed.
23. A readable storage medium, characterized in that: The readable storage medium stores instructions, and when the instructions are executed on a computer, the memory management method according to any one of claims 1 to 9 or any one of claims 19 to 20 is executed.