Process processing method and device and electronic equipment
By combining the process's recycling priority and start-stop time interval in electronic devices, the memory recycling process is optimized, and the problem of poor memory recycling is solved, which reduces system load and improves performance and user experience.
Patent Information
- Application Number
- CN202510638807.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-16
- Publication Date
- 2025-08-01
AI Technical Summary
In the prior art, electronic devices have poor effectiveness in process memory recovery, resulting in frequent memory recovery and allocation operations, affecting system performance and user experience.
By referring to the process's recycling priority and start-stop time interval, the process to be recycled is determined and memory recovery is performed, reducing the probability of the same process being quickly restarted and requested for memory.
Improve the effectiveness of memory recycling, avoid system load caused by frequent memory recycling and allocation, and improve system performance and user experience.
Smart Images

Figure CN120407192A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and more particularly, to a process processing method, apparatus, and electronic device. Background Art
[0002] During the operation of an electronic device, processes (application programs) in the electronic device use the memory of the electronic device to complete corresponding tasks. Among them, the electronic device can process the processes according to the memory usage of the processes. However, the related processing methods still have the problem of poor effectiveness. Summary of the Invention
[0003] In view of the above problems, this application proposes a process processing method, apparatus, and electronic device to improve the above problems.
[0004] In a first aspect, this application provides a process processing method applied to an electronic device. The method includes: determining a process to be recycled in response to meeting a recycling trigger condition, where the process to be recycled is determined by the recycling priority of the process and the start-stop time interval of the process, and the start-stop time interval represents the time interval from when the process is closed to the next start; performing memory recycling on the process to be recycled to meet the memory recycling requirement.
[0005] In a second aspect, this application provides a process processing apparatus running on an electronic device. The apparatus includes: a process determination unit for determining a process to be recycled in response to meeting a recycling trigger condition, where the process to be recycled is determined by the recycling priority of the process and the start-stop time interval of the process, and the start-stop time interval represents the time interval from when the process is closed to the next start; a memory recycling unit for performing memory recycling on the process to be recycled to meet the memory recycling requirement.
[0006] In a third aspect, this application provides an electronic device including one or more processors and a memory; one or more programs are stored in the memory and configured to be executed by the one or more processors to implement the above method.
[0007] In a fourth aspect, this application provides a computer-readable storage medium storing program code, where the above method is executed when the program code is run by a processor.
[0008] In a fifth aspect, this application provides a computer program product including a computer program or instruction, where when the computer program or instruction is executed by a processor, the above method is implemented.
[0009] A process processing method, apparatus, and electronic device provided by the present application. In this method, when the recycling trigger condition is met, the process to be recycled can be determined based on the recycling priority of the process and the start-stop time interval of the process, and then memory recycling is performed on the process to be recycled. Thus, during the process of memory recycling of the process, not only the recycling priority of the process is considered, but also the start-stop time interval of the process is considered, thereby reducing the probability that the memory of the same process is recycled and then quickly starts and applies for memory allocation again, improving the effectiveness of memory recycling, and also avoiding increasing the additional system load caused by frequent memory recycling and allocation. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] To more clearly illustrate the technical solutions in the embodiments of the present application, the following will briefly introduce the accompanying drawings required for the description of the embodiments. Obviously, the accompanying drawings in the following description are only some embodiments of the present application. For those skilled in the art, without creative efforts, other accompanying drawings can be obtained based on these drawings.
[0011] Figure 1 Shows a flowchart of a process processing method proposed in an embodiment of the present application;
[0012] Figure 2 Shows a flowchart of determining memory overrun in an embodiment of the present application;
[0013] Figure 3 Shows a schematic diagram of processing a memory overrun process in an embodiment of the present application;
[0014] Figure 4 Shows a schematic diagram of determining and updating the recycling priority of a process in an embodiment of the present application;
[0015] Figure 5 Shows a schematic diagram of the start-stop time interval in an embodiment of the present application;
[0016] Figure 6 Shows a flowchart of a process processing method proposed in another embodiment of the present application;
[0017] Figure 7 Shows a schematic diagram of a recycling priority sorting in an embodiment of the present application;
[0018] Figure 8 Shows a schematic diagram of a recycling priority sorting in an embodiment of the present application;
[0019] Figure 9 Shows a schematic diagram of determining the historical start-stop time interval in an embodiment of the present application;
[0020] Figure 10A schematic diagram showing the most recent M historical start-stop time intervals in an embodiment of the present application is shown;
[0021] Figure 11 A schematic diagram showing the most recent Z historical start-stop time intervals in an embodiment of the present application is shown;
[0022] Figure 12 A flow chart of the detection process currently being detected in an embodiment of the present application is shown;
[0023] Figure 13 A flowchart of a process processing method proposed in another embodiment of the present application is shown;
[0024] Figure 14 A schematic diagram of determining a process to be recycled according to an embodiment of the present application is shown;
[0025] Figure 15 A structural block diagram of a process processing device proposed in an embodiment of the present application is shown;
[0026] Figure 16 A schematic diagram showing a system architecture proposed in an embodiment of the present application is shown;
[0027] Figure 17 A structural block diagram of an electronic device for executing a process processing method according to an embodiment of the present application is shown in real time in the present application;
[0028] Figure 18 The present invention shows a storage unit in real time for storing or carrying program codes for implementing the process processing method according to an embodiment of the present invention. DETAILED DESCRIPTION
[0029] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0030] Memory, also known as main memory, is directly addressable storage space made of semiconductor devices. Processes in electronic devices typically rely on memory to process data during operation. For example, during the startup process, a process acquires memory for use during or after startup. Data in memory is typically managed using memory pages. During operation, electronic devices can manage processes based on their memory usage. For example, when the electronic device is running low on memory or needs to increase available memory, the memory of some processes can be reclaimed.
[0031] However, the inventors found in their research that the related processing methods still have problems with poor effectiveness. For example, in the related processing methods, it is not considered that after the memory of a process is recycled, the process may quickly appear to apply for memory again (for example, for a process that is closed due to memory recycling, it may start again soon and then need to apply for memory), resulting in frequent memory recycling and allocation operations. This not only fails to effectively release memory, but also causes problems such as lag and overheating due to additional system load, affecting system performance and user experience.
[0032] Therefore, the process processing method, device, and electronic device in the present application are proposed. In this method, when the recycling trigger condition is met, the process to be recycled can be determined based on the recycling priority of the process and the start-stop time interval of the process, and then the memory of the process to be recycled is recycled. Thus, during the process of recycling the memory of a process, not only the recycling priority of the process is considered, but also the start-stop time interval of the process is considered, thereby reducing the probability that the memory of the same process will start and apply for memory allocation again soon after being recycled, improving the effectiveness of memory recycling, and also avoiding the additional system load caused by frequent memory recycling and allocation.
[0033] The following will specifically describe the embodiments of the present application with reference to the accompanying drawings.
[0034] Please refer to Figure 1 , a process processing method provided by an embodiment of the present application, which is applied to an electronic device. The method includes:
[0035] S110: In response to meeting the recycling trigger condition, determine the process to be recycled, where the process to be recycled is determined based on the recycling priority of the process and the start-stop time interval of the process, and the start-stop time interval represents the time interval from when the process is closed to the next start.
[0036] In the embodiments of the present application, a process can be understood as a process included in an application program. For example, the main process included in the application program. Alternatively, a process can also be directly understood as an application program. In the embodiments of the present application, the memory occupancy of a process can characterize how much memory the process is currently using. Alternatively, the memory occupancy of a process can also be understood as the memory that the electronic device has currently allocated to the process. Optionally, the memory occupancy of a process can be the memory occupancy value of the process. For example, the memory occupancy value can be the actual used physical memory PSS (Proportional Set Size). For example, the memory occupancy value of a certain process can be 500MB, or can be 1023MB, etc. Optionally, the memory occupancy of a process can also be the ratio of the memory occupied by the process to the total memory of the electronic device. For example, the occupancy of a certain process can be 5% of the total memory of the electronic device by the memory value used by the process.
[0037] Among them, the electronic device can obtain the memory occupancy of the process based on the target frequency. For example, the electronic device can obtain the memory occupancy of the process every 2 minutes.
[0038] In the embodiments of the present application, a corresponding recycling priority can be configured for each process. Among them, the recycling priority can be understood as the priority degree of the memory of the process being recycled. In one way, the higher the recycling priority of the process, the easier it is to perform memory recycling. Optionally, the recycling priority can be characterized by a numerical value. For example, when the recycling priority can be divided into four levels, the highest level of recycling priority can be characterized by the numerical value 1, the second highest level of recycling priority can be characterized by the numerical value 2, the relatively lower recycling priority can be characterized by the numerical value 3, and the relatively lowest recycling priority can be characterized by the numerical value 4.
[0039] In the embodiments of the present application, a corresponding recycling priority can be configured for the processes in the electronic device based on the same rule. Alternatively, for different processes, there can be different ways to determine the recycling priority.
[0040] As one way, in the embodiments of the present application, the processes included in the electronic device can include system processes and third-party processes. Among them, the system process can be understood as a process belonging to the system application. Among them, the system application can be understood as an application program whose flags attribute in the application package includes system. The third-party process can then be understood as a process belonging to the third-party application. Among them, the third-party application can be understood as an application program developed by a non-electronic device developer.
[0041] Optionally, there can be different ways to determine the recycling priority for system processes and third-party processes.
[0042] Among them, for system processes, the corresponding recycling priority can be determined by its corresponding ADJ (Adjustment Value). In an electronic device, the ADJ value is an indicator used to manage processes. By adjusting the ADJ value of a process, the performance of aspects such as the memory usage, CPU occupancy, and battery consumption of the process can be effectively controlled. As a way, if the ADJ value of a system process is larger, its corresponding recycling priority is higher. Or, for system processes, the corresponding recycling priority can also be determined by the importance value (appcare value) of the process. Among them, the importance value of the process can be determined by the special state of the process. Among them, the special state can include whether the process is running in the foreground, whether the process is visible, whether the process is performing audio output, whether the process is using a sensor, the recent usage times of the process, and whether the process belongs to one or more items in a certain whitelist.
[0043] Among them, for third-party processes, the corresponding recycling priority can be determined by the importance value of the process. Or, for third-party processes, the corresponding recycling priority can also be determined by the ADJ value of the process.
[0044] Optionally, in the case of dividing processes into system processes and third-party processes, for system processes and third-party processes, the corresponding recycling priority can also be determined in the same way. For example, for system processes and third-party processes, the corresponding recycling priority can be determined by the corresponding ADJ value. Or, for system processes and third-party processes, the corresponding recycling priority can be determined by the corresponding importance value.
[0045] As a way, the importance value of the process can be determined and stored in the electronic device by the electronic device in advance; for example, the electronic device stores the correspondence between the process identifier and the importance value of the process. Correspondingly, this step can be: the electronic device determines the importance value of the process from the correspondence between the process identifier and the importance value based on the process identifier of the process. In the embodiments of the present application, the electronic device generates the importance value in advance and stores it locally; when it is necessary to determine the importance value of the process, the stored importance value is directly obtained, thereby improving the efficiency of determining the importance value of the application program.
[0046] In some other embodiments, the importance value of the process can be calculated by the electronic device in real time; correspondingly, this step can be implemented through the following steps (1) to (3), including:
[0047] (1) For any process, the electronic device determines the first-level value of the process based on the application attributes of the process.
[0048] Among them, the application attributes of a process can be understood as the attributes of the application program to which the process belongs. The application attributes include foreground applications (including foreground associated applications), sidebar applications, picture-in-picture applications, floating window applications, persistent applications, music applications, application list 1 (including the first and second most recently used applications), applications using Bluetooth connections (external devices such as bracelets or watches), applications using VPNs, desktop applications, dynamic wallpaper applications, cached processes that can be killed under severe low memory conditions (cached processes of foreground associated applications, cached processes of picture-in-picture applications, cached processes of floating applications), first locked applications (frequently used applications and super applications), cached processes that can be killed under moderate low memory conditions (cached processes of persist applications, cached processes of sidebar applications, cached processes of music applications, cached processes of applications using VPNs, cached processes of applications using Bluetooth connections, cached processes of dynamic wallpaper applications), second locked applications (locked applications of ordinary users), application list 1 (including the third and fourth most recently used applications), input method applications, applications being downloaded, list of recently used applets (recently used applets 2 to N), non-current user applets (recently used applets 1 to N), and other general applications.
[0049] In some embodiments, when the application attributes of a process include one, the electronic device determines the first level value corresponding to the application attribute of the process, and the level value corresponding to the application attribute is the first level value corresponding to the process. When the application attributes of a process include multiple, the electronic device respectively determines the first level value corresponding to each application attribute of the process; based on the first level value corresponding to each application attribute of the process, the electronic device determines the first level value of the process. For example, the electronic device determines the maximum level value from the first level values corresponding to each application attribute of the process and determines the maximum level value as the first level value of the process; or, the electronic device performs weighted summation on the first level values corresponding to each application attribute of the process to obtain the first level value of the process.
[0050] In some embodiments, the electronic device stores in advance the level value corresponding to the application attribute of the process; for example, the electronic device stores the correspondence between the application attribute and the level value; correspondingly, for any application attribute of the process, the step for the electronic device to determine the first level value corresponding to the application attribute can be: the electronic device determines the first level value corresponding to the application attribute from the correspondence between the application attribute and the level value based on the application attribute.
[0051] (2) The electronic device determines the second level value of the process based on the usage information of the process.
[0052] The usage information includes the usage duration, the number of cold starts, and the number of warm starts. Among them, the usage duration, the number of cold starts, and the number of warm starts respectively refer to the usage duration, the number of cold starts, and the number of warm starts within a preset duration closest to the current time. For example, the usage information includes the usage duration, the number of cold starts, and the number of warm starts in the most recent 1 month. Another example is that the usage information includes the usage duration, the number of cold starts, and the number of warm starts in the most recent week. Also, the usage duration can be the cumulative usage duration or the duration of the longest single use. The number of cold starts of a process refers to the number of times the process is started without running in the background. The number of warm starts of a process refers to the number of times the application program is started again when the process is already running in the background.
[0053] Correspondingly, this step can be: The electronic device determines the usage duration, the number of cold starts, and the number of warm starts of the process; inputs the usage duration, the number of cold starts, and the number of warm starts into the importance prediction model, and outputs the second-level value of the process. The importance prediction model is used to predict the second-level value of the application program based on the usage duration, the number of cold starts, and the number of warm starts, and the second-level value is used to represent the importance degree of the process.
[0054] (3) The electronic device performs weighted summation on the first-level value and the second-level value to obtain the importance value of the process.
[0055] For example, the electronic device performs weighted summation on the first-level value and the second-level value through the following formula (1) to obtain the importance value of the application program.
[0056] Formula (1): Y = a * X1 + b * X2.
[0057] Among them, Y represents the importance value of the process, X1 represents the first-level value, X2 represents the second-level value, a represents the weight corresponding to the first-level value, and b represents the weight corresponding to the second-level value. For example, the electronic device scans to obtain the running processes. For any process, the maximum first-level value among the first-level values corresponding to multiple application attributes of the process is used as the first-level value of the process; the second-level value of the application program is predicted through the importance prediction model; the weighted average of the first-level value and the second-level value is obtained to get the importance value of the process.
[0058] In the embodiments of the present application, the application attributes of the application program and the importance prediction model are combined to determine the importance value of the process, so as to improve the accuracy of the determined importance value, and further improve the accuracy of memory recycling based on the importance value of the process, and prevent the user from having a bad experience due to incorrect memory recycling.
[0059] As a classification method, the recycling priorities configured for system processes and third-party processes can be as shown in the following table:
[0060] Importance value 0-19 20-39 40-59 60-79 ADJ value Above 900 801-899 501-800 Below 500 Recycling priority 1 2 3 4
[0061] As shown in the above table, in an electronic device, the recycling priorities can be divided into four levels: 1, 2, 3, and 4. Among them, the value 1 represents the highest recycling priority, and the value 4 represents the lowest recycling priority.
[0062] Among them, for system processes with an ADJ value above 900, the configured recycling priority is level 1. For system processes with an ADJ value between 801 and 899, the configured recycling priority is level 2. For system processes with an ADJ value between 501 and 800, the configured recycling priority is level 3. For system processes with an ADJ value below 500, the configured recycling priority is level 4. Among them, for third-party processes with an importance value between 0 and 19, the configured recycling priority is level 1. For third-party processes with an importance value between 20 and 39, the configured recycling priority is level 2. For third-party processes with an importance value between 40 and 59, the configured recycling priority is level 3. For third-party processes with an importance value between 60 and 79, the configured recycling priority is level 4.
[0063] In the embodiments of the present application, after determining the recycling priority of each process, the electronic device can also update the recycling priority of the process. For example, for a system process, its recycling priority is determined by the corresponding ADJ value. In some cases, the ADJ value of the system process may change. In this case, for the system process with the changed ADJ value, its corresponding recycling priority can also be updated. For example, for the system process P1, its initial ADJ value may be 888. In this case, the recycling priority corresponding to the process P1 is level 2. In the subsequent running process, the ADJ value of the system process P1 may become 555. In this case, the recycling priority of the process P1 can be correspondingly updated to level 3. Similarly, in some cases, the importance value of a third-party process may change. In this case, for the third-party process with the changed importance value, its corresponding recycling priority may also be dynamically updated. For example, for the third-party process P2, its initial importance value may be 20. In this case, the recycling priority corresponding to the process P2 is level 2. In the subsequent running process, the importance value of the process P2 may become 16. In this case, the recycling priority of the process P2 can be correspondingly updated to level 1.
[0064] In addition, in the embodiments of the present application, it is also possible to determine whether to adjust the recycling priority of a process according to the memory occupation situation of the process. As a way, if the memory occupied by the process exceeds the standard, the recycling priority of the process is increased. Among them, the higher the recycling priority of a process, the greater the probability of being determined as a process to be recycled. Exemplarily, such as Figure 2As shown, the electronic device can define the memory occupied by the scanning process. If the memory occupied by the process exceeds the memory overrun threshold, the process can be added to the memory overrun process list; otherwise, it can be removed from the memory overrun process list.
[0065] As Figure 3 shown, by using a memory overrun process to replace multiple processes with smaller memory occupancy, it can make the memory overrun process easier to be reclaimed, and avoid directly reclaiming the memory of the multiple processes with smaller memory occupancy, so as to reduce the performance costs such as load and time consumption caused by closing multiple small processes. Among them, Figure 3 "small_mem_app" shown in
[0066] represents a process with smaller memory occupancy. Figure 4 Next, the process of determining the reclaim priority of the process will be described through
[0067] As Figure 4 shown, for system processes, after determining the reclaim priority based on the corresponding ADJ value, the reclaim priority will be further adjusted according to whether the system process has a memory overrun situation. For example, for a system process with a memory overrun, when the value of the reclaim priority is greater than 1, the value of its reclaim priority can be decreased by 1 to increase the reclaim priority by one level. Similarly, for a third-party process, in the case of a memory overrun process, its corresponding importance value will be decreased by 20 to facilitate the improvement of the reclaim priority. Among them, in the case of a third-party process being a memory overrun process, the reduction amplitude of the importance value can be configured as needed, not limited to the aforementioned 20. Among them, for a system process with a memory overrun, if its reclaim priority is already at the highest level (for example, the value of the reclaim priority is 1), then the adjustment of the reclaim priority can be omitted.
[0068] In the embodiments of the present application, the memory overrun thresholds corresponding to different processes can be the same, or different memory overrun thresholds can be configured for different processes.
[0069] As a configuration method, the corresponding memory overrun threshold can be determined according to the running frequency of the process. Among them, for a process with a higher running frequency, its corresponding memory overrun threshold is higher. It should be noted that for a process with a higher running frequency, it means that the probability of the process being used by the user is higher, and thus it can be understood as a process commonly used by the user. Or, for a process with a higher running frequency, it can also be understood that the more times the process is called by the electronic device, the more it means that the process is required for the electronic device to implement specific functions. In this case, a higher memory overrun threshold can be given to a process with a higher running frequency, so that the reclaim priority of the process is not easily increased.
[0070] Exemplarily, the processes included in the electronic device are process P1, process P2, process P3, and process P4. Among them, the running frequency of process P1 is F1, the running frequency of process P2 is F2, the running frequency of process P3 is F3, and the running frequency of process P4 is F4. Among them, if F4 is greater than F3, F3 is greater than F2, and F2 is greater than F1, then the sorting of the memory overrun thresholds corresponding to the multiple processes from high to low is: process P4, process P3, process P2, and process P1.
[0071] Optionally, the running frequency of a process can be the ratio of the number of times the process runs within a preset time period to the length of the preset time period. Exemplarily, the number of times the process runs within the preset time period is b, and the length of the preset time period is t, then the obtained running frequency is b / t. In the embodiments of the present application, whenever a process is detected to start or a process is detected to switch from the background to the foreground, the running count of the process can be incremented by 1.
[0072] As another configuration method, the memory overrun threshold corresponding to a process can be preset by the user or developer of the electronic device.
[0073] Among them, when there is a corresponding recycling priority for each process, when the recycling trigger condition is met, the process to be recycled can be determined according to the recycling priority of the process. Among them, the process to be recycled can be understood as the process to be recycled for the process memory. Optionally, the recycling trigger condition can include: the available memory of the electronic device is lower than the memory recycling threshold. Among them, the available memory can be understood as the memory that the electronic device can currently use for allocation. When the available memory is lower than the memory recycling threshold, it indicates that the electronic device is in a low-memory situation, and thus memory recycling is required to avoid running failures. Or, the recycling trigger condition can include: a preset application is started. The preset application can include a game application and a camera application. Among them, the preset application can be understood as an application that consumes a large amount of memory during operation. Correspondingly, when there is a preset application started on the electronic device, it indicates that the electronic device needs to allocate a large amount of memory for the preset application, and thus a memory recycling can be triggered to ensure there is enough memory.
[0074] Among them, determining the process to be recycled according to the recycling priority of the process can be understood as determining the process to be recycled in the order from high to low according to the current memory recycling requirement until the memory recycling requirement is met. Among them, the memory recycling requirement may include the target value of the memory to be recycled. For example, the target value may be 100MB, 200MB, etc. And, in the embodiments of the present application, in addition to referring to the recycling priority, the start-stop time interval of the process will also be synchronously referred to. Among them, the start-stop time interval represents the time interval from when the process is shut down to the next start. Exemplarily, as Figure 5 shown, after the process is shut down at time T1 and then started again at time T2, the start-stop time interval of the process is T2 - T1. In the embodiments of the present application, the start-stop time interval of the process can be obtained by statistics based on the historical shutdown times and historical start times of the process multiple times. In one way, the start-stop time interval of the process can be understood as a predicted value.
[0075] Among them, the role of referring to the start-stop time interval of the process is to largely avoid the situation that the memory of the same process is recycled and then quickly starts and applies for memory allocation again. That is to say, in the process of determining the process to be recycled, a process with a relatively small start-stop time interval (for example, less than the interval threshold) will not be determined as the process to be recycled.
[0076] S120: Recycle the memory of the process to be recycled to meet the memory recycling requirement.
[0077] After determining the process to be recycled, the memory of the process to be recycled can be recycled. In the embodiments of the present application, memory recycling can be implemented in various ways. As one way, recycling the memory of the process to be recycled may include shutting down the process to be recycled. Among them, by shutting down the process to be recycled, all the memory occupied by the process to be recycled can be recycled. As one way, only a part of the memory occupied by the process to be recycled can be recycled.
[0078] Optionally, the electronic device can determine the corresponding memory recycling method according to the running state of the process to be recycled.
[0079] As one way, for a process that has been switched to the background for running or a process that is a non-core system service, memory recovery can be performed by directly shutting it down. Among them, the processes of non-core system services may include: non-critical processes such as system log services and statistical background services.
[0080] As a way, for foreground UI (User Interface) related processes or system critical processes, only part of the memory can be reclaimed to avoid directly shutting down and causing a reduction in the user experience. Among them, foreground UI related processes can include processes of social applications and navigation applications that the current user is interacting with. Among them, for foreground UI related processes, the memory of inactive memory areas (such as historical page caches and pre-loaded image data) can be reclaimed. System critical processes can include processes related to basic functions such as phone services and SMS daemon processes.
[0081] It should be noted that in the embodiment of the present application, when the electronic device detects that the recycling trigger condition is met, it can directly determine all the processes to be recycled according to the memory recycling requirements and the order of recycling priorities first. Then, after determining all the processes to be recycled, the memory of all the determined processes to be recycled can be uniformly recycled. Or, the electronic device can determine the processes to be recycled one by one according to the order of recycling priorities and recycle the memory of the determined processes to be recycled until the memory recycling requirements are met.
[0082] A process processing method provided in this embodiment can, when the recycling trigger condition is met, determine the processes to be recycled through the recycling priorities of the processes and the start-stop time intervals of the processes, and then recycle the memory of the processes to be recycled. Thus, during the process of recycling the memory of the processes, not only the recycling priorities of the processes are considered, but also the start-stop time intervals of the processes are considered, thereby reducing the probability that the memory of the same process is quickly started and applies for memory allocation again after being recycled, thus improving the effectiveness of memory recycling and avoiding reducing the system load caused by frequent memory recycling and allocation.
[0083] Please refer to Figure 6 , a process processing method provided in the embodiment of the present application, is applied to an electronic device. The method includes:
[0084] S210: In response to meeting the recycling trigger condition, based on the order of the recycling priorities of the processes, sequentially determine the processes currently being detected to determine the processes to be recycled through the detection until the memory recycling requirements are met.
[0085] When the process has a recycling priority, the processes can be sorted according to the recycling priority. In this case, the result of sorting the processes will correspond to the order of the corresponding recycling priorities. Among them, for a process with a higher recycling priority, its sorting will be relatively more forward, and a process with a relatively more forward sorting will be relatively earlier determined as the process to be currently detected. In addition, during the process of sorting the processes, for the same recycling priority, there will be multiple processes. Then, for the processes belonging to the same recycling priority, they can be sorted by the value used to determine the recycling priority (for example, the ADJ value or the importance value). Among the processes belonging to the same recycling priority, a process with a relatively more forward sorting will be relatively earlier determined as the process to be currently detected.
[0086] Moreover, in this implementation, the process to be currently detected can be determined one by one. Among them, after determining the process to be currently detected, it can be determined whether the process belongs to the process to be recycled through this detection. If it is determined that the process to be currently detected belongs to the process to be recycled, memory recycling will be performed on the process to be currently detected, and further judgment will be made on whether the recycled memory meets the memory recycling requirements after the memory recycling of the process to be currently detected. If it has been met, the memory recycling will end. If not, the next process to be detected will be determined until the memory recycling requirements are met.
[0087] Exemplarily, as Figure 7 shown, for processes, they can be sorted first based on the recycling priority. Among them, processes with a higher recycling priority will be sorted relatively more forward. For example, the process with a recycling priority of 1 is sorted at the front, followed by the process with a recycling priority of 2, and then the processes with recycling priorities of 3 and 4 respectively.
[0088] Based on this sorting, the process with a recycling priority of level 1 will be the first to be used as the process to be currently detected. Among them, during the detection of the process with a recycling priority of level 1, first, the process P31 will be used as the process to be currently detected. If it is determined that the process P31 is a process to be recycled and the memory recycling of the process P31 does not meet the memory recycling requirements, then the process P32 will be used as the process to be currently detected, and so on. After completing the detection of the process with a recycling priority of level 1 and the currently recycled memory does not meet the memory recycling requirements, the detection of the process with a recycling priority of level 2 will start, and so on, until the memory recycling requirements are met. For example, if the currently recycled memory does not meet the memory recycling requirements after determining the memory recycling of the process P34, then the process P41 will start to be used as the process to be currently detected.
[0089] It should be noted that in one case, processes can be divided into system processes and third-party processes. In this case, for processes with the same reclaim priority, there may be both system processes and third-party processes. Moreover, for system processes and third-party processes, the values used to determine the reclaim priority can be different.
[0090] As a method, among processes with the same reclaim priority, the system processes can be sorted by the ADJ value, and the third-party processes can be sorted by the importance value. In this case, based on the respective sorting results of the system processes and the third-party processes, the process to be currently detected can be alternately determined from the system processes and the third-party processes. Here, alternately determining the process to be currently detected can be understood as follows: if the process to be currently detected is a system process, then the next process to be detected is the third-party process that has not been detected and is ranked first among the third-party processes. Correspondingly, if the process to be currently detected is a third-party process, then the next process to be detected is the system process that has not been detected and is ranked first among the system processes.
[0091] Exemplarily, as Figure 8 shown, for processes with a reclaim priority of level 1, there are process P31, process P32, process P33, process P34, process P35, and process P36. Among them, process P31, process P32, and process P33 are system processes, and process P34, process P35, and process P36 are third-party processes. Among them, process P31, process P32, and process P33 can be sorted based on the ADJ value. Among them, the ADJ value of process P31 is the largest and is ranked first, followed by process P32 and process P33. Among them, process P34, process P35, and process P36 can be sorted based on the importance value. Among them, the importance value of process P34 is the smallest and is ranked first, followed by process P35 and process P36. When starting to detect processes with a reclaim priority of level 1, process P31 can be first determined as the process to be currently detected. After completing the detection of process P31, the next one will be the detection of process P34. After completing the detection of process P34, the next one will be the detection of process P32, and so on, so as to complete the detection of processes with a reclaim priority of level 1.
[0092] As a method, among processes with the same reclaim priority, the third-party processes can be preferentially detected, and after completing the detection of the third-party processes, the system processes can be detected. Exemplarily, please refer to Figure 8 again. Processes P34, P35, and P36 can be preferentially detected, and then, processes P31, P32, and P33 can be detected.
[0093] S220: Recycle the memory of the process to be recycled determined during the detection process, where the process to be recycled satisfies a first condition, and the first condition includes: the start-stop time interval is greater than an interval threshold, and the start-stop time interval represents the time interval from when the process is closed to the next start.
[0094] Among them, for the process currently being detected, it can be determined whether it is a process to be recycled through the first condition. Among them, when the first condition includes that the start-stop time interval is greater than the interval threshold, if the start-stop time interval of the process currently being detected is greater than the interval threshold, it will be determined as a process to be recycled. Correspondingly, if the start-stop time interval of the process currently being detected is less than or equal to the interval threshold, it will not be determined as a process to be recycled (which means it will not be recycled for memory). Among them, when the start-stop time interval of the process is greater than the interval threshold, it means that when the process is closed due to memory recycling, it will not be started again in a short time, so that the memory recycling operation for this process can enable the available memory of the electronic device to recover within a certain time, improving the effectiveness of the memory recycling operation.
[0095] Exemplarily, please refer to Figure 7 again. During the detection process of process P31, if it is detected that the start-stop time interval of process P31 is greater than the interval threshold, then process P31 will be regarded as a process to be recycled. And memory recycling will be performed on process P31. Then, it is detected whether the currently recycled memory meets the memory recycling requirement. If not, process P32 can be used as the next process to be detected until the recycled memory meets the memory recycling requirement.
[0096] It should be noted that in the embodiment of the present application, the start-stop time interval of the process can be understood as a predicted value. For example, it represents the start-stop time interval of the next time after the current moment. Therefore, the start-stop time interval of the process can be predicted based on the historical start-stop situation of the process. Among them, there are various ways to determine the start-stop time interval of the process.
[0097] As a way, the distribution of the historical start-stop time intervals of the process in multiple time intervals can be counted, and then the start-stop time interval of the process can be predicted based on this distribution.
[0098] Exemplarily, as Figure 9 shown, the time when the process starts and closes can be recorded. Then, the multiple historical start times and multiple historical close times of the process can be counted. Then, a historical start-stop time interval is calculated based on each historical start time and the nearest historical close time before this historical start time, so that Figure 9The distribution of the historical start-stop time intervals in 0-1, 1-2, 2-3, 3-4, 4-5, and above 5, where the time unit of the multiple time intervals involved in the above distribution is minutes. Among them, the distribution includes the number of times and the probability. In addition, by counting the start time of the process, in addition to obtaining the start-stop time interval of the process, the survival duration of the process can also be obtained.
[0099] Optionally, the start-stop time interval of the first process can be determined by the historical start-stop time intervals of the process in the most recent M times and the historical start-stop time intervals of the process in Z times; where Z and M are both integers, and M is greater than Z. For example, M can be 200, Z can be 20, or M can be 100, Z can be 10.
[0100] Among them, a specific process for determining whether the start-stop time interval of the first process is greater than the interval threshold by the historical start-stop time intervals of the process in the most recent M times and the historical start-stop time intervals of the process in Z times can include:
[0101] Obtain the first probability and the second probability of the first process. The first probability represents the proportion of the historical start-stop time intervals of the first process in the most recent M times that are less than or equal to the interval threshold, and the second probability represents the proportion of the historical start-stop time intervals of the most recent M times that are greater than the interval threshold;
[0102] Obtain the first score and the second score of the first process. The first score represents the proportion of the historical start-stop time intervals corresponding to the first process in Z times that are less than or equal to the interval threshold, and the second score represents the proportion of the historical start-stop time intervals in Z times that are greater than the interval threshold;
[0103] Obtain the first total score and the second total score of the first process. The first total score is determined by the first probability and the first score, and the second total score is determined by the second probability and the second score;
[0104] If the first total score of the first process is less than the second total score, determine that the start-stop time interval of the first process is greater than the interval threshold.
[0105] Optionally, a way to obtain the first total score and the second total score of the first process can include:
[0106] Determine a first intermediate score and a second intermediate score. The first intermediate score is the product of a first probability and a first weight, and the second intermediate score is the product of a first score and a second weight. The sum of the first weight and the second weight is 1. Obtain a first total score through the sum of the first intermediate score and the second intermediate score. Determine a third intermediate score and a fourth intermediate score. The third intermediate score is the product of a second probability and the first weight, and the fourth intermediate score is the product of a second score and the second weight. Obtain a second total score through the sum of the third intermediate score and the fourth intermediate score.
[0107] Optionally, divide the time interval distribution to divide the time interval into two categories: C1 and C2. Among them, C1: 0 - N minutes; C2: after N minutes. Here, N represents an interval threshold. Based on historical data, the probability of each interval can be calculated. Among them, P(C1) = p, P(C2) = q. Here, p + q = 1. Among them, P(C1) can be understood as the aforementioned first probability. P(C2) can be understood as the aforementioned second probability.
[0108] Calculate a simple trend score (i.e., corresponding to the first score and the second score in the foregoing content):
[0109] Calculate the probability of the most recent Z times as the trend score. For example, in the most recent Z times, the number of times of intervals C1 and C2 are x and y; among them
[0110] Among them, trend_score(C1) is the trend score of event C1, and trend_score(C2) is the trend score of event C2. Among them, trend_score(C1) can be understood as the aforementioned first score. trend_score(C2) can be understood as the aforementioned second score.
[0111] Comprehensive trend score calculation:
[0112] comp_trend_score(C1) = α·p + (1 - α)·trend_score(C1)
[0113] comp_trend_score(C2) = α·q + (1 - α)·trend_score(C2)
[0114] Among them, comp_trend_score(C1) is the comprehensive trend score of event C1, comp_trend_score(C2) is the comprehensive trend score of event C2, and α is a weight factor. Among them, comp_trend_score(C1) can be understood as the aforementioned first total score, and comp_trend_score(C2) can be understood as the aforementioned second total score.
[0115] The final result prediction can be carried out through the following expression, and the expression is:
[0116] result_interval = arg(max(comp_trend_score(C1), comp_trend_score(C2)))
[0117] Among them, result_interval is the distribution interval of the start-stop time interval of the final prediction. If comp_trend_score(C1) is greater than comp_trend_score(C2), it can be determined that the probability of the start-stop time interval being C1 is higher than that of C2, and further characterizes that the start-stop time interval of the process is less than or equal to the interval threshold. Correspondingly, if comp_trend_score(C1) is less than comp_trend_score(C2), it can be determined that the probability of the start-stop time interval being C2 is higher than that of C1, and further characterizes that the start-stop time interval of the process is greater than the interval threshold.
[0118] Exemplarily, taking M as 200, Z as 20, the interval threshold as 3, and the weight coefficient α as 0.3 as an example, the process of determining the start-stop time interval of the process will be described again.
[0119] Among them, based on the above exemplary values, the distribution of the historical start-stop time intervals of the process in the most recent 200 times can be as Figure 10 shown, and the distribution of the historical start-stop time intervals of the process in the most recent 20 times can be as Figure 11 shown.
[0120] Based on the historical start-stop time intervals in the most recent 200 times, calculate the probability of each interval:
[0121] P(C1) = 0.2 + 0.2 + 0.2 = 0.6, P(C2) = 0.2 + 0.1 + 0.1 = 0.4
[0122] Among them, P(C1) represents the probability that the start-stop interval time is less than or equal to 3 minutes (i.e., the aforementioned first probability), and P(C2) represents the probability that the start-stop interval time is greater than 3 minutes (i.e., the aforementioned second probability).
[0123] Based on the historical start-stop time intervals in the most recent 20 times, calculate the simple trend score:
[0124]
[0125] Among them, trend_score(C1) can be understood as the aforementioned first score, and trend_score(C2) can be understood as the aforementioned second score.
[0126] Calculate the comprehensive trend score:
[0127] comp_trend_score(C1) = 0.3x0.6 + (1 - 0.3)x0.7 = 0.67
[0128] comp_trend_score(C2) = 0.3x0.4 + (1 - 0.3)x0.3 = 0.33
[0129] Among them, comp_trend_score(C1) can be understood as the aforementioned first total score, and comp_trend_score(C2) can be understood as the aforementioned second total score.
[0130] Prediction result: The probability that the start-stop time interval of the process (i.e., the next start-stop time interval) falls within 0 - 3 minutes is 0.67, and the probability of falling outside 3 minutes is 0.33; In summary, the start-stop time interval of the process is within 0 - 3 minutes. That is to say, when the interval threshold is 3 minutes, the start-stop time interval of the process will be less than 3 minutes.
[0131] In addition, in the embodiments of the present application, after obtaining multiple historical start-stop time intervals of the process, the average value of the multiple historical start-stop time intervals can also be obtained to obtain the start-stop time interval of the process.
[0132] In the embodiments of the present application, the first condition may further include more condition contents. As a way, the first condition further includes one or more of the following multiple condition contents, and the multiple condition contents include: the memory occupied by the process exceeds the standard; the survival duration of the process is greater than the survival duration threshold. Among them, the survival duration of the process can be understood as the duration between the time of the most recent start of the process and the current time. Optionally, when the process being detected currently is a system process, one or more of the above multiple condition contents can be added to the first condition.
[0133] In one way, it can be to first determine whether the process being detected currently is a process with memory exceeding the standard. If it is a process with memory exceeding the standard, then directly determine the process being detected currently as the process to be recycled. If it is not a process with memory exceeding the standard, then further detect whether the survival duration of the process being detected currently is greater than the survival duration threshold. If the survival duration is greater than the survival duration threshold, then determine the process being detected currently as the process to be recycled. If it is less than or equal to the survival duration threshold, then further detect the start-stop time interval.
[0134] Next, the following will be used to Figure 12 describe a process handling process involved in this embodiment.
[0135] As Figure 12 shown, when the recycling trigger condition is met, memory recycling of the process can be performed first based on the sorting of the recycling priorities. Among them, if the currently detected process is a system process, it can be first determined whether the memory occupied by the system process exceeds the standard. If it exceeds the standard, the system process will be determined as the process to be recycled and memory recycling will be performed. Otherwise, it is further determined whether the survival time of the system process is greater than the survival time threshold. If it exceeds the survival time threshold, the system process will be determined as the process to be recycled and memory recycling will be performed. Otherwise, it is further determined whether the start-stop time interval of the system process is greater than the interval threshold. If it is greater than the interval threshold, the system process will be determined as the process to be recycled and memory recycling will be performed. Otherwise, the system process will not be regarded as the process to be recycled this time.
[0136] As shown in the foregoing content, Figure 12 taking the currently detected process as a system process as an example, the process handling process is described. Among them, in the case where the process is a third-party process, the second condition can be used to determine whether the currently detected third-party process is the process to be recycled. Among them, the second condition can be the same as or different from the condition content included in the foregoing first condition. For example, when the first condition includes Figure 12 the three condition contents shown in, the second condition can only include that the start-stop time interval is greater than the interval threshold.
[0137] A process handling method provided in this embodiment enables, during the process of memory recycling of the process, not only to refer to the recycling priority of the process, but also to refer to the start-stop time interval of the process, thereby reducing the probability that the memory of the same process will be started and apply for memory allocation again soon after being recycled, thereby improving the effectiveness of memory recycling and avoiding reducing the frequent memory recycling and allocation, which causes additional system load. And in this embodiment, when determining whether the currently detected process is the process to be recycled, it also considers whether the memory occupied by the process exceeds the standard and whether the survival duration of the process exceeds the survival duration threshold, so that the determined process to be recycled is more accurate.
[0138] Please refer to Figure 13 , a process handling method provided by an embodiment of the present application, which is applied to an electronic device. The method includes:
[0139] S310: In response to meeting the recycling trigger condition, determine a first process, and the recycling priority of the first process meets the memory recycling requirement.
[0140] In this embodiment, after detecting that the recycling trigger condition is met, the electronic device may first determine a first process according to the memory recycling requirement. Among them, the first process may be determined according to the memory recycling requirement and the recycling priority of the process. In this embodiment, the memory recycling requirement represents the memory value that needs to be recycled. For example, the memory value that needs to be recycled may be 100MB, 1000MB, etc.
[0141] Among them, that the recycling priority of the first process meets the memory recycling requirement can be understood as: the first process is the process that is preferentially recycled according to the recycling priority of the process when the memory recycling requirement is met. Optionally, after the electronic device performs memory recycling on each process, it can estimate the memory that can be recycled. Then, that the first process meets the memory recycling requirement can be understood as that after recycling the memory of the first process, the memory recycling requirement can be met.
[0142] For example, when the recycling priority can be divided into 4 levels, the highest level of recycling priority can be represented by the value 1, the second highest level of recycling priority can be represented by the value 2, the relatively lower recycling priority can be represented by the value 3, and the relatively lowest recycling priority can be represented by the value 4.
[0143] Among them, the highest level of recycling priority can be understood as the recycling priority that performs memory recycling first. Among them, if the memory recovered after recycling a part of the processes with a recycling priority of level 1 can meet the memory recycling requirement, then this part of the processes can be determined as the first process. Among them, if all the processes with a recycling priority of level 1 need to be recycled before the recovered memory can meet the memory recycling requirement, then all the processes with a recycling priority of level 1 can be determined as the first process. Among them. If all the processes with a recycling priority of level 1 and a part of the processes with a recycling priority of level 2 need to be recycled before the recovered memory can meet the memory recycling requirement, then the determined first process will include all the processes with a recycling priority of level 1 and a part of the processes with a recycling priority of level 2. And so on, the processes included in the first process can be determined in different situations.
[0144] S320: Determine the process to be recycled from the first process, where the start-stop time interval of the process to be recycled is greater than the interval threshold.
[0145] After determining the first process, the process to be recycled can be determined from the first process according to the start-stop time interval corresponding to the first process. Optionally, the determined process to be recycled can be a part of the first process, or all of the first process can be determined as the process to be recycled.
[0146] S330: Recycle the memory of the process to be recycled.
[0147] It should be noted that, as shown in the foregoing content, the first process is determined according to the memory recycling requirement. That is to say,
[0148] In one case, after recycling the memory of all processes in the first process, the recycled memory can meet the memory recycling requirement. However, in this embodiment, after determining the first process, the process to be recycled will be further determined from the first process according to the start-stop time interval of the process. Therefore, the number of processes to be recycled determined may be less than the number of the first process. Furthermore, it may result in that even after recycling the memory of all processes to be recycled, the recycled memory cannot meet the memory recycling requirement. To improve this problem, when determining the first process, the estimated recycled memory corresponding to the determined first process can be made greater than the memory value to be recycled, so as to make the finally recycled memory equal to or close to the memory value to be recycled as much as possible. Among them, the estimated recycled memory can be understood as the memory that is expected to be recycled after recycling the memory of all processes in the first process.
[0149] Exemplarily, as Figure 14 shown, in Figure 14 the example shown, the memory requirement represented by the memory recycling requirement is 250MB. In this case, based on this memory recycling requirement and the recycling order (determined based on the recycling priority), the first process determined may include process P41 and process P42. Among them, the estimated recyclable memory corresponding to process P41 is 200MB, and the estimated recyclable memory corresponding to process P42 is 50MB, which is exactly the same as the memory recycling requirement of 250MB. However, based on the foregoing description, among process P41 and process P42, the start-stop time interval of some processes may not be greater than the interval threshold, which means that among process P41 and process P42, some processes may not be determined as the process to be recycled. Therefore, based on the foregoing method, process P43 can also be determined as the first process. That is, the finally determined first process may include process P41, process P42, and process P43.
[0150] Among them, during the process of determining the process to be recycled, the start-stop time interval of process P42 is less than the interval threshold. In this case, the determined processes to be recycled include process P41 and process P43. Among them, after recycling the memory of process P41 and process P43, the recycled memory is exactly the same as the memory recycling requirement.
[0151] A process processing method, apparatus, and electronic device provided by the present application. In this method, when the recycling trigger condition is met, a first process can be determined according to the memory recycling requirement and the recycling priority. Then, a process to be recycled can be screened from the first process according to the start-stop time interval of the process, so that in the process of recycling memory for the process, not only the recycling priority of the process is considered, but also the start-stop time interval of the process is considered, thereby reducing the probability that the memory of the same process is recycled and then quickly starts and applies for memory allocation again, thus improving the effectiveness of memory recycling and avoiding additional system load caused by frequent memory recycling and allocation.
[0152] Please refer to Figure 15 , a process processing apparatus 400 provided by an embodiment of the present application, running on an electronic device. The apparatus 400 includes:
[0153] A process determination unit 410, configured to determine a process to be recycled in response to the recycling trigger condition being met, where the process to be recycled is determined by the recycling priority of the process and the start-stop time interval of the process, and the start-stop time interval represents the time interval from when the process is shut down to the next start.
[0154] A memory recycling unit 420, configured to recycle the memory of the process to be recycled to meet the memory recycling requirement.
[0155] As a way, the process determination unit 410 is specifically configured to sequentially determine the currently detected processes based on the recycling priority order of the processes, so as to determine the process to be recycled through the detection until the memory recycling requirement is met. In this way, the memory recycling unit 420 is specifically configured to recycle the memory of the process to be recycled determined during the detection process, where the process to be recycled meets the first condition, and the first condition includes: the start-stop time interval is greater than the interval threshold.
[0156] As a way, the first condition further includes one or more of the following multiple condition contents, and the multiple condition contents include: the memory occupied by the process exceeds the standard; the survival duration of the process is greater than the survival duration threshold.
[0157] As a way, the process determination unit 410 is specifically configured to determine whether the start-stop time interval of the first process is greater than the interval threshold through the historical start-stop time intervals of the process in the most recent M times and the historical start-stop time intervals of the process in Z times; where M is greater than Z.
[0158] Optionally, the process determination unit 410 is specifically configured to obtain a first probability and a second probability of the first process. The first probability represents the proportion of the last M historical start-stop time intervals of the first process that are less than or equal to the interval threshold, and the second probability represents the proportion of the last M historical start-stop time intervals that are greater than the interval threshold; obtain a first score and a second score of the first process. The first score represents the proportion of the corresponding Z historical start-stop time intervals of the first process that are less than or equal to the interval threshold, and the second score represents the proportion of the Z historical start-stop time intervals that are greater than the interval threshold; obtain a first total score and a second total score of the first process. The first total score is determined by the first probability and the first score, and the second total score is determined by the second probability and the second score; if the first total score of the first process is less than the second total score, determine that the start-stop time interval of the first process is greater than the interval threshold.
[0159] As a manner, the process determination unit 410 is specifically configured to, if the process currently being detected is a system process and the process currently being detected meets the first condition, determine that the process currently being detected is a process to be recycled. The process determination unit 410 is specifically configured to, if the process currently being detected is a third-party process and the process currently being detected meets the second condition, determine that the process currently being detected is a process to be recycled, where the second condition is different from the first condition.
[0160] As a manner, the process determination unit 410 is further configured to increase the recycling priority of a process if the memory occupied by the process exceeds the standard. Among them, the higher the recycling priority of a process, the greater the probability that the process is determined to be a process to be recycled.
[0161] A process processing device provided in this embodiment enables, during the process of memory recycling of a process, not only to refer to the recycling priority of the process, but also to refer to the start-stop time interval of the process, thereby reducing the probability that the memory of the same process starts and applies for memory allocation again quickly after being recycled, improving the effectiveness of memory recycling, and avoiding increasing the extra system load caused by frequent memory recycling and allocation.
[0162] It should be noted that the device embodiments in this application correspond to the foregoing method embodiments. The specific principles in the device embodiments can be referred to in the content of the foregoing method embodiments and will not be elaborated here.
[0163] Next, Figure 16 introduce a system architecture related to the embodiments of this application.
[0164] Such as Figure 16As shown in the figure, the system architecture involved includes a kernel, an upper-layer framework FW (Framework), a process message monitoring module, and a process recovery module.
[0165] Among them, the kernel includes osvelte, where osvelte refers to a device file located in the / dev directory. This device file is an interface for accessing hardware devices. / proc / meminfo is a virtual file located in the / proc directory and contains information about the system's memory usage. By reading this virtual file, detailed information about the system memory can be obtained, such as total memory, available memory, cached memory, etc. In the upper-layer framework, procStats refers to a module or tool for obtaining and monitoring system process statistics. It may obtain relevant information by reading files in the / proc directory. AMS: This abbreviation may have multiple interpretations, but in the Android system, AMS refers to the ActivityManager Service, which is a service in the Android system responsible for managing the lifecycle of activities (Activity).
[0166] Among them, the process information monitoring module can be used to count the processes (application programs) in the electronic device, and then determine the processes with excessive memory. It can also count the startup time and shutdown time of the processes to determine the distribution of the startup and shutdown time intervals among multiple time periods, and store the relevant information obtained from the statistics in the local database.
[0167] Among them, the process recovery module can be used to determine and detect recovery scenarios. In the process recovery module, there is also a process recovery priority adjustment module, which is used to adjust the recovery priorities of processes (for example, the recovery priorities of system processes and third-party processes). Among them, in the process of determining the processes to be recovered, process filtering can be performed based on a process filtering mechanism.
[0168] Next, a description will be given in conjunction with Figure 17 an electronic device provided by this application.
[0169] Please refer to Figure 17 , based on the above process processing method and device, another electronic device 200 that can execute the foregoing process processing method is further provided in an embodiment of this application. The electronic device 200 includes one or more (only one is shown in the figure) processors 202, a memory 204, a network module 206, a sensor module 208, and an audio collection device 210 that are coupled to each other. Among them, a program that can execute the content in the foregoing embodiment is stored in the memory 204, and the processor 202 can execute the program stored in the memory 204.
[0170] Among them, the processor 202 may include one or more processing cores. The processor 202 connects various parts within the entire electronic device 200 through various interfaces and circuits. By running or executing instructions, programs, code sets, or instruction sets stored in the memory 204, and by calling the data stored in the memory 204, it executes various functions of the electronic device 200 and processes data. Optionally, the processor 202 may be implemented in at least one hardware form of digital signal processing (DSP), field-programmable gate array (FPGA), or programmable logic array (PLA). The processor 202 may integrate a combination of one or more of a central processing unit (CPU), a graphics processing unit (GPU), and a modem, etc. Among them, the CPU mainly processes the operating system, user interface, application programs, etc.; the GPU is responsible for rendering and drawing display content; the modem is used to process wireless communication. It can be understood that the above-mentioned modem may not be integrated into the processor 202 and may be implemented separately by a communication chip.
[0171] The memory 204 may include random access memory (RAM) and may also include read-only memory. The memory 204 can be used to store instructions, programs, code, code sets, or instruction sets. The memory 204 may include a program storage area and a data storage area. Among them, the program storage area can store instructions for implementing the operating system, instructions for implementing at least one function (such as touch function, sound playback function, image playback function, etc.), instructions for implementing the following various method embodiments, etc.
[0172] The network module 206 is used to implement information interaction between the electronic device 200 and other devices. For example, it transmits device control instructions, manipulation request instructions, and status information acquisition instructions, etc. When the electronic device 200 is specifically different devices, the corresponding network module 206 may be different.
[0173] The sensor module 208 may include at least one sensor. Specifically, the sensor module 208 may include but is not limited to: optical sensors, motion sensors, pressure sensors, infrared thermal sensors, distance sensors, acceleration sensors, and other sensors.
[0174] Among them, the pressure sensor is a sensor that can detect the pressure generated by pressing on the electronic device 200. That is, the pressure sensor detects the pressure generated by the contact or pressing between the user and the electronic device, such as the pressure generated by the contact or pressing between the user's ear and the mobile terminal. Therefore, the pressure sensor can be used to determine whether there is a contact or pressing between the user and the electronic device 200, as well as the magnitude of the pressure.
[0175] Among them, the acceleration sensor can detect the magnitude of the acceleration in each direction (generally three axes). When stationary, it can detect the magnitude and direction of gravity, and can be used in applications for identifying the posture of the electronic device 200 (such as horizontal and vertical screen switching, related games, magnetometer posture calibration), vibration recognition related functions (such as pedometers, taps), etc. In addition, the electronic device 200 can also be configured with other sensors such as gyroscopes, barometers, hygrometers, thermometers, etc., which will not be elaborated here.
[0176] The audio acquisition device 210 is used for audio signal acquisition. Optionally, the audio acquisition device 210 includes a plurality of audio acquisition components. The audio acquisition component can be a microphone. For example, in one way, the audio acquisition device 210 can include two microphones. In this way, one of the microphones can correspond to an analog-to-digital converter, and the other microphone can correspond to two analog-to-digital converters with different analog gains. In another way, the audio acquisition device 210 can include three microphones. In this way, two of the microphones (for example, the main microphone and the secondary microphone) can each correspond to an analog-to-digital converter, and the other microphone (for example, the camera microphone) can correspond to two analog-to-digital converters with different analog gains.
[0177] As one way, the network module of the electronic device 200 is a radio frequency module. The radio frequency module is used to receive and send electromagnetic waves, realize the mutual conversion between electromagnetic waves and electrical signals, so as to communicate with a communication network or other devices. The radio frequency module can include various existing circuit elements for performing these functions, such as antennas, radio frequency transceivers, digital signal processors, encryption / decryption chips, user identity module (SIM) cards, memories, etc. For example, the radio frequency module can interact with external devices through the transmitted or received electromagnetic waves, and then receive the audio signals sent by the external devices.
[0178] Furthermore, the electronic device 200 can also include an image acquisition component for image acquisition. For example, videos, static pictures or dynamic pictures can be taken through the image acquisition component.
[0179] Please refer to Figure 18, which shows a structural block diagram of a computer-readable storage medium provided by an embodiment of the present application. Program code is stored in the computer-readable medium 800, and the program code can be called by a processor to execute the method described in the above method embodiment.
[0180] The computer-readable storage medium 800 can be an electronic memory such as a flash memory, EEPROM (electrically erasable programmable read-only memory), EPROM, hard disk, or ROM. Optionally, the computer-readable storage medium 800 includes a non-transitory computer-readable storage medium. The computer-readable storage medium 800 has a storage space for the program code 810 that executes any method step in the above method. These program codes can be read out from or written into one or more computer program products. The program code 810 can be compressed in an appropriate form, for example.
[0181] A process processing method, device, and electronic device provided by the present application. In this method, when the recycling trigger condition is met, the process to be recycled can be determined through the recycling priority of the process and the start-stop time interval of the process, and then memory recycling is performed on the process to be recycled. Thus, during the process of memory recycling of the process, not only the recycling priority of the process is referred to, but also the start-stop time interval of the process is referred to, thereby reducing the probability that the memory of the same process is started and applies for memory allocation again relatively quickly after being recycled, thereby improving the effectiveness of memory recycling and also avoiding reducing the frequent recycling and allocation of memory and causing additional system load.
[0182] In one implementation, an embodiment of the present application proposes a memory recycling method that combines the memory occupancy of a process and the start-stop time interval of the process. This method dynamically adjusts the recycling priority of the process in a hierarchical and graded manner, fine-tunes the management of the process, and preferentially kills processes with excessive memory occupancy, thereby effectively releasing memory pressure and avoiding increasing system load by closing multiple processes with small memory at the same time. At the same time, using the historical start-stop time interval in the historical data, a weighted statistical and trend analysis algorithm is used to predict the next start-stop time interval, and combined with the memory usage and survival time of the application, an intelligent decision is made on whether to close a certain process. This strategy reduces unnecessary process closing operations, reduces the system load caused by frequent closing and starting of processes, and improves the overall performance and stability of the system.
[0183] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions described in the foregoing embodiments, or perform equivalent replacements for some of the technical features; and these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A process handling method, characterized in that, Applied to an electronic device, the method includes: In response to meeting the recycling trigger condition, determining a process to be recycled, where the process to be recycled is determined by the recycling priority of the process and the start-stop time interval of the process, and the start-stop time interval represents the time interval from when the process is shut down to the next start; Performing memory recycling on the process to be recycled to meet the memory recycling requirement.
2. The method according to claim 1, wherein The determining the process to be recycled includes: sequentially determining the currently detected process based on the recycling priority order of the processes to determine the process to be recycled through the detection until the memory recycling requirement is met; The performing memory recycling on the process to be recycled includes: Performing memory recycling on the process to be recycled determined during the detection process, where the process to be recycled meets the first condition, and the first condition includes: the start-stop time interval is greater than the interval threshold.
3. The method according to claim 2, wherein The first condition further includes one or more of the following multiple condition contents, and the multiple condition contents include: The memory occupied by the process exceeds the standard; The survival duration of the process is greater than the survival duration threshold.
4. The method according to claim 2, wherein The method further includes: Determining whether the start-stop time interval of the first process is greater than the interval threshold through the most recent M historical start-stop time intervals of the process and the Z historical start-stop time intervals of the process; Where M is greater than Z.
5. The method according to claim 4, wherein The determining whether the start-stop time interval of the first process is greater than the interval threshold through the most recent M historical start-stop time intervals of the process and the Z historical start-stop time intervals of the process includes: Obtaining a first probability and a second probability of the first process, where the first probability represents the proportion of the most recent M historical start-stop time intervals of the first process that are less than or equal to the interval threshold, and the second probability represents the proportion of the most recent M historical start-stop time intervals that are greater than the interval threshold; Obtaining a first score and a second score of the first process, where the first score represents the proportion of the Z historical start-stop time intervals corresponding to the first process that are less than or equal to the interval threshold, and the second score represents the proportion of the Z historical start-stop time intervals that are greater than the interval threshold; Obtaining a first total score and a second total score of the first process, where the first total score is determined by the first probability and the first score, and the second total score is determined by the second probability and the second score; If the first total score of the first process is less than the second total score, determining that the start-stop time interval of the first process is greater than the interval threshold.
6. The method according to claim 5, wherein The obtaining the first total score and the second total score of the first process includes: Determining a first intermediate score and a second intermediate score, where the first intermediate score is the product of the first probability and the first weight, the second intermediate score is the product of the first score and the second weight, and the sum of the first weight and the second weight is 1; Obtaining the first total score through the sum of the first intermediate score and the second intermediate score; Determining a third intermediate score and a fourth intermediate score, where the third intermediate score is the product of the second probability and the first weight, and the fourth intermediate score is the product of the second score and the second weight; Obtaining the second total score through the sum of the third intermediate score and the fourth intermediate score.
7. The method according to claim 2, characterized in that, If the process currently being detected is a system process and the process currently being detected meets the first condition, then determine that the process currently being detected is a process to be recycled; If the process currently being detected is a third-party process and the process currently being detected meets the second condition, then determine that the process currently being detected is a process to be recycled, where the second condition is different from the first condition.
8. The method according to claim 1, characterized in that, The method further includes: If the memory occupied by a process exceeds the standard, then increase the recycling priority of the process. Among them, the higher the recycling priority of a process, the greater the probability that the process is determined to be a process to be recycled.
9. The method according to claim 1, characterized in that, The process includes a system process and a third-party process, where the determination methods of the respective recycling priorities of the system process and the third-party process are different.
10. A process processing device, characterized in that, Running on an electronic device, the device includes: A process determination unit, configured to determine a process to be recycled in response to meeting a recycling trigger condition, where the process to be recycled is determined by the recycling priority of the process and the start-stop time interval of the process, and the start-stop time interval represents the time interval from when the process is shut down to the next start; A memory recycling unit, configured to perform memory recycling on the process to be recycled to meet the memory recycling requirement.
11. An electronic device, characterized in that, Comprising one or more processors and a memory; one or more programs are stored in the memory and are configured to be executed by the one or more processors to perform the method according to any one of claims 1-9.
12. A computer program product, comprising a computer program or instructions, characterized in that, When the computer program or instruction is executed by a processor, the method according to any one of claims 1-9 is implemented.