A process management method, electronic equipment and computer readable storage medium
Patent Information
- Application Number
- CN202410704185.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-31
- Publication Date
- 2026-09-25
- Estimated Expiration
- 2044-05-31
AI Technical Summary
[0005]有鉴于此,本申请提供了一种进程管理方法、电子设备及计算机可读存储介质,能够改善后台应用程序出现热启动时长过长的问题
[0039]可以理解地,上述提供的第五方面及其任一种可能的设计方式所述的电子设备,第六方面所述的计算机可读存储介质,以及第七方面所述的计算机程序产品均用于执行上文所提供的对应的方法,因此,其所能达到的有益效果可参考上文所提供的对应的方法中的有益效果,此处不再赘述。
Smart Images

Figure CN121092269B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of terminal technology, and in particular to a process management method, electronic device, and computer-readable storage medium. Background Technology
[0002] Electronic devices, such as mobile phones and tablets, can have multiple applications installed, allowing users to switch between them while using the device. Applications running in the foreground of an electronic device are called foreground applications, and they interact directly with the user. Applications running in the background are called background applications, and they do not interact directly with the user.
[0003] When a user launches a background application, because the application's process remains on the electronic device, the device can directly switch the background application to the foreground. This launch method is also known as a warm start. Warm starts allow for quick application launches, improving the smoothness of electronic device operation.
[0004] However, when electronic devices launch background applications via warm restart, some background applications have been found to have excessively long warm restart times. Summary of the Invention
[0005] In view of this, this application provides a process management method, an electronic device, and a computer-readable storage medium that can improve the problem of excessively long warm start times for background applications.
[0006] Firstly, this application provides a process management method applied to an electronic device including an application. When the electronic device executes this process management method, it may first respond to a user operation that switches an application from the foreground to the background, triggering memory reclamation at a first moment. Memory reclamation releases the memory occupied by the application, thereby freeing up the memory occupied by the background application. Then, in response to the user operation, the electronic device triggers process freezing at a second moment. Process freezing freezes the process corresponding to the application, thereby preventing the background application from consuming computing resources; wherein, the first moment occurs before the second moment.
[0007] In the above implementation process, because the first moment occurs before the second moment, the electronic device can send a memory reclamation command to the process corresponding to the application before it is frozen. This avoids sending the memory reclamation command to the frozen process, thus preventing the frozen process from executing the memory reclamation command before entering the startup process after thawing. This effectively reduces the time required for a warm restart of the application.
[0008] In one possible implementation of the first aspect, the electronic device also includes an application management system and a memory management module;
[0009] Therefore, the process of triggering memory reclamation in response to a user action that switches an application from the foreground to the background can include the following steps: First, in response to the user action, the application management system sends a first notification message to the memory management module, which instructs the application to switch to the background. Next, the memory management module sends a second notification message to the application management system in the same instant, also instructing the application to switch to the background; the first instant is defined as the time after a preset period following the receipt of the first notification message. Finally, in response to the first notification message, the application management system sends a first instruction to the application; this first instruction triggers the application to release the memory occupied by the corresponding process.
[0010] In the above implementation, the application management system can manage the application's lifecycle, including operations such as application startup, switching, and destruction. Therefore, upon detecting a user operation switching an application from the foreground to the background, the application management system can manage the application switch and send a first notification to the memory management module to inform it that the application has been switched to the background. This allows the memory management module to send a second notification message to the application management system immediately, instructing it to send a first command to the application to trigger the release of memory occupied by the corresponding process. Thus, the memory management module can notify the application management system to send a first command to the application to release memory at the first moment, enabling memory release before the application is frozen. This avoids the frozen process executing a memory reclamation command before starting the startup process after thawing, effectively reducing the duration of application warm starts.
[0011] In one possible implementation of the first aspect, the method further includes: in response to the application's process level being downgraded to a preset level, the application management system determines whether the level of a second instruction to be sent to the application is lower than the level of the first instruction. If the level of the second instruction is lower than the level of the first instruction, the application management system intercepts the second instruction; wherein the second instruction is an instruction to be sent to the application to trigger memory reclamation in response to the application's process level being downgraded to a preset level.
[0012] The levels of the first and second instructions are used to indicate the importance of the instructions. In some embodiments, the importance of an instruction can represent the amount of memory that the application is instructed to release; for example, the larger the amount of memory released, the higher the importance of the instruction.
[0013] In the above implementation process, when the application's process level is reduced to the preset level, it means that the memory occupied by the application's process can be released. At this time, the application management system can send a command to the application to trigger memory reclamation, which is the second command to be sent to the application. However, if the application directly sends the command to trigger memory reclamation, the application whose process is frozen will receive the command. Therefore, the application management system can first determine whether the level of the second command to be sent to the application is lower than the level of the first command. If the level of the second command is lower than the level of the first command, it means that the importance of the second command is not as high as that of the first command. Since the application has already executed the higher-level first command, the application management system can stop sending the second command to the application.
[0014] This prevents frozen applications from receiving less important memory reclamation commands, and avoids frozen processes executing memory reclamation commands before starting the startup process. This effectively reduces the time required for a warm restart of the application.
[0015] In one possible implementation of the first aspect, the application management system sends a second instruction to the application when the second instruction has a higher priority than the first instruction. The higher priority of the second instruction indicates that the second instruction is of greater importance than the first instruction. Although the application has already executed the first instruction, the application management system can continue to send the second instruction to the application to prevent it from missing the higher-priority instruction.
[0016] This prevents applications whose processes are frozen from missing important memory reclamation instructions, thereby improving the effectiveness of memory reclamation.
[0017] In one possible implementation of the first aspect, after the application management system sends a first instruction to the application in response to the first notification message, the method further includes: the application management system recording the level of the first instruction sent.
[0018] After the application management system records the level of the first instruction, it can determine the level of the second instruction to be sent to the application when it is necessary to send a second instruction to the application. It can also compare the relationship between the levels of the first and second instructions to ensure that it can accurately determine whether a second instruction needs to be sent to the application.
[0019] Secondly, this application provides a process management method applied to an electronic device including an application program and a memory management module, the method comprising:
[0020] In response to a user action that brings the application to the foreground, the memory management module sends an intercept command to the application;
[0021] In response to the intercept instruction, if there is a first instruction to be executed, the application stops processing the first instruction, which is used to trigger the application to release the memory occupied by the process corresponding to the application.
[0022] In the above process, if a background application process receives the first instruction while frozen, then, in response to the application being switched from the background to the foreground, the electronic device can set a memory reclamation disallowance flag for the application process through the above process, so that the application process will not execute any memory reclamation instructions it has received. This prevents the application process from executing memory reclamation instructions received during the freezing period after it is unfrozen, thus avoiding the problem of excessively long warm-start times.
[0023] In one possible implementation of the second aspect, in response to the interception instruction, the application sets a flag for the corresponding process to not perform memory reclamation. Thus, when there is a first instruction to be executed, the application can determine whether to execute the first instruction by checking whether the corresponding process has set a flag to not perform memory reclamation.
[0024] If the application's process has a flag set to not perform memory reclamation, the application can determine that it does not need to execute the first instruction it has received. If the application's process has not a flag set to not perform memory reclamation, the application can determine that it needs to execute the first instruction it has received.
[0025] Thus, when a user brings an application to the foreground, the electronic device can first send an intercept command to the application, enabling the application to set a flag to prevent memory reclamation for the corresponding process. Therefore, if the application receives the first command while it is frozen, because the corresponding process has the memory reclamation flag set, the application process, once unfrozen, can be certain that it does not need to execute the received first command. This avoids the frozen process executing the memory reclamation command before entering the startup process after unfreezing. This effectively reduces the time required for a warm restart of the application.
[0026] Thirdly, this application provides a process management method applied to an electronic device including an application. When a first instruction to be executed exists, the application determines whether it is in a warm-start phase. If the application is in a warm-start phase, processing of the first instruction is stopped; the first instruction is used to trigger the application to release memory occupied by the process corresponding to the application.
[0027] In some embodiments, firstly, after the application management system sends a first instruction to a background application whose process is frozen, the application switches from the background to the foreground, meaning there is a first instruction to be executed at this point. Therefore, the application needs to first determine if it is in a warm-start phase, and in this phase, the application will not execute memory reclamation instructions.
[0028] In this way, the above implementation method can avoid the application process executing the memory reclamation instruction before the startup instruction after being unfrozen, thus avoiding the problem of excessively long application warm start time.
[0029] Fourthly, this application provides a process management method applied to an electronic device including an application and an application management system. In response to the application's process level being downgraded to a preset level, the application management system determines whether the application is frozen; if the application is frozen, it stops sending a first instruction to the application, the first instruction being used to trigger the application to release the memory occupied by the process corresponding to the application.
[0030] Specifically, when the application's process level is downgraded to the preset level, the application management system should send the first instruction to the application.
[0031] In the above implementation, when the application's process level is reduced to a preset level, the application management system first determines whether the application is frozen. If the application management system can determine that the application's process is frozen, then the application management system will not send the first instruction to the application.
[0032] In other words, an application whose process is frozen will not receive the first instruction. Even if an application whose process is frozen switches from the background to the foreground, the application can only execute the startup instruction, and will not execute the first instruction first and then the startup instruction.
[0033] This avoids the problem of excessively long warm start times caused by applications in the warm start phase executing memory reclamation instructions.
[0034] Fifthly, this application provides an electronic device, the electronic device including a memory and one or more processors; the memory and the processors are coupled; the memory is used to store computer program code, the computer program code including computer instructions; when the processor executes the computer instructions, the electronic device performs the method as described in the first aspect, the second aspect, the third aspect, the fourth aspect, and any possible design of the thereof.
[0035] Sixthly, this application provides a computer-readable storage medium including computer instructions that, when executed on an electronic device, cause the electronic device to perform the methods described in the first aspect, second aspect, third aspect, fourth aspect, and any possible design of the thereof.
[0036] In a seventh aspect, this application provides a computer program product, including a computer program / instructions that, when executed by a processor, cause the electronic device to perform the methods described in the first aspect, the second aspect, the third aspect, the fourth aspect, and any possible design of the present application.
[0037] Eighthly, this application provides an apparatus included in an electronic device, which has the function of implementing the behavior of the electronic device in any of the above aspects and possible implementations. This function can be implemented by hardware or by hardware executing corresponding software. The hardware or software includes at least one module or unit corresponding to the above function. For example, an allocation module or unit, a scanning module or unit, a recycling module or unit, a moving module or unit, and a storage module or unit, etc.
[0038] Ninthly, embodiments of this application provide a chip system including a processor and potentially a memory, for implementing any of the methods provided in the third to fifth aspects above. The chip system may be composed of chips or may include chips and other discrete devices.
[0039] Understandably, the electronic device described in the fifth aspect and any possible design of the above-described device, the computer-readable storage medium described in the sixth aspect, and the computer program product described in the seventh aspect are all used to perform the corresponding methods provided above. Therefore, the beneficial effects they can achieve can be referred to the beneficial effects in the corresponding methods provided above, and will not be repeated here. Attached Figure Description
[0040] Figure 1 A comparative diagram of application runtime provided in an embodiment of this application;
[0041] Figure 2 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application;
[0042] Figure 3 A software structure block diagram of an electronic device provided in an embodiment of this application;
[0043] Figure 4 This application provides an illustration of a process management method. Figure 1 ;
[0044] Figure 5This application provides an illustration of a process management method. Figure 2 ;
[0045] Figure 6 This application provides an illustration of a process management method. Figure 3 ;
[0046] Figure 7 This application provides an illustration of a process management method. Figure 4 . Detailed Implementation
[0047] Hereinafter, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of this embodiment, "at least one" means one or more, and "more than one" means two or more. "And / or" describes the relationship between related objects, indicating that three relationships may exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone, where A and B can be singular or plural. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. "At least one of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one of a, b, or c can represent: a, b, c, ab, ac, bc, or abc, where a, b, and c can be single or multiple.
[0048] It should be noted that, in the embodiments of this application, the terms "exemplary" or "for example" are used to indicate examples, illustrations, or descriptions. Any embodiment or design scheme described as "exemplary" or "for example" in this application should not be construed as being more preferred or advantageous than other embodiments or design schemes. Specifically, the use of terms such as "exemplary" or "for example" is intended to present the relevant concepts in a specific manner.
[0049] Before introducing the embodiments of this application, the technologies involved in the embodiments of this application will be described in detail.
[0050] 1. Memory reclamation mechanism
[0051] Memory reclamation mechanisms can include two types of reclamation methods. The first method reclaims memory by releasing infrequently used memory occupied by a process; this method does not kill the process. The second method directly kills the process, thereby releasing the memory it occupies.
[0052] In some embodiments, the first method of memory reclamation involves the electronic device sending a memory reclamation command to a process. The process can execute this command to release the memory it occupies, thus achieving memory reclamation. Generally, processes need to execute commands sequentially according to the order they are received. Therefore, in this method, if a process receives the memory reclamation command late, it may be unable to execute the command in a timely manner. The second method involves the electronic device forcibly killing the process, thereby releasing all the memory it occupies. In this method, the memory occupied by the process can be released directly, achieving rapid memory release.
[0053] 2. Freezing mechanism
[0054] The freezing mechanism is a management mechanism proposed to prevent background application processes from consuming excessive computing resources.
[0055] Without a freezing mechanism, when a user switches an application from foreground to background, the corresponding process continues to run in the background of the electronic device. Therefore, with many background applications running on an electronic device, a large number of background processes will be consuming the device's computing resources. This can lead to a significant drain on the device's computing resources, causing it to lag or stutter.
[0056] Therefore, electronic devices can use a freezing mechanism to freeze the processes corresponding to background applications, thereby preventing these frozen processes from consuming computing resources. This avoids background applications consuming excessive computing resources and improves the smoothness of the electronic device.
[0057] In analyzing the issue of excessively long warm-start times for background applications, it was found that when electronic devices simultaneously use freezing and memory reclamation mechanisms to manage application processes, background application processes sometimes receive memory reclamation commands only after being frozen. Thus, although the frozen process receives the memory reclamation command, it cannot execute it. When the application is switched from the background to the foreground, the frozen process is unfrozen and can receive the necessary launch commands. However, because the process received the memory reclamation command before being frozen, it executes the reclamation command first, followed by the launch commands. This results in the excessively long warm-start time for the background application.
[0058] In some embodiments, such as Figure 1As shown, application A, which is running in the foreground, receives instructions 1, 2, and 3 in chronological order. Therefore, application A will execute instruction 1 first, then instruction 2, and finally instruction 3.
[0059] Subsequently, in response to the user's action of switching application A from the foreground to the background, the electronic device switches application A from the foreground to the background. After application A is switched to the background, without the electronic device freezing application A, application A receives instructions 4 and 5 in chronological order, such as... Figure 1 As shown, application A will execute instruction 4 first, and then instruction 5.
[0060] Next, if application A meets the freezing conditions in the freezing mechanism, the electronic device will freeze the process corresponding to application A. At this time, if application A receives a memory reclamation command, application A will not execute the memory reclamation command, but will instead retain the memory reclamation command and wait.
[0061] Finally, in response to the user's action of switching application A to the foreground, the electronic device switches application A from the background to the foreground. Specifically, in response to the user's action of switching application A from the background to the foreground, the electronic device unfreezes the process corresponding to application A, and application A receives a startup-related instruction, such as a startup command. Since the memory reclamation instruction received by application A has not yet been executed, application A executes the memory reclamation instruction first, and then executes the startup command. After application A completes the startup process, application A completes its startup process and its interface can be displayed in the foreground of the electronic device.
[0062] It should be noted that in the freezing mechanism of this application embodiment, if the application process is frozen, the process does not receive instructions belonging to synchronous requests, but only instructions belonging to asynchronous requests. Before instructions belonging to synchronous requests are executed, the electronic device cannot perform other operations, while before instructions belonging to asynchronous requests are executed, the electronic device can perform other operations. Therefore, if the frozen process can receive instructions belonging to synchronous requests, the frozen process will be unable to execute those instructions, and before those instructions are executed, the electronic device will also be unable to perform any further operations, resulting in a system crash. Therefore, by ensuring that the frozen process only receives instructions belonging to asynchronous requests, the normal operation of the electronic device can be guaranteed. The memory reclamation instruction in this application embodiment is an asynchronous request instruction.
[0063] The hot start time of application A starts from the moment the user switches application A from the background to the foreground and ends when application A completes the startup command. It can be seen that after receiving the user's command to switch application A from the background to the foreground, application A first executes a memory reclamation command and then executes the startup command, resulting in an excessively long hot start time. Therefore, after switching application A from the background to the foreground, the user has to wait a considerable amount of time before seeing the application A's interface, leading to a poor user experience.
[0064] Furthermore, in the above embodiments, after application A is switched to run in the background, the process corresponding to application A only receives the memory reclamation instruction after it is frozen, but it is unable to execute the memory reclamation instruction to release the occupied memory. Thus, although the electronic device uses the memory reclamation mechanism to reclaim the occupied memory, it does not achieve a good memory reclamation effect.
[0065] Furthermore, after application A switches from the background to the foreground, it first executes a memory reclamation command and then a startup command. Because application A releases the memory it occupies after executing the memory reclamation command, it may then need to re-allocate that released memory when executing the startup command. This not only results in ineffective memory reclamation but also wastes time. In addition, the frequent memory release and allocation during this process can easily lead to memory thrashing issues.
[0066] Based on this, this application provides a process management method applied to electronic devices. The electronic device can send a memory reclamation command to the process corresponding to an application before the process is frozen, avoiding sending the memory reclamation command to the frozen process. This prevents the frozen process from executing the memory reclamation command before entering the startup process after thawing. Thus, the warm restart time of the application can be effectively reduced.
[0067] Furthermore, this method enables application processes to execute memory reclamation instructions in a timely manner to release occupied memory, thereby improving the effectiveness of memory reclamation.
[0068] In addition, the above methods can also avoid frequent memory release and allocation by electronic devices, thereby avoiding memory thrashing problems.
[0069] To better understand the embodiments of this application, the electronic device provided in the embodiments of this application will first be introduced.
[0070] The process management method provided in this application can be applied to electronic devices. For example, the electronic device can specifically be a mobile phone, tablet computer, smart screen, in-vehicle device, wearable device (such as a smartwatch), ultra-mobile personal computer (UMPC), netbook, personal digital assistant (PDA), artificial intelligence device, or other electronic device that uses memory reclamation and freezing mechanisms. This application does not limit the specific type of electronic device 100 or the operating system installed on it.
[0071] Figure 2 A schematic diagram of the structure of electronic device 100 is shown. Electronic device 100 may include processor 110, external memory interface 120, internal memory 121, universal serial bus (USB) interface 130, charging management module 140, power management module 141, battery 142, display screen 194, etc.
[0072] It is understood that the structures illustrated in the embodiments of this application do not constitute a specific limitation on the electronic device 100. In other embodiments of this application, the electronic device 100 may include more or fewer components than illustrated, or combine some components, or split some components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
[0073] Processor 110 may include one or more processing units, such as: application processor (AP), modem processor, graphics processing unit (GPU), image signal processor (ISP), controller, memory, video codec, digital signal processor (DSP), baseband processor, and / or neural network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.
[0074] The controller can be the nerve center and command center of the electronic device 100. The controller can generate operation control signals according to the instruction opcode and timing signals to complete the control of fetching and executing instructions.
[0075] The processor 110 may also include a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. This memory can store instructions or data that the processor 110 has just used or that are used repeatedly. If the processor 110 needs to use the instruction or data again, it can retrieve it directly from the memory. This avoids repeated accesses, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.
[0076] Digital signal processors (DSPs) are used to process digital signals. Besides digital image signals, they can also process other digital signals. For example, when electronic device 100 selects a frequency, the DSP performs Fourier transforms on the frequency energy.
[0077] The external storage interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100. The external memory card communicates with the processor 110 through the external storage interface 120 to perform data storage functions. For example, music, video, and other files can be saved on the external memory card.
[0078] Internal memory 121 can be used to store computer executable program code, which includes instructions. Processor 110 executes various functional applications and data processing of electronic device 100 by running the instructions stored in internal memory 121. Internal memory 121 may include a program storage area and a data storage area. The program storage area may store the operating system, at least one application program required for a function (such as sound playback, image playback, etc.), etc. The data storage area may store data created during the use of electronic device 100 (such as audio data, phonebook, etc.). Furthermore, internal memory 121 may include high-speed random access memory and may also include non-volatile memory, such as at least one disk storage device, flash memory device, universal flash storage (UFS), etc.
[0079] In some embodiments, the processor 110 may include one or more interfaces. Interfaces may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.
[0080] USB port 130 is a USB standard compliant interface, specifically a Mini USB port, Micro USB port, USB Type-C port, etc. USB port 130 can be used to connect a charger to charge electronic device 100, and can also be used for data transfer between electronic device 100 and peripheral devices. It can also be used to connect headphones for audio playback. This interface can also be used to connect other electronic devices, such as AR devices.
[0081] It is understood that the interface connection relationships between the modules illustrated in the embodiments of this application are merely illustrative and do not constitute a structural limitation on the electronic device 100. In other embodiments of this application, the electronic device 100 may also employ different interface connection methods or combinations of multiple interface connection methods as described in the above embodiments.
[0082] The charging management module 140 receives charging input from a charger, which can be a wireless charger or a wired charger. While charging the battery 142, the charging management module 140 can also power the electronic device via the power management module 141. The power management module 141 is connected to the battery 142 and receives input from the battery 142 and / or the charging management module 140 to power the processor 110, internal memory 121, external memory, display screen 194, etc. In some other embodiments, the power management module 141 may also be located within the processor 110. In other embodiments, the power management module 141 and the charging management module 140 may be located in the same device.
[0083] Electronic device 100 implements display functions through a GPU, a display screen 194, and an application processor. The GPU is a microprocessor for image processing, connected to the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations and for graphics rendering. Processor 110 may include one or more GPUs, which execute program instructions to generate or modify display information.
[0084] The display screen 194 is used to display images, videos, etc. The display screen 194 includes a display panel. In some embodiments, the electronic device 100 may include one or N display screens 194, where N is a positive integer greater than 1.
[0085] The software system of electronic device 100 can adopt a layered architecture, event-driven architecture, microkernel architecture, microservice architecture, or cloud architecture. This application embodiment uses a layered operating system as an example to exemplify the software structure of electronic device 100.
[0086] Figure 3 This is a software structure block diagram of the electronic device 100 according to an embodiment of this application.
[0087] A layered architecture divides software into several layers, each with a clear role and function. Layers communicate with each other through software interfaces. In some embodiments, the operating system is divided into four layers, from top to bottom: the application layer, the application framework layer, the runtime and system libraries, and the kernel layer.
[0088] It should be noted that the embodiments of this application are illustrated using a common operating system as an example. In other operating systems, the solution of this application can also be implemented as long as the functions implemented by each functional module are similar to those in the embodiments of this application.
[0089] The application layer can include a series of application packages. For example... Figure 3 As shown, the application package may include applications such as camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, and SMS.
[0090] The application framework layer provides application programming interfaces (APIs) and a programming framework for applications in the application layer. The application framework layer includes some predefined functions.
[0091] like Figure 3 As shown, the application framework layer may include a freeze management module, a memory management module, and an application management system (Activity Manager Service, AMS), etc.
[0092] The freeze management module is used to send freeze commands to applications that have switched to running in the background, thereby freezing the processes of the background applications and preventing them from consuming too many computing resources.
[0093] The memory management module is used to send memory reclamation notification messages to the application management system based on the application's state, so as to notify the application management system to send memory reclamation instructions to the application.
[0094] An application management system is used to manage the lifecycle of applications, including operations such as application startup, switching, and destruction. The application management system also manages the resource usage of applications. In the embodiments of this application, the application management system can perform corresponding management operations based on user actions on the application. For example, when a user starts an application, the application management system can create a process corresponding to that application to support its operation. As another example, when a user switches an application from the foreground to the background, the application management system can send notification messages to both the freeze management module and the memory management module, enabling the freeze management module to freeze the application in the background and the memory management module to reclaim memory from the application in the background.
[0095] The runtime includes the core libraries and the virtual machine. The runtime is responsible for the scheduling and management of the operating system.
[0096] The core library consists of two parts: one part is the functionalities that need to be called by the Java language, and the other part is the Android core library.
[0097] The application layer and application framework layer run in a virtual machine. The virtual machine executes the Java files of the application layer and application framework layer as binary files. The virtual machine is used to perform functions such as object lifecycle management, stack management, thread management, security and exception management, and garbage collection.
[0098] The system library can include multiple functional modules. For example: surface manager, three-dimensional (3D) graphics processing library (e.g., OpenGL ES), two-dimensional (2D) graphics engine (e.g., SGL), etc.
[0099] The Surface Manager is used to manage the display subsystem and provides the blending of 2D and 3D layers for multiple applications.
[0100] The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, compositing, and layer processing.
[0101] A 2D graphics engine is a graphics engine for 2D drawing.
[0102] The kernel layer is the layer between hardware and software. The kernel layer includes freezer drivers, binder drivers, and more.
[0103] The freeze driver is used to freeze and unfreeze application processes. For example, if the freeze management module needs to freeze or unfreeze a process corresponding to a specific application, the freeze management module can send the relevant freeze or unfreeze information to the freeze driver, informing the freeze driver which application's process needs to be frozen or unfrozen. The freeze driver then performs the freeze or unfreeze operation on the process corresponding to the application that needs to be frozen or unfrozen.
[0104] The binder driver is used to provide communication for inter-process calls and data transfer. For example, if process M and process N need to communicate, process M can send an inter-process communication request to the binder driver, requesting communication with process N. The binder driver then locates process N based on the inter-process communication request and establishes a communication connection between process M and process N, enabling them to communicate. Detailed information about the inter-process communication process via the binder driver can be found in relevant technical documents and will not be elaborated here.
[0105] The process management method provided in this application is described below in conjunction with the software architecture of electronic devices.
[0106] The following, combined with Figure 4 This application describes the implementation of a process management method. This process management method is applied to electronic devices, such as… Figure 4 As shown, the method may include the following steps:
[0107] S401. In response to the application switching from the foreground to the background, the application management system sends a notification message to the memory management module and the freeze management module that the application has been switched to run in the background.
[0108] The foreground application can be the application corresponding to the interface currently displayed on the screen of an electronic device. It should be noted that the interface content of the foreground application can include not only the screen visible to the user, but also content without a user interface, content with transparent layers, or content that is not visible to the user but is obscured by other application interfaces.
[0109] In some examples, the actions of switching an application from the foreground to the background include actions such as user-instructed exit from the application's display interface, such as actions on the home screen, voice control of the application, and switching other applications to run in the foreground.
[0110] The notification message indicating that the application has been switched to run in the background may refer to the first notification message in this application.
[0111] After the electronic device executes S401, in order to ensure that the application process can be reclaimed before it is frozen, the electronic device can first execute the memory reclamation process (S402-S404) after executing S401, and only after executing S404 will the electronic device continue to execute the process freezing process (S405).
[0112] S402. In response to receiving a notification message that the application has been switched to the background, the memory management module sends a memory reclamation notification message to the application management system.
[0113] In some embodiments, an application is not immediately frozen after being switched to the background. Therefore, at the moment the notification message that the application has been switched to the background is received, the process corresponding to the application has not yet been frozen. At this time, the memory management module can promptly send a memory reclamation notification message to the application management system, even though the application has been switched to the background and has not yet been frozen, so as to notify the application management system to send memory reclamation instructions to the application in a timely manner.
[0114] The memory reclamation notification message may refer to the second notification message in this application.
[0115] In some examples, the electronic device can freeze the application after S seconds since it was switched to the background. Then, the memory management module sends a memory reclamation notification message to the application management system after St seconds since the application was switched to the background. Here, S and t are both positive numbers, and S is greater than t.
[0116] In this application, the first moment is the time after the memory management module receives the notification message that the application has been switched to the background, that is, the first moment is St seconds after the application is switched to the background, and the second moment is S seconds after the application is switched to the background.
[0117] S403. In response to receiving a memory reclamation notification message, the application management system sends a memory reclamation instruction to the application.
[0118] In some embodiments, the memory reclamation command sent by the application management system to the application may be a TRIM command. The TRIM command is a subcommand in the Advanced Technology Attachment (ATA) command set, also known as the disable delete notify command. The TRIM command allows the solid-state drive (SSD) to determine which data blocks are no longer considered for use and can be internally erased. By using the TRIM command, no content is retained in the corresponding data blocks in the SSD, resulting in fewer writes, higher write throughput, and thus increased drive lifespan.
[0119] The memory reclamation instruction sent by the application management system to the application can be the first instruction in this application.
[0120] S404. In response to receiving a memory reclamation command, the process corresponding to the application executes the memory reclamation command.
[0121] At this point, the application can execute memory reclamation commands to release excess memory resources occupied by the application's corresponding process, thereby improving the efficiency of memory release.
[0122] After executing S404, the electronic device can continue the following process freezing process:
[0123] S405. In response to receiving a notification message that the application has been switched to the background, the freeze management module freezes the application.
[0124] In some embodiments, the freeze management module can freeze the application process through a kernel-level freeze driver.
[0125] In the above embodiments, the freeze management module freezes the application only after the process corresponding to the application executes the memory reclamation instruction. This ensures that the memory reclamation instruction is executed before the application's process is frozen, guaranteeing that the application's process can release its occupied memory resources in a timely manner, thereby improving memory resource optimization. Furthermore, it avoids the situation where the application's process is frozen before receiving the memory reclamation instruction, preventing the frozen process from being unable to respond to the instruction for an extended period.
[0126] Furthermore, since the application process has already issued a memory reclamation command to the application before being frozen, it is possible to avoid receiving the memory reclamation command while the application process is in a frozen state. Thus, when the application is subsequently switched from the background to the foreground, its corresponding process will not execute the memory reclamation command received in the frozen state to release memory before executing the relevant instructions for the application's warm-up process after being unfrozen. This reduces the application's warm-up time and can also avoid memory thrashing issues.
[0127] Optionally, after executing S403, the application management system may refrain from sending any further memory reclamation commands to the application. This avoids the application management system sending memory reclamation commands to the frozen application process after the application process has been frozen.
[0128] Optionally, after the electronic device executes S403, the application management system can also record the level of the memory reclamation command it sent to the application, so that the application management system can determine whether it can send the memory reclamation command to the application again based on the recorded level of the memory reclamation command.
[0129] For example, after sending a memory reclamation command to an application, the application management system records the level of that command. Later, if the application management system needs to send a new memory reclamation command to the application, it can send the new command only if its level is higher than the previously sent command; otherwise, it will not send a new command. The higher the level of the memory reclamation command executed by the application process, the more memory is released.
[0130] In this application, the application management system needs to send a new memory reclamation instruction to the application, which can be the second instruction in this application. The levels of the first and second instructions are used to indicate the importance of the instructions. In some of the above embodiments, the higher the level of the instruction, the greater its importance, and the more memory the instruction instructs the application to release.
[0131] For example, when the electronic device executes S403, the application management system sends a memory reclamation command A to the application, and records the level of memory reclamation command A as medium. Subsequently, the application management system needs to send a new memory reclamation command B to the application, and the level of memory reclamation command B is also medium. Then, the application management system can determine that the level of memory reclamation command B is no higher than the level of the previously sent memory reclamation command A. Therefore, the application management system does not send a new memory reclamation command B to the application.
[0132] This avoids the frozen process receiving new memory reclamation instructions of low priority, thus preventing the unfrozen process from having to execute the new memory reclamation instructions of low priority before executing the startup instructions after the application is switched to the foreground, thereby avoiding the problem of excessively long application warm restart time.
[0133] For example, when an electronic device executes S403, the application management system sends a memory reclamation command A to the application, and records the level of memory reclamation command A as medium. The application management system then needs to send a new memory reclamation command C to the application, and this memory reclamation command C is at a high level. Therefore, the application management system can determine that the level of memory reclamation command C is higher than the level of the previously sent memory reclamation command A; thus, the application management system needs to send the new memory reclamation command C to the application.
[0134] This ensures that high-level memory reclamation commands are sent to the frozen application process in a timely manner, improving memory optimization.
[0135] In some embodiments, in S403, the level of memory reclamation instructions sent by the application management system to the application can be pre-configured in the electronic device by the developers according to actual needs.
[0136] In some examples, developers can pre-configure the levels of memory reclamation commands sent by the application management system to applications in electronic devices, based on the common levels of these commands. For instance, memory reclamation commands are categorized into low, medium, and high levels. Low and medium levels are the most common, while high-level commands are less frequent. Therefore, developers can set the level of memory reclamation commands sent by the application management system to medium in S403 to ensure that applications execute common memory reclamation commands before their processes are frozen, and to prevent the application management system from repeatedly sending these commands to frozen applications.
[0137] In other examples, developers can pre-configure the level of memory reclamation commands sent by the application management system to applications based on the relationship between the electronic device's memory space and the memory usage of application processes. For example, assuming that each application process uses an average of 500 megabytes (MB) of memory, then with a total memory size of 2 gigabytes (GB) on the electronic device, the following two calculations apply: 2GB = 2048MB, 2048MB / 500MB ≈ 4.1. Therefore, the electronic device's memory can be used by approximately four application processes. User surveys show that most users habitually switch between six applications on their electronic devices, such as music, navigation, phone, maps, Bluetooth, and SMS. To ensure normal user experience, the electronic device can allocate memory to one foreground application and five background applications. That is, the electronic device needs to ensure that one foreground application process can use 500MB of the 2048MB of memory, and then the remaining 1548MB of memory is allocated to five background applications, with each background application receiving approximately 305MB of memory. In other words, after an application in the foreground is switched to the background, approximately 200MB of memory it occupies needs to be released to ensure that users can switch between up to six applications on their electronic devices. Therefore, developers can set the level of memory reclamation commands sent by the S403 application management system to applications to release approximately 200MB of memory. The above example is only one possible implementation; developers can determine the specific implementation based on their actual needs.
[0138] In some embodiments, in addition to sending memory reclamation instructions to the application upon receiving a memory reclamation notification message from the memory management module, as described in S403 above, the application management module can also send memory reclamation instructions to the application based on the application's process status.
[0139] In some examples, the application management system can monitor the status of all application processes. When the status of an application process changes, the application management system can determine, based on the application's process status, the necessary memory reclamation command to be sent to that application, and the level of that command. This includes all application processes, including frozen processes.
[0140] In some examples, application processes are categorized into foreground, visible, service, cached, and empty states. Foreground and visible processes do not have corresponding memory reclamation commands, while service, cached, and empty processes do. Furthermore, service processes correspond to low-level memory reclamation commands, cached processes to medium-level commands, and empty processes to high-level commands. When the application management system detects a change in the application process's state, and the changed process is in a cached state, the application management system can send a medium-level memory reclamation command to the application. Similarly, when the application management system detects a change in the application process's state, and the changed process is in an empty state, the application management system can send a high-level memory reclamation command to the application.
[0141] Different application process states correspond to different memory reclamation priorities. For example, the foreground state has the lowest memory priority, the empty state has the highest memory priority, and the memory priorities increase sequentially for the visible, service, and cached states. Therefore, the process state of an application can also be referred to as the preset level. A process level being downgraded to the preset level can be understood as a change in the application's process state, where the memory priority corresponding to the changed process state meets the conditions for the application management system to send a memory reclamation instruction to that application.
[0142] In some embodiments, such as Figure 4 As shown, when an application is switched to the background and the process corresponding to that application is frozen, the electronic device can continue executing subsequent processes (S406-S407) in response to the operation of switching the application to the foreground:
[0143] S406. In response to the application being switched from the background to the foreground, the application management system sends a notification message to the freeze management module that the application has been switched to the foreground.
[0144] S407. In response to receiving a notification message that the application has been switched to the foreground, the freeze management module unfreezes the application.
[0145] In some embodiments, the freeze management module can unfreeze the application process through a kernel-level freeze driver.
[0146] In the above embodiment, after receiving a notification message that the application has been switched to the foreground, the freeze management module can directly unfreeze the application. Furthermore, since the application process has already executed the memory reclamation instruction in the aforementioned S404 process, the unfrozen application process no longer processes the memory reclamation instruction and directly executes the startup instruction, achieving the goal of quickly switching the application from the background to the foreground to begin running. This effectively reduces the duration of a warm start.
[0147] The following, combined with Figure 5 This application introduces an alternative implementation of a process management method. This process management method is applied to electronic devices, such as... Figure 5 As shown, the method may include the following steps:
[0148] S501. In response to the application being switched to the foreground, the application management system sends a notification message to the memory management module that the application has been switched to the foreground.
[0149] The operation of switching an application to run in the foreground can include the operation of switching an application from running in the background to running in the foreground.
[0150] S502. In response to receiving a notification message that the application has been switched to the foreground, the memory management module sends a notification message to the application management system to cancel memory reclamation.
[0151] S503. In response to receiving the memory reclamation cancellation notification message, the application management system sends a memory reclamation cancellation command to the application.
[0152] Specifically, the memory management module sends a memory reclamation cancellation notification message to the application management system, instructing the application management system to send a memory reclamation cancellation command to the application. The memory reclamation cancellation command sent by the application management system to the application instructs the application's process not to execute any received memory reclamation commands.
[0153] In the above process, because the application receives a memory reclamation command when it is frozen, and when the application is switched to the foreground, the application process executes the memory reclamation command before the startup command after being unfrozen, resulting in an excessively long warm start time. Therefore, when the application is switched to the foreground, the electronic device can instruct the application management system to send a memory reclamation cancellation command to the application through the memory management module, so as to instruct the application not to execute the received memory reclamation command.
[0154] S504. In response to receiving a memory reclamation cancellation command, the application sets a flag that disallows memory reclamation for the corresponding process.
[0155] The "Do not run memory reclamation" flag is used to instruct processes to clean up or delete received memory reclamation commands. In some embodiments, the memory reclamation cancellation command sent by the application management system to the application may be a "cancel trim" command. When the application receives a "cancel trim" command, it sets a "do not run trim" flag for the corresponding process. If the application's process has a "do not run trim" flag set, the application can determine whether it has received a memory reclamation command. If it has, the application can delete the received memory reclamation command.
[0156] In some embodiments, an application can execute memory reclamation instructions through a handleTrimMemory process, which includes the following steps:
[0157] a. Determine if the process corresponding to the application currently has a "disallow trim" flag set.
[0158] b. If the process corresponding to the application currently has a "trim not allowed" flag set, delete the pending memory reclamation instructions for that application.
[0159] c. Remove the "disallow trim" flag currently set for the process corresponding to the application.
[0160] Therefore, if a background application process receives any memory reclamation command while it is frozen, the electronic device can set a memory reclamation disallowance flag for the application process through the above process in response to the application being switched from the background to the foreground. This prevents the application process from executing any received memory reclamation commands. Consequently, after the application process is unfrozen, it cannot execute the memory reclamation commands it received during the freezing period, thus avoiding the problem of excessively long warm-start times.
[0161] In the above embodiments, the memory reclamation instruction can be the first instruction in this application.
[0162] The following, combined with Figure 6 This application describes an implementation of a process management method. This process management method is applied to electronic devices and includes the following steps:
[0163] S601, the application management system sends memory reclamation instructions to the application.
[0164] Among them, the memory reclamation instruction can be the first instruction in this application.
[0165] The electronic device can implement the memory release process through the following procedures (S602-S604):
[0166] S602. In response to receiving a memory reclamation command, the application determines whether it is currently in the warm start phase.
[0167] In some embodiments, the system process for managing application startup can monitor whether all applications are in a warm start state. The application process can communicate with the system process for managing application startup through the binder driver to determine whether the application is in the warm start phase.
[0168] The application is currently in the hot start phase, which can refer to the process of the application switching from the background to the foreground.
[0169] If the application is currently in the warm start phase, the electronic device executes the following S603:
[0170] S603, The application stops executing memory reclamation instructions.
[0171] In some embodiments, firstly, in S601, the application management system sends a memory reclamation instruction to the background application whose process is frozen. Then, in S602, the application switches from the background to the foreground. The application can first determine that it is currently in the hot start phase, so the application will not execute the memory reclamation instruction.
[0172] This avoids the application process executing memory reclamation instructions before startup instructions after being unfrozen, thus preventing the application from taking too long to start warmly.
[0173] After the electronic device executes S602, if the application determines that it is not currently in the warm start phase, the electronic device executes the following S604:
[0174] S604, The application continues to execute memory reclamation instructions.
[0175] If an application is not in the warm-start phase, whether or not it executes memory reclamation instructions does not affect the performance of the electronic device. Therefore, applications can execute memory reclamation instructions to improve memory optimization.
[0176] In this context, "the application is not currently in a warm start phase" can refer to any process that does not belong to the process of the application switching from the background to the foreground. For example, the process of the application switching from a closed state to a started state, or the process of switching from the foreground to the background, etc.
[0177] Generally, in response to receiving a memory reclamation command, an application can begin executing the `handleTrimMemory` process to execute the memory reclamation command. In this embodiment, before executing the `handleTrimMemory` process, the application can first determine whether it is currently in a warm start phase. If so, the `handleTrimMemory` process will not be executed. This avoids the problem of excessively long warm start times caused by applications in the warm start phase executing memory reclamation commands.
[0178] The following, combined with Figure 7 This application describes an implementation of a process management method. This process management method is applied to electronic devices and includes the following steps:
[0179] S701, the application management system obtains memory reclamation instructions.
[0180] This memory reclamation command is used to instruct the application to release memory. Therefore, after receiving the memory reclamation command, the application management system needs to send the memory reclamation command to the application.
[0181] The application management system can obtain memory reclamation instructions in several ways. First, the memory management module can send a memory reclamation notification message to the application management system to instruct it to send memory reclamation instructions to the application, as shown in S402 of the above embodiment. Second, the application management system can send memory reclamation instructions to the application based on the application's process status; see the above-mentioned methods for details. Figure 4 The corresponding implementation examples will not be described in detail here.
[0182] Before the application management system sends a memory reclamation instruction to the application, the electronic device executes the following S702:
[0183] S702, the application management system determines whether the application process is frozen.
[0184] If the application management system determines that the application process is frozen, the electronic device executes the following S703:
[0185] S703, the application management system does not send memory reclamation commands to applications.
[0186] If the application management system determines that the application process is not frozen, the electronic device executes the following S704:
[0187] S704, the application management system sends memory reclamation commands to the application.
[0188] In some embodiments, when the process of application A is frozen but the process of application B is not frozen, and when the application management system needs to send memory reclamation instructions to application A and application B respectively, the application management system can have the following two implementation processes.
[0189] Because the application management system can determine that application A's process is frozen, it will not send memory reclamation commands to application A. In other words, application A with its process frozen will not receive memory reclamation commands. Even if application A with its process frozen switches from the background to the foreground, it will only execute the startup command, not the memory reclamation command first and then the startup command. This avoids the problem of excessively long warm-start times caused by applications in the warm-start phase executing memory reclamation commands.
[0190] Since the application management system can determine that application B's process is not frozen, it sends a memory reclamation command to application B. In other words, application B, whose process is not frozen, can receive and execute the memory reclamation command. This effectively improves the efficiency of memory reclamation.
[0191] This application also provides a computer-readable storage medium including computer instructions that, when executed on the electronic device, cause the electronic device to perform the various functions or steps described in the method embodiments.
[0192] This application also provides a computer program product, including a computer program that, when run on an electronic device, causes the electronic device to perform the various functions or steps described in the above method embodiments.
[0193] Through the above description of the embodiments, those skilled in the art can clearly understand that, for the sake of convenience and brevity, only the division of the above functional modules is used as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.
[0194] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another device, or some features may be ignored or not executed. Furthermore, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.
[0195] The units described as separate components may or may not be physically separate. A component shown as a unit can be one or more physical units; that is, it can be located in one place or distributed in multiple different locations. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0196] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0197] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solutions of the embodiments of this application, essentially or in other words, the parts that contribute to the prior art, or all or part of the technical solutions, can be embodied in the form of a software product. This software product is stored in a storage medium and includes several instructions to cause a device (which may be a microcontroller, chip, etc.) or processor to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0198] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions within the technical scope disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A process management method, characterized in that, The method, applied to an electronic device including an application program, an application management system, and a memory management module, comprises: In response to a user operation that switches the application from the foreground to the background, the application management system sends a first notification message to the memory management module, the first notification message being used to instruct the application to switch to the background; The memory management module sends a second notification message to the application management system at a first moment, the second notification message being used to instruct the application management system to issue a first instruction; the first moment is the moment after a preset time has elapsed since the first notification message was received; the first instruction is used to trigger the application to release the memory occupied by the process corresponding to the application; In response to the second notification message, the application management system sends a first instruction to the application. In response to the user operation, a process freeze is triggered at a second time point, wherein the process freeze is to freeze the process corresponding to the application; wherein the first time point is before the second time point. In response to the application's process level being downgraded to a preset level, if the application management system determines that the level of the second instruction to be sent to the application is lower than the level of the first instruction, the second instruction is intercepted; wherein, the second instruction is an instruction to be sent to the application to trigger memory reclamation in response to the application's process level being downgraded to a preset level.
2. The method according to claim 1, characterized in that, After the application management system sends a first instruction to the application in response to the first notification message, the method further includes: The application management system records the level of the first instruction sent.
3. The method according to claim 1 or 2, characterized in that, The method further includes: In response to a user action that brings the application to the foreground, the memory management module sends an interception command to the application; In response to the interception instruction, if there is a first instruction to be executed, the application stops processing the first instruction.
4. The method according to claim 1 or 2, characterized in that, The method further includes: If there is a first instruction to be executed, the application determines whether the application is in the warm start phase; If the application is in a warm-start phase, stop processing the first instruction.
5. The method according to claim 1 or 2, characterized in that, The method further includes: In response to the application's process level being downgraded to a preset level, the application management system determines whether the application has been frozen. If the application is frozen, stop sending the first instruction to the application.
6. An electronic device, characterized in that, The electronic device includes a memory and one or more processors; the memory and the processors are coupled; the memory stores computer program code, which includes computer instructions; the electronic device includes an application program, an application management system, and a memory management module; when the processor executes the computer instructions, the electronic device is used for: In response to a user operation that switches the application from the foreground to the background, the application management system sends a first notification message to the memory management module, the first notification message being used to instruct the application to switch to the background; The memory management module sends a second notification message to the application management system at a first moment, the second notification message being used to instruct the application management system to issue a first instruction; the first moment is the moment after a preset time has elapsed since the first notification message was received; the first instruction is used to trigger the application to release the memory occupied by the process corresponding to the application; In response to the second notification message, the application management system sends a first instruction to the application. In response to the user operation, a process freeze is triggered at a second time point, wherein the process freeze is to freeze the process corresponding to the application; wherein the first time point is before the second time point. In response to the application's process level being downgraded to a preset level, if the application management system determines that the level of the second instruction to be sent to the application is lower than the level of the first instruction, the second instruction is intercepted; wherein, the second instruction is an instruction to be sent to the application to trigger memory reclamation in response to the application's process level being downgraded to a preset level.
7. The electronic device according to claim 6, characterized in that, After the application management system sends a first instruction to the application in response to the first notification message, the electronic device is further configured to: The application management system records the level of the first instruction sent.
8. The electronic device according to claim 6 or 7, characterized in that, The electronic device is also used for: In response to a user action that brings the application to the foreground, the memory management module sends an interception command to the application; In response to the interception instruction, if there is a first instruction to be executed, the application stops processing the first instruction.
9. A computer-readable storage medium, characterized in that, Includes computer instructions that, when executed on an electronic device, cause the electronic device to perform the method as described in any one of claims 1-5.
10. A computer program product comprising a computer program / instructions, characterized in that, When the computer program / instructions are executed by the processor, the electronic device performs the method as described in any one of claims 1-5.
Citation Information
Patent Citations
Method and device for control over terminal equipment, terminal equipment and computer readable storage medium
CN108287760A