A method, system, and electronic device for system resource monitoring and process cleanup.

By employing dual-channel triggering, multi-dimensional load perception, and resource change identification, combined with multi-dimensional filtering and chain-based non-cleanable determination, scenario-driven sorting and staggered rearrangement, as well as differentiated early stop cleaning for three slots, solves the problems of single resource governance objectives and repetitive cleaning in existing technologies, achieving high efficiency and stability in dynamic resource governance.

CN123114885APending Publication Date: 2026-11-17SICHUAN COOLBY COMM EQUIP CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611245379.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-17
Publication Date
2026-11-17

AI Technical Summary

Technical Problem

Existing technologies struggle to dynamically determine resource governance objectives based on different operating scenarios and resource load states. Process selection relies on a single criterion, making it difficult to consider both the actual resource consumption of processes and the current user usage status, leading to duplicate cleanup and resource fluctuations.

Method used

Triggered by both external scenario-based requests and kernel events, combined with multi-dimensional load perception and resource change identification, multi-dimensional filtering and chain-based non-cleanable judgment are used to perform scenario-driven sorting and staggered rearrangement, and differentiated early stop cleaning is adopted for memory, CPU and IO slots.

Benefits of technology

It enables dynamic resource governance based on different operating scenarios and resource load states, improving the accuracy of process selection and the targeting of resource governance, reducing the impact on important applications, and minimizing redundant cleanup and resource fluctuations.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123114885A_ABST
    Figure CN123114885A_ABST
Patent Text Reader

Abstract

This invention discloses a system resource monitoring and process cleanup method, system, and electronic device. The method includes: triggering cleanup through a dual-channel approach of external scenario-based requests and kernel events, and determining the current resource governance target based on the trigger scenario; collecting system-level and process-level load data, calculating resource changes for each resource dimension based on the current and previous sample values ​​to determine abnormal resource dimensions and corresponding abnormal processes; performing multi-dimensional filtering and chain-based non-cleanable determination on the abnormal processes to filter out cleanable processes; determining the sorting dimension based on the resource governance target, performing scenario-based sorting of cleanable processes, and performing staggered rearrangement of recent and non-recent tasks; and performing differentiated early stop cleanup based on the status of memory, CPU, and I / O slots. This invention can more accurately identify abnormal processes and control the cleanup depth, releasing system resources while reducing the impact on the normal operation of important applications.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of operating system resource management technology, and in particular to a system resource monitoring and process cleanup method, system, and electronic device. Background Technology

[0002] With the improvement of hardware performance in smartphones and other mobile terminals and the enrichment of the application ecosystem, the number of background processes is constantly increasing. Some applications may continue to occupy memory, consume CPU resources, or perform storage read / write operations even when the user is not actively using them, thereby increasing the system resource load and potentially causing problems such as slower system response, increased device temperature, and increased power consumption. To alleviate these problems, various background process management and cleanup schemes have been proposed in existing technologies.

[0003] A common approach is based on the system's low-memory management mechanism, prioritizing processes according to their importance parameters and terminating less important processes first when the system is under high memory pressure. This type of approach mainly manages memory resources, with relatively limited consideration of the actual CPU, I / O, and other resource consumption of processes, as well as the user's current usage scenario. Therefore, in some cases, it may lead to the termination of important applications or the inability to handle abnormal loads in other resource dimensions in a timely manner.

[0004] Another approach is to clean up processes based on their recent usage status or task order, prioritizing processes that have not been interacted with by the user for a long time. This approach can reduce the risk of accidental cleanup to some extent by leveraging recent user behavior, but for background processes that continue to perform downloads, calculations, synchronizations, or other resource-intensive operations despite not interacting with the user for a long time, it is difficult to identify their resource consumption in a timely manner based solely on their recent usage status.

[0005] Another approach is to protect specific applications or processes with specific priorities by maintaining a fixed whitelist or protection rules based on process priority. However, some third-party applications may maintain a high process awareness priority by continuously displaying notifications, allowing them to obtain a higher level of protection than their actual running state during process cleanup.

[0006] Furthermore, existing process cleanup solutions may set up monitoring or handling mechanisms for different resource pressures such as CPU, memory, or I / O. However, the identification of resource pressure, process candidate screening, protection of recent user tasks, and cleanup termination conditions may still be independent of each other, making it difficult to link abnormal states of different resource dimensions with specific process cleanup decisions based on the current scenario. Some processes may be restarted after being cleaned up due to system task scheduling or the application's own mechanisms, causing the same process to repeatedly enter the cleanup candidate set within a short period of time. Without a short-term protection mechanism, duplicate cleanup and resource governance instability may occur.

[0007] In summary, existing solutions have at least the following shortcomings: First, the triggering mechanism mainly revolves around single resource pressure or fixed conditions, making it difficult to dynamically determine resource governance goals based on different operating scenarios. Second, process selection mainly relies on process priority, recent usage status, or fixed protection rules, making it difficult to simultaneously combine the actual resource consumption of the process with the user's current usage status for precise judgment. Third, different resource types have different resource reclamation characteristics, and existing solutions cannot dynamically control the cleanup process and termination timing based on the different characteristics of memory, CPU, and I / O. Fourth, cleaned-up processes may re-enter the cleanup candidate set within a short period of time, easily leading to duplicate cleanup and resource fluctuations. Therefore, it is necessary to provide a process cleanup solution that can dynamically manage resources for different operating scenarios and resource load states. Summary of the Invention

[0008] In view of the shortcomings of the prior art, the present invention aims to provide a system resource monitoring and process cleanup method and system, so as to determine the corresponding resource governance objectives for different operating scenarios and resource load states, improve the pertinence of abnormal resource process identification and cleanup decision-making, and reduce the impact on the normal operation of important applications while realizing effective resource recovery.

[0009] To achieve the above objectives, the present invention provides a system resource monitoring and process cleanup method, comprising: Cleanup is triggered through a dual-channel approach of external scenario-based requests and kernel events, and the current resource governance target is determined based on the triggering scenario. Collect system-level load and process-level load, and determine the resource change of each resource dimension based on the current sample value and the previous sample value, so as to identify abnormal resource dimensions and corresponding abnormal processes; Perform multi-dimensional filtering and chain-based non-cleanable determination on the abnormal processes to filter out cleanable processes; Based on the resource governance objectives, the corresponding resource dimensions and cleanup strategies are determined. The cleanupable processes are sorted according to the resource dimensions corresponding to the scenario, and the most recent tasks and non-most recent tasks are alternately rearranged to form a cleanup queue. Based on the status of the memory, CPU, and I / O slots, differentiated early stopping cleanup is performed on the rearranged processes. In the memory dimension, after cleanup, the kernel polls and waits for the slots to be reclaimed until the target is reached before closing the slots. In the CPU dimension, the slots are closed after only one round of traversal. In the I / O dimension, the slots are closed immediately after cleanup.

[0010] In an optional implementation, the dual-channel triggering includes: receiving scene parameters from an external module, including scene identifier, cleanup level, and target memory; and listening for UEvent events reported by kernel nodes when the load exceeds a threshold.

[0011] In an optional implementation, the resource change is obtained by reading the current values ​​of CPU utilization, memory usage, and IO read / write data of the system and each process, and then calculating the difference between these values ​​and the previous sampled values.

[0012] In an optional implementation, the multi-dimensional filtering includes pseudo foreground service degradation: when a third-party application process is identified as being in a perceptible priority state and there is no effective user interaction, its priority is forcibly downgraded to a normal background service. The chain-based non-cleanable determination is executed sequentially according to a preset priority order. If any item is hit, the process is marked as non-cleanable and short-circuited back.

[0013] In an optional implementation, the conditions for determining that the chain cannot be cleaned up include at least one of the following: foreground application, system critical service dependency, recent usage status, resource activity status, and historical cleanup status.

[0014] In an optional implementation, the sorting and alternating rearrangement includes: The sorting dimension is selected according to the triggering scenario: temperature control scenarios are sorted by CPU usage from high to low, and other scenarios are first sorted by memory usage from high to low, and then by IO read and write data volume from high to low, forming a resource priority queue. The processes in the resource priority queue are divided into a subset of recent tasks and a subset of non-recent tasks based on the recent task attribute; The highest priority processes are alternately selected from the non-recent task subset and the recent task subset to form the queue to be cleaned up, and the original resource dimension sorting relationship within each subset is maintained during the alternating selection; when the processes in any subset have been selected, the remaining processes are selected in sequence according to the original resource dimension sorting relationship within the other subset.

[0015] In an optional implementation, separate cleanup status identifiers are maintained for different resource dimensions, and different cleanup termination rules are adopted, including: Initialize the memory, CPU, and I / O slots to be all in the open state; When traversing the queue to be cleaned up, if the slot for the resource dimension corresponding to the current process is already closed, then skip the cleanup of that dimension. For memory cleanup, after performing the cleanup, poll and wait for the kernel to reclaim the memory until the remaining memory reaches the corresponding target, the cleanup quantity reaches the corresponding target, or the polling waiting time reaches the preset timeout threshold, and then close the memory slot. For CPU-related cleanup, the queue to be cleaned up is traversed only once, and the CPU slot is closed after the traversal is completed. For I / O cleanup, after performing cleanup on the target process, the I / O slots are closed; Stop traversing and end cleanup when all memory slots, CPU slots, and I / O slots are closed.

[0016] In an optional implementation, the method further includes: When the service starts, the trigger thresholds for each dimension are adaptively set based on the total number of archive bits in the device and the maximum CPU frequency of each core. The process package name to be cleaned is added to the FIFO record ring. If it is hit in subsequent cleanups, it will be skipped, forming a short-term anti-vibration protection window.

[0017] In another aspect, the present invention provides a system resource monitoring and process cleanup system, comprising: The triggering module is used to trigger cleanup through a dual-channel approach of external scenario-based requests and kernel events, and to determine the current resource governance target based on the triggering scenario. The data acquisition module is used to collect system-level load and process-level load, and determine the resource change of each resource dimension based on the current sample value and the previous sample value, so as to identify abnormal resource dimensions and corresponding abnormal processes. The filtering and determination module is used to perform multi-dimensional filtering and chain-like non-cleanable determination on the abnormal process. The sorting and cleanup module is used to determine the corresponding resource dimensions and cleanup strategies based on resource governance objectives, perform scenario-based sorting and staggered rearrangement of cleanable processes, and perform differentiated early stop cleanup based on the status of memory, CPU, and IO slots.

[0018] In another aspect, the present invention provides an electronic device, including at least one processor and a memory communicatively connected to said at least one processor; The memory stores instructions that can be executed by the at least one processor. When the instructions are executed by the at least one processor, the at least one processor is able to perform any of the above-described system resource monitoring and process cleanup methods.

[0019] In summary, this invention achieves dynamic resource governance for different operating scenarios and resource load states by using dual-channel triggering of external scenario-based requests and kernel events, multi-dimensional load perception and resource change identification, multi-dimensional filtering and chain-based non-cleanable determination, scenario-driven sorting and interleaving rearrangement, and differentiated early stop cleanup for memory, CPU, and IO slots. This linkage integrates resource anomaly identification, process candidate screening, cleanup priority determination, and cleanup termination control, thereby releasing system resources while reducing the impact on the normal operation of important applications.

[0020] Compared with the prior art, the present invention has at least the following beneficial effects: 1. By using dual-channel triggering combined with multi-dimensional load perception and resource change identification, it can dynamically determine resource governance objectives based on different operating scenarios, and identify abnormal resource dimensions and corresponding abnormal processes based on resource load changes, thereby improving the targeting of resource governance triggering and process screening.

[0021] 2. By using pseudo-foreground service degradation and chain-based non-cleanable determination, processes with user interaction or system function dependencies can be prioritized for exclusion, and the possibility of third-party applications circumventing cleanup by maintaining a high awareness priority can be reduced, thereby improving the accuracy of cleanable process screening.

[0022] 3. By using scenario-driven resource dimension sorting, alternating rearrangement of recent and non-recent tasks, and differentiated early stop cleanup for memory, CPU, and IO slots, it can take into account the degree of process resource consumption and the user's recent usage behavior. It can also adopt different slot closing conditions according to the reclamation characteristics of different resource dimensions, thereby reducing invalid traversal and excessive cleanup.

[0023] 4. By adding the package name of the process to be cleaned to the FIFO record ring to form a short-term protection window, the situation of the same process being cleaned up repeatedly in a short period of time is reduced, and resource fluctuations caused by repeated process startup and cleanup are suppressed. Attached Figure Description

[0024] The present invention will be further described below with reference to the accompanying drawings and embodiments. In the accompanying drawings: Figure 1 This is a schematic diagram of the overall architecture of a system resource monitoring and process cleanup system according to the present invention.

[0025] Figure 2 This is a schematic diagram of the overall process of a system resource monitoring and process cleanup method according to the present invention.

[0026] Figure 3 This is a schematic diagram of a dual-channel triggering and resource governance target determination process according to the present invention.

[0027] Figure 4 This is a schematic diagram of a multi-dimensional load acquisition, resource change calculation, and abnormal resource identification process according to the present invention.

[0028] Figure 5 This is a schematic diagram of a multi-dimensional filtering and chain-type non-cleanable determination process according to the present invention.

[0029] Figure 6 This is a schematic diagram illustrating a scenario-based sorting process and an alternating rearrangement of recent and non-recent tasks according to the present invention.

[0030] Figure 7 This is a schematic diagram illustrating a differentiated early stop cleanup process and slot state transition based on three slots: memory, CPU, and IO.

[0031] Figure 8 This is a schematic diagram of an adaptive threshold setting and a short-term anti-oscillation protection process based on a FIFO recording loop according to the present invention. Detailed Implementation

[0032] To make the objectives, technical solutions, and effects of this invention clearer and more explicit, the invention is further described in detail below. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention. The embodiments of the invention are described below in conjunction with the accompanying drawings.

[0033] Please see Figure 1 and Figure 2 This invention provides a system resource monitoring and process cleanup method and system, applicable to electronic devices with a multi-process runtime environment. The electronic device can be a smartphone, tablet computer, or other terminal device with an operating system and multi-process runtime capabilities.

[0034] The system resource monitoring and process cleanup system 100 provided in this embodiment includes a trigger module 110, a data acquisition module 120, a filtering and judgment module 130, a sorting and cleanup module 140, and a resource status storage unit. The system can run as a resource governance service in the operating system, or as a functional module integrated into the system service framework.

[0035] The triggering module 110 receives scenario-based requests from external modules and kernel events generated by kernel resource load status, and determines the current resource governance target based on the running scenario corresponding to the triggering request. The acquisition module 120 acquires system-level load and process-level load, and compares historical sampling values ​​with current sampling values ​​to determine the degree of change of different resource dimensions during the sampling period, and identifies abnormal resource dimensions and abnormal processes. The filtering and judgment module 130 combines multiple dimensions such as the foreground interaction state of the process, system function dependency state, user-perceptible state, resource activity state, and historical cleanup state to filter cleanable processes from the abnormal processes. The sorting and cleanup module 140 sorts the cleanable processes according to scenarios, performs staggered rearrangement, and differentiated cleanup.

[0036] Therefore, this embodiment introduces resource anomaly identification, process cleanupability judgment, recent user behavior, and cleanup characteristics of different resources into the resource governance process in sequence, transforming process cleanup from a simple resource recycling action into a dynamic resource governance process oriented towards specific operating scenarios.

[0037] Please continue reading. Figure 2 The system resource monitoring and process cleanup method provided in this embodiment mainly includes the following steps: S100, dual-channel triggered cleanup. The system receives cleanup trigger information through an external scenario request channel or a kernel event channel. When a scenario-based request is received from an external module, the current running scenario is determined based on the scenario request; when a kernel load event is received, the resource dimension to trigger cleanup is determined based on the resource load status corresponding to the kernel event.

[0038] S200, Determine the resource governance objective. The resource governance objective is determined based on the trigger source, scenario category, and current resource status. This objective defines the primary resource dimensions and cleanup strategies targeted in this cleanup. For example, in a temperature control scenario, CPU resources can be the primary governance objective; in a memory reclamation scenario, memory resources can be the primary objective; and in an abnormal IO load scenario, IO resources can be the primary objective.

[0039] The S300 collects system-level and process-level load data. It collects system-level resource status and the resource usage status of running processes, including at least CPU, memory, and I / O. It also saves the corresponding historical sampling status for subsequent change calculations.

[0040] S400 identifies abnormal resource dimensions and corresponding abnormal processes. Based on the current and previous sampled values, it determines the resource change amount for each resource dimension and combines system-level load changes and process-level load changes to identify abnormal resource dimensions and corresponding abnormal processes. By introducing resource change amounts, it avoids relying solely on absolute resource usage at a single moment for judgment.

[0041] S500, perform multi-dimensional filtering and chain-based non-cleanable determination on the abnormal process. For the abnormal process, firstly, multi-dimensional filtering is performed based on the current running state of the process, and then a chain-based non-cleanable determination is performed on processes that may affect user interaction or normal system function. The chain-based determination is executed sequentially according to a preset priority order. When any non-cleanable condition is met, the corresponding process is marked as non-cleanable and the subsequent determination of that process ends.

[0042] S600, determine cleanable processes. After multi-dimensional filtering and chain-like non-cleanable determination, non-cleanable processes are excluded from the abnormal processes, forming a set of cleanable processes. Cleanable processes represent candidate processes that are allowed to enter subsequent cleanup decisions under the current resource governance objectives and current protection conditions.

[0043] S700 performs scenario-based sorting based on resource governance objectives. For the set of processes to be cleaned up, an appropriate sorting dimension is selected based on the resource governance objectives, and the priority order of the processes to be cleaned up is determined according to this sorting dimension.

[0044] S800, perform staggered rearrangement of recent and non-recent tasks. Based on whether the abnormal process belongs to the recent task protection set, the sorted cleanable processes are divided into recent task subsets and non-recent task subsets, and processes are selected sequentially from the two subsets according to a preset staggered rule to form a queue of processes to be cleaned.

[0045] S900, initialize memory, CPU and I / O slots to the open state.

[0046] S1000 performs differentiated early stop cleanup. When performing differentiated early stop cleanup, the system maintains independent cleanup states (i.e., the aforementioned slot states) for different resource dimensions, and adopts different cleanup termination rules based on the resource reclamation characteristics corresponding to each resource dimension. For example, for memory resources with reclamation delays, a polling feedback termination rule is used; for computationally intensive CPU resources that easily cause device temperature rise, a termination rule that limits the number of traversal rounds is used; and for transient IO read / write resources, a rule that terminates after a single execution is used. This achieves efficient governance with a unified candidate queue, independent resource states, differentiated cleanup depth, and unified termination judgment.

[0047] S1100: Determine if all three slots are closed. If all three slots are closed, stop the iteration and end the current cleanup process.

[0048] Through the above implementation methods, this embodiment forms a continuous processing chain from dual-channel triggering, resource governance target determination, resource change identification, process protection screening, scenario-based sorting, staggered rearrangement, to differentiated early stop cleanup. Each processing step uses the status information generated by the previous step as the decision basis for the next step, so that the cleanup objects, cleanup order, and cleanup depth can all change according to the current operating scenario and resource status.

[0049] The system resource monitoring and process cleanup method provided in this embodiment is not a simple aggregation of isolated functional modules, but rather a closed-loop process cleanup decision system with status feedback, oriented towards resource type differences. In this closed loop, the results of the preceding resource change identification directly determine the subsequent resource governance objectives, which in turn determine the scale of multi-dimensional filtering and the dimension of scenario-based ranking. Ultimately, the characteristics of different resource dimensions determine differentiated early termination conditions. This collaborative mechanism, where each stage is an input-output relationship, allows the system's cleanup depth to dynamically converge with the actual load, avoiding the over-cleanup based on a single dimension found in traditional solutions.

[0050] Please see Figure 3 The trigger module 110 includes an external scene request interface and a kernel event listening interface, which respectively form an external scene request channel and a kernel event channel.

[0051] The external scenario request interface is used to receive scenario-based requests from external modules. These external modules can be system services within the operating system, device status management modules, temperature management modules, memory management modules, or other functional modules capable of sensing the current operating scenario. Scenario parameters include at least a scenario identifier, cleanup level, and target memory. Upon receiving the scenario parameters, the triggering module parses them and uses the parsed scenario identifier, cleanup level, and target memory as input for subsequent resource governance decisions.

[0052] The kernel event listening interface is used to monitor resource load events generated by kernel nodes. When a kernel node detects that the corresponding resource load exceeds a preset trigger condition, it generates a UEvent event and reports it to the triggering module. After receiving the kernel event, the triggering module can determine the resource dimension targeted for this resource governance based on the resource type corresponding to the event.

[0053] External scenario requests primarily reflect resource governance needs proactively proposed by upper-layer functional modules based on device operating scenarios, while kernel events primarily reflect passively triggered states after the underlying resource load has reached preset conditions. By setting up two trigger channels, resource governance can respond to both changes in upper-layer operating scenarios and changes in underlying resource pressure.

[0054] Upon receiving an external scenario request or kernel event, the triggering module determines the resource governance objective based on the trigger source and the corresponding scenario or resource load information. When both external scenario requests and kernel events exist simultaneously, they can be correlated: external scenario requests determine the current priority runtime scenario, while kernel events determine the resource dimension experiencing actual resource pressure. The resource governance objective at least determines the resource dimension of interest for the current cleanup and the corresponding cleanup strategy, and can also determine the allowed governance depth for this cleanup based on the cleanup level.

[0055] Please see Figure 4 The acquisition module 120 includes a system load acquisition unit, a process load acquisition unit, a historical status storage unit, and an incremental analysis unit.

[0056] The system load acquisition unit obtains the current system-level resource status of the device, including at least CPU utilization, memory usage, and I / O read / write status. The process load acquisition unit traverses the currently running processes and obtains the CPU utilization, memory usage, and I / O read / write data for each process. The above resource status can be collected periodically according to a preset sampling period.

[0057] The historical state storage unit saves the resource state corresponding to the previous sampling period. For process-level resource states, the process identifier can be used as an index for storage. When a process exists in the current sampling period but not in the previous sampling period, the process can be marked as a newly appearing process, and the current sample value can be used as its initial reference state.

[0058] The incremental analysis unit acquires the current sample value and the previous sample value, respectively, and determines the corresponding resource changes for the three resource dimensions: CPU, memory, and IO. The resource change is obtained by the difference between the current sample value and the previous sample value. For any resource dimension R, the resource change can be expressed as: ΔR = R_current-R_previous Here, R_current represents the resource state obtained in the current sampling period, and R_previous represents the corresponding resource state obtained in the previous sampling period. The original sampled values ​​of different resource dimensions have different physical meanings, and the incremental analysis unit determines their change based on the sampling attributes corresponding to the resource dimensions.

[0059] The incremental analysis unit can determine anomalous resource dimensions by combining system-level and process-level resource changes. For example, when the system CPU utilization increases significantly within adjacent sampling periods, and the CPU utilization of one or more processes simultaneously shows a large increase, CPU can be identified as the current anomalous resource dimension, and the corresponding process can be designated as a CPU anomalous candidate process. Similarly, memory anomalies and I / O anomalies can be identified. The same process can simultaneously be an anomalous candidate process for multiple resource dimensions; in this case, the primary anomalous resource dimension is determined based on the current resource governance objectives.

[0060] When resource changes exceed a preset threshold or deviate significantly from the historical baseline, they are identified as abnormal resource dimensions. By introducing resource change data, it is possible to distinguish between consistently high but stable resource usage and processes that rapidly increase resource usage during the sampling period. To reduce the impact of instantaneous sampling fluctuations, correlation analysis can also be performed on increments obtained from multiple consecutive sampling periods.

[0061] Please see Figure 5 The filtering and judgment module 130 includes a process status acquisition unit, a pseudo foreground service identification unit, a protection condition judgment unit, a chain judgment unit, and a candidate process output unit.

[0062] The filtering and judgment module obtains the set of currently running processes and establishes corresponding process status information for each running process, which is used to reflect at least the user interaction status, system function dependency status, resource activity status, task usage status, and historical cleanup status of the process.

[0063] Multidimensional filtering does not determine whether to clean up a process solely based on its resource consumption; instead, it first assesses whether a process possesses attributes that make it unsuitable for cleanup. Only when a process fails to meet its corresponding protection conditions is it allowed to enter the set of processes eligible for cleanup.

[0064] The pseudo-foreground service identification unit is used to identify whether a third-party application process appears as a foreground or perceptible process by maintaining a high perceptible priority state. When a third-party application process has a high system process priority or other perceptible state, but further acquisition of its actual user interaction state reveals no corresponding effective user interaction, it can be identified as a pseudo-foreground service process, and its cleanup protection level can be adjusted to the level corresponding to a normal background service. The effective user interaction is determined based on at least one or more of the following: whether a visible window exists, whether it is in focus, and whether it receives user input events. As a specific and definite implementation method, when a third-party application process is identified as having a higher perceptible priority state than a normal background service, and simultaneously satisfies the conditions of not having a visible window and not being in a user input focus state, it can be determined that there is no effective user interaction, thereby forcibly downgrading its priority to a normal background service. In another implementation method, it can also be determined based on at least two of the three indicators: whether a visible window exists, whether it is in focus, and whether it receives user input events. The adjustment does not change the actual business function executed by the third-party application, but rather downgrades the cleanup judgment state used by this resource governance service.

[0065] After identifying and adjusting the pseudo-foreground service, the chained decision unit executes the non-cleanable process determination according to a preset priority order. For the current process to be determined, the first protection condition is first obtained and judged; if the first protection condition is not met, the next protection condition is judged; if any protection condition is met, the current process is immediately marked as a non-cleanable process, and the subsequent determination of the current process ends. This forms a short-circuit return mechanism to avoid unnecessary status queries for processes that have been determined to be non-cleanable.

[0066] The conditions for chained non-cleanable status checks can include: currently foreground application, using Bluetooth, desktop process, priority higher than the scene threshold, previous application, heavy disk writing, playing audio, desktop widget present, default wallpaper, default input method, in recent task protection set, recently killed, using location services, default voice engine, visible window, and currently in a call. These specific conditions can be categorized by function as: foreground application (currently foreground application, visible window, etc.), system critical service dependencies (using Bluetooth, desktop process, default input method, default voice engine, currently in a call, etc.), recent usage status (previous application, in recent task protection set, etc.), resource activity status (heavy disk writing, playing audio, using location services, etc.), and historical cleanup status (recently killed, etc.). Chained checks are executed sequentially according to a preset priority order. It is not required that all conditions be executed in every check. The chained check unit executes each condition in a preset priority order, and immediately outputs an "uncleanable" result when a protection condition is met.

[0067] For processes that do not meet any of the non-cleanable conditions, the candidate process output unit marks them as cleanable processes. Cleanable processes still need to undergo subsequent scenario-based sorting and differentiated cleanup processes, which does not mean that the process will be terminated immediately.

[0068] By setting the pseudo-foreground service degradation before the chained uncleanable determination, the resource governance service can first correct the apparent priority state of the process before performing user interaction state and system function dependency state judgments. At the same time, by separating resource anomaly identification from uncleanable determination, high resource consumption is not directly equivalent to cleanability. Instead, a process must simultaneously meet two conditions: "having resource governance value" and "not hitting the current protection condition," before it can enter the subsequent cleanup queue.

[0069] Please see Figure 6 The sorting and cleaning module 140 includes a scenario strategy determination unit, a resource sorting unit, a task attribute division unit, and an interleaved rearrangement unit.

[0070] The scenario strategy determination unit obtains the current resource governance objective and determines the corresponding resource dimensions and cleanup strategies based on this objective. In temperature-controlled scenarios, CPU usage is used as the primary sorting dimension, and cleanupable processes are sorted from highest to lowest CPU usage. In other resource governance scenarios, processes are first sorted from highest to lowest memory usage, and then further sorted from highest to lowest I / O read / write data volume when memory usage is the same or close. The resource sorting unit does not simply look for the "process with the highest resource usage," but rather for the "cleanupable process that best matches the current resource governance objective."

[0071] After resource-dimensional sorting is completed, the task attribute partitioning unit obtains the most recent task attributes corresponding to each cleanable process, and divides the cleanable processes that have completed resource-dimensional sorting into a subset of most recent tasks and a subset of non-most recent tasks. The most recent task attributes are mainly used to adjust the order of candidate processes after resource-dimensional sorting, rather than directly determining whether a process is eligible for cleanup.

[0072] The staggered rearrangement unit performs staggered rearrangement on the two subsets. In one implementation, the highest-priority process to be cleaned up is first selected from the non-recent task subset, then the highest-priority process to be cleaned up is selected from the recent task subset, and the process returns to the non-recent task subset to continue selection, alternately forming a queue of processes to be cleaned up. When one subset has no remaining processes, processes are selected from the other subset according to its remaining sort order. The original resource-dimensional sorting relationship within each subset is maintained during staggered rearrangement.

[0073] For example, after sorting by resource dimension, the processes with high memory usage in the non-recent task subset are processes A, B, and C, and the processes with high memory usage in the recent task subset are processes D, E, and F. After interleaving and rearranging, the process can be: process A → process D → process B → process E → process C → process F.

[0074] The above processing forms a two-level cleanup order: the first level is the resource governance order, which selects resource dimensions and determines resource consumption priorities based on the current scenario; the second level is the user behavior order, which involves interleaving the already formed resource priority queue based on the attributes of recent tasks. Interleaving does not mean absolute protection for recent task processes; recent task processes that have passed multi-dimensional filtering and chain-based non-cleanup determination can still enter the candidate set. The interleaving mechanism simply reduces the probability of them continuously entering the cleanup sequence when forming the cleanup queue.

[0075] Please see Figure 7 The slot cleanup unit in the sorting and cleanup module establishes slot states corresponding to the three resource dimensions of memory, CPU, and I / O. At the start of this cleanup task, all three slots are initialized to the open state. When a slot is open, it indicates that cleanup of the corresponding resource dimension is allowed; when a slot is closed, it indicates that the corresponding cleanup termination condition for that resource dimension has been met. It should be noted that the 'slots' (including memory slots, CPU slots, and I / O slots) mentioned in this article are essentially resource dimension cleanup status identifiers. These identifiers indicate whether a specific resource dimension still allows the cleanup operation to continue. Specifically, when the cleanup status identifier (i.e., the slot) of a resource dimension is open, it indicates that cleanup of the corresponding resource dimension is allowed; when it is closed, it indicates that the corresponding cleanup termination condition for that resource dimension has been met.

[0076] When traversing the queue of processes to be cleaned up, the primary resource dimension and the current status of the three slots corresponding to the current process are first determined. If the slot for the corresponding resource dimension is already closed, the cleanup operation for that resource dimension corresponding to the current process is skipped; if the slot for the corresponding resource dimension is still open, the corresponding cleanup operation is performed according to the current resource dimension, and the slot status is updated according to the closing condition corresponding to that resource dimension after the cleanup is completed.

[0077] For memory cleanup: After performing memory cleanup operations on the current process, the kernel enters a reclamation waiting process, polling the remaining memory status of the system. When the remaining memory has reached the corresponding target, or the number of memory-related processes cleaned up has reached the corresponding target, the memory slot is closed. Therefore, the closure of the memory slot can be triggered by either "the remaining system memory after cleanup reaches the corresponding target" or "the number of memory-related processes cleaned up reaches the corresponding target".

[0078] For IO-related cleanup: After completing the cleanup of IO-related processes, the IO slots are directly closed. In other words, IO resources are controlled by a single cleanup trigger, which terminates any further cleanup efforts at the IO level.

[0079] For CPU-related cleanup: Perform one round of traversal on the current queue of processes to be cleaned up. During this round of traversal, clean up processes that meet the CPU management conditions and whose CPU slots are still open; after completing this round of traversal, directly close the CPU slots, and do not re-traverse and perform CPU-related cleanup for the same cleanup task.

[0080] Each of the three slots undergoes an independent state change process: Memory slot: Open → Perform memory cleanup → Wait for kernel reclamation → Determine remaining memory or amount to be cleaned up → Close; CPU slot: Open → Perform one round of CPU cleanup → One round of traversal ends → Close; IO slot: Open → Perform IO cleanup → Complete cleanup → Close.

[0081] After processing each candidate process, the cleanup status judgment unit checks the status of the three slots. If all three slots are closed, it stops traversing the queue of processes to be cleaned and ends the current cleanup task. If at least one slot is still open, it continues traversing. For processes with multiple resource anomaly characteristics, the priority resource dimension for processing can be determined based on the current resource governance goals.

[0082] By assigning independent slots to memory, CPU, and I / O, and setting different shutdown conditions for different resource dimensions, the resource governance process forms a processing structure of "unified candidate queue, independent resource status, differentiated cleanup depth, and unified termination judgment." Memory resources adopt a feedback process of "cleanup—waiting for reclamation—re-judgment," CPU resources adopt a limited cleanup process of "closing after one round of traversal," and I / O resources adopt a fast termination process of "closing immediately after execution," ensuring that the cleanup depth of different resources matches their resource reclamation characteristics.

[0083] Please see Figure 8 The resource governance service also includes a parameter initialization module and a cleanup history management module.

[0084] When the resource governance service starts, the parameter initialization module obtains the hardware resource parameters of the current electronic device, including at least the total memory capacity and the maximum CPU frequency of each processor core. Based on the obtained hardware resource parameters, it determines the resource level to which the current device belongs and the corresponding initial resource governance parameters. If the actual device parameters are between two preset levels, linear interpolation can be performed based on the position of the actual device parameters between adjacent levels. The initialized threshold is provided to the triggering module and the acquisition module, enabling the same resource governance logic to adjust the trigger sensitivity according to the device's hardware capabilities.

[0085] After the resource governance service performs a process cleanup, the cleanup history management module obtains the package name of the cleaned-up process and writes it into the FIFO recording ring. The FIFO recording ring updates the records in a first-in, first-out manner, and removes the earliest written record when the recording capacity reaches a preset capacity. The cleanup time information can also be correlated to determine whether a process is still within a short-term protection window.

[0086] When the next resource governance task enters the filtering and judgment phase, the cleanup history management module matches the packet name of the currently abnormal process with the historical records in the FIFO record ring. When the packet name of the current process matches a valid record in the FIFO record ring, the process is marked as a short-term anti-vibration protection object, and the cleanup is skipped in the current cleanup task. The FIFO record ring is not a permanent process whitelist, but a dynamic historical record with a limited lifespan. The short-term anti-vibration protection window can be set according to the device operating status or the current resource governance scenario.

[0087] This mechanism is particularly suitable for situations where a process is restarted due to system services, user operations, or the application's own mechanisms after being cleaned up. It can prevent the same process from going through a cycle of "resource abnormality → process cleanup → process restart → re-entering a high resource consumption state → being cleaned up again", reducing the additional overhead caused by application restart, state recovery, and system scheduling.

[0088] The device hardware parameter adaptive mechanism and the FIFO anti-oscillation mechanism can work together to form a closed-loop process of "hardware capability initialization—operational status perception—resource management—historical feedback cleanup". The FIFO recording loop is only used to prevent repeated cleanup in the short term and does not change the other protection conditions in the aforementioned chain-based non-cleanable determination. After the FIFO protection window ends, a process still needs to go through multi-dimensional filtering and chain-based non-cleanable determination again.

[0089] In one embodiment of an electronic device, the electronic device includes at least one processor and a memory communicatively connected to the at least one processor. The memory stores a resource monitoring and process cleanup program, which, when executed by the at least one processor, causes the at least one processor to perform the system resource monitoring and process cleanup method of any of the foregoing embodiments.

[0090] The electronic device can be a mobile terminal with a multi-process operating system, such as a smartphone or tablet. The resource management system can run as a system-level service and obtain corresponding system-level and process-level information through the process status, resource statistics, and process management interfaces provided by the operating system. This invention does not limit the electronic device to a mobile terminal; as long as the electronic device has the processing capability to run multiple processes and monitor and manage process resources, the resource management method of this invention can be used.

[0091] The specific resource acquisition methods, process status acquisition methods, and process cleanup interfaces in this invention can be adapted to the operating system running on the electronic device without changing the resource governance logic described in this invention. The specific system interfaces are engineering adaptation means for implementing the technical solution of this invention and do not affect the core processing flow consisting of dual-channel triggering, resource change identification, multi-dimensional filtering and chain judgment, scenario-based sorting and staggered rearrangement, and three-slot differentiated early stop cleanup.

[0092] It should be understood that the present invention has been described in detail above with reference to the accompanying drawings, but the present invention is not limited to the above embodiments. Equivalent substitutions or modifications made by those skilled in the art without departing from the concept of the present invention should fall within the protection scope of the present invention.

Claims

1. A method for system resource monitoring and process cleanup, characterized in that, include: Cleanup is triggered through a dual-channel approach of external scenario-based requests and kernel events, and the current resource governance target is determined based on the triggering scenario. Collect system-level load and process-level load, and determine the resource change of each resource dimension based on the current sample value and the previous sample value, so as to identify abnormal resource dimensions and corresponding abnormal processes; Perform multi-dimensional filtering and chain-based non-cleanable determination on the abnormal processes to filter out cleanable processes; Based on the resource governance objectives, the corresponding resource dimensions and cleanup strategies are determined. The cleanupable processes are sorted according to the resource dimensions corresponding to the scenario, and the most recent tasks and non-most recent tasks are alternately rearranged to form a cleanup queue. Based on the states of the memory, CPU, and I / O slots, differentiated early stopping cleanup is performed on the rearranged processes. In the memory dimension, after cleanup, the slots are polled and waited for the kernel to reclaim them until the target is reached before closing the slots. In the CPU dimension, the slots are closed after only one round of traversal. In the I / O dimension, the slots are closed immediately after cleanup.

2. The method according to claim 1, characterized in that, The dual-channel triggering includes: Receive scene parameters from external modules, including scene identifier, cleanup level, and target memory; and Listen for UEvent events reported by kernel nodes when the load exceeds a threshold.

3. The method according to claim 1, characterized in that, The resource change is obtained by reading the current values ​​of CPU utilization, memory usage, and IO read / write data of the system and each process, and then calculating the difference between these values ​​and the previous sampled values.

4. The method according to claim 1, characterized in that, The multi-dimensional filtering includes pseudo foreground service degradation: when a third-party application process is identified as being in a perceptible priority state and there is no effective user interaction, its priority is forcibly downgraded to a normal background service. The chain-based non-cleanable determination is executed sequentially according to a preset priority order. If any item is hit, the process is marked as non-cleanable and short-circuited back.

5. The method according to claim 1, characterized in that, The conditions for determining that a chain cannot be cleaned up include at least one of the following: foreground application, system critical service dependency, recent usage status, resource activity status, and historical cleanup status.

6. The method according to claim 1, characterized in that, The sorting and alternating rearrangement include: The sorting dimension is selected according to the triggering scenario: temperature control scenarios are sorted by CPU usage from high to low, and other scenarios are first sorted by memory usage from high to low, and then by IO read and write data volume from high to low, forming a resource priority queue. The processes in the resource priority queue are divided into a subset of recent tasks and a subset of non-recent tasks based on the recent task attribute; The highest priority processes are alternately selected from the non-recent task subset and the recent task subset to form the queue to be cleaned up, and the original resource dimension sorting relationship within each subset is maintained during the alternating selection; when the processes in any subset have been selected, the remaining processes are selected in sequence according to the original resource dimension sorting relationship within the other subset.

7. The method according to claim 1, characterized in that, Independent cleanup status identifiers are maintained for different resource dimensions, and different cleanup termination rules are adopted, including: Initialize the memory, CPU, and I / O slots to be all in the open state; When traversing the queue to be cleaned up, if the slot for the resource dimension corresponding to the current process is already closed, then skip the cleanup of that dimension. For memory cleanup, after performing the cleanup, poll and wait for the kernel to reclaim the memory until the remaining memory reaches the corresponding target, the cleanup quantity reaches the corresponding target, or the polling waiting time reaches the preset timeout threshold, and then close the memory slot. For CPU-related cleanup, the queue to be cleaned up is traversed only once, and the CPU slot is closed after the traversal is completed. For I / O cleanup, after performing cleanup on the target process, the I / O slots are closed; Stop traversing and end cleanup when all memory slots, CPU slots, and I / O slots are closed.

8. The method according to claim 1, characterized in that, The method further includes: When the service starts, the trigger thresholds for each dimension are adaptively set based on the total number of archive bits in the device and the maximum CPU frequency of each core. The process package name to be cleaned is added to the FIFO record ring. If it is hit in subsequent cleanups, it will be skipped, forming a short-term anti-vibration protection window.

9. A system resource monitoring and process cleanup system, characterized in that, include: The triggering module is used to trigger cleanup through a dual-channel approach of external scenario-based requests and kernel events, and to determine the current resource governance target based on the triggering scenario. The data acquisition module is used to collect system-level load and process-level load, and determine the resource change of each resource dimension based on the current sample value and the previous sample value, so as to identify abnormal resource dimensions and corresponding abnormal processes. The filtering and determination module is used to perform multi-dimensional filtering and chain-like non-cleanable determination on the abnormal process. The sorting and cleanup module is used to determine the corresponding resource dimensions and cleanup strategies based on resource governance objectives, perform scenario-based sorting and staggered rearrangement of cleanable processes, and perform differentiated early stop cleanup based on the status of memory, CPU, and IO slots.

10. An electronic device, characterized in that, It includes at least one processor and a memory communicatively connected to the at least one processor; The memory stores instructions that can be executed by the at least one processor, which, when executed by the at least one processor, enable the at least one processor to perform the system resource monitoring and process cleanup method according to any one of claims 1 to 8.