WO2023185684A1 - Process killing method for application, and electronic device - Google Patents

Process killing method for application, and electronic device Download PDF

Info

Publication number
WO2023185684A1
WO2023185684A1 PCT/CN2023/083751 CN2023083751W WO2023185684A1 WO 2023185684 A1 WO2023185684 A1 WO 2023185684A1 CN 2023083751 W CN2023083751 W CN 2023083751W WO 2023185684 A1 WO2023185684 A1 WO 2023185684A1
Authority
WO
WIPO (PCT)
Prior art keywords
memory
electronic device
type
occupied
component
Prior art date
Application number
PCT/CN2023/083751
Other languages
French (fr)
Chinese (zh)
Inventor
季柯丞
杨文飞
常演
王绪
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Publication of WO2023185684A1 publication Critical patent/WO2023185684A1/en

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/50Monitoring users, programs or devices to maintain the integrity of platforms, e.g. of processors, firmware or operating systems
    • G06F21/55Detecting local intrusion or implementing counter-measures
    • G06F21/56Computer malware detection or handling, e.g. anti-virus arrangements
    • G06F21/566Dynamic detection, i.e. detection performed at run-time, e.g. emulation, suspicious activities
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • G06F9/5016Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals the resource being the memory

Definitions

  • the present application relates to the field of operating systems, and in particular, to an application process checking and killing method and an electronic device.
  • electronic devices can use process scanning and killing methods to clean up the memory occupied by processes.
  • electronic devices usually clean up the memory occupied by processes that are not commonly used or will not be used in the short term based on the user's usage habits.
  • the memory released after each process killing does not account for a high proportion of the entire machine's memory. Therefore, electronic devices need to frequently trigger process killing behaviors, which can easily cause system crashes.
  • This application provides a process checking and killing method for an application program and an electronic device, which can prevent electronic devices from frequently triggering process checking and killing behaviors, and is conducive to improving the smoothness and stability of the operation of electronic devices.
  • the first aspect provides a process checking and killing method for application programs.
  • the method includes: an electronic device runs one or more application APPs; the electronic device counts the first type of memory and the second type of memory occupied by each process started by one or more APPs.
  • Class memory the first class of memory includes one or more of the memory occupied by file pages, core library files, cached data, and user-mode anonymous pages; the second class of memory includes the memory occupied by streaming media and the kernel Occupying one or more items in the memory; when it is detected that the memory of the electronic device meets the preset conditions, the electronic device determines from the processes started by one or more APPs based on the first type of memory and the second type of memory occupied by each process.
  • Target process electronic device killing target process.
  • the electronic device when counting the memory occupied during the running of the process, the first type of memory and the second type of memory occupied during the running of the process are also counted, that is, the total occupation of the first type of memory and the second type of memory is counted. Then, when the electronic device performs process killing, it will determine the target process based on the total occupation of the first type of memory and the second type of memory of each candidate process. Moreover, after killing the target processes, the electronic device will reclaim the first type of memory and the second type of memory occupied by these target processes.
  • the first type of memory and the second type of memory recovered through this method account for a high proportion of the entire machine memory, it is conducive to maintaining the available memory of the electronic device at a higher value and preventing the electronic device from frequently triggering process checks. Killing behavior is conducive to improving the smoothness and stability of the operation of electronic devices.
  • the memory of the electronic device meeting the preset conditions includes: the remaining memory amount of the electronic device is less than or equal to the first threshold, and the blocking duration of the process in the electronic device due to untimely memory allocation is greater than or equal to the second threshold. Threshold, the total occupied amount of the second type of memory in the electronic device is greater than or equal to any of the third thresholds.
  • the electronic device may use a waterline triggering mechanism based on the amount of remaining memory to kill processes. Specifically, the electronic device can monitor the amount of remaining memory of the electronic device, where the remaining memory refers to available memory, which can include free memory in the system, as well as memory occupied by file pages, core library files, and cached data. when monitoring When the amount of remaining memory is less than or equal to the threshold 1, the electronic device starts the process killing process.
  • the electronic device may also use a triggering mechanism based on Pressure Stall Information (PSI) to kill the process.
  • PSI Pressure Stall Information
  • the electronic device can monitor the blocking time caused by untimely memory allocation when each process on the electronic device is running, that is, the time the process waits for memory allocation. When it is detected that the blocking time of the process is greater than or equal to the threshold 2, the process killing process is started.
  • PSI Pressure Stall Information
  • the electronic device can also use a waterline triggering mechanism based on the second type of memory usage to kill the process. Specifically, the electronic device can monitor the total occupied amount of the second type of memory in the electronic device. When it is detected that the total occupied amount of the second type of memory is greater than or equal to the threshold 3, the electronic device starts the process killing process.
  • this embodiment provides a method of monitoring the memory occupancy of an electronic device from the perspective of monitoring the second type of memory occupancy.
  • the second type of memory occupancy is usually large, which is one of the main reasons for the memory shortage of electronic devices. Therefore, the startup process killing process is determined from the perspective of monitoring the second type of memory occupancy. Being able to more accurately monitor the memory usage of electronic devices is more conducive to fundamentally solving the problems of high memory pressure and slow system operation caused by high second-type memory usage of electronic devices.
  • this embodiment realizes the function of recycling the second type of memory, it effectively reduces the occupation of the second type of memory, which helps the system's available memory to stay at a higher threshold for a long time, ensuring the stability and smoothness of the system operation. .
  • the first type of memory and the second type of memory occupied by the first process include the first type of memory and/or the second type of memory occupied by the second process called by the first process. Any one of the processes started for one or more APPs, and the second process is not called by other processes except the first process.
  • the electronic device determines the target process from the processes started by one or more APPs based on the first type of memory and the second type of memory occupied by each process, including: after the electronic device determines that the first process is the target process, it determines that the second process is also target process.
  • the electronic device can also determine other processes called by the target process based on the target process and the linkage relationships between different processes maintained by the electronic device, and determine These other processes are also processes that need to be killed, that is, they are also target processes. It can be understood that after the target process (for example, the first process) is checked and killed, if other processes (such as the second process) called by the target process are only called by the target process, then these other processes can also be checked and killed. Memory occupied by other processes can also be reclaimed. This will help further improve memory utilization and improve the system's operating speed. Of course, if other processes called by the target process are also called by other non-target processes, these other processes cannot be killed to ensure the normal operation of other non-target processes.
  • the method further includes: the electronic device determines whether the first component associated with the target process is a key component; where the key component is a component containing key information, and the key information Including information that will affect the stability of the system operation or the user experience when the target process is running; if it is determined that the first component is a critical component, the electronic device retains the information of the first component; if it is determined that the first component is not a critical component, The electronic device then clears the information of the first component.
  • some processes with higher priority or system level may be determined as target processes.
  • the key components in the target process are identified (that is, the information in the key components affects the stability of the system or the user experience) , and preserve key components in the target process. Later, when restarting the target process (or restarting the APP corresponding to the target process), you can directly use the retained key components to restore the target process to ensure that the system Operation stability or ensuring user experience.
  • the key information includes one or more of the information on the negative screen, the information on the magazine lock screen, the information displayed on the active screen, the information on the weather widget, and the reading progress information of the electronic document.
  • the method further includes: the electronic device calls the first component; when it is queried that the electronic device retains the first component After receiving the information of the component, the electronic device starts the third process; the electronic device establishes an association between the third process and the first component based on the retained information of the first component.
  • an electronic device including: a processor and a memory, the memory is coupled to the processor, the memory is used to store computer program code, the computer program code includes computer instructions, the processor The computer instructions are read from the memory, so that the electronic device performs the method described in the above aspect and any possible implementation manner therein.
  • a third aspect is to provide a device, which is included in an electronic device and has the function of realizing the behavior of the electronic device in any of the above aspects and possible implementation methods.
  • This function can be implemented by hardware, or it can be implemented by hardware executing corresponding software.
  • the hardware or software includes at least one module or unit corresponding to the above functions. For example, detection module or unit, statistical module or unit, determination module or unit, and killing module or unit, etc.
  • the fourth aspect is to provide a computer-readable storage medium.
  • the computer-readable storage medium includes computer instructions. When the computer instructions are run on an electronic device, the electronic device causes the electronic device to perform the above aspects and any possible implementation manner thereof. the method described.
  • a fifth aspect provides a chip system, including a processor.
  • the processor executes instructions, the processor executes the method described in the above aspects and any of the possible implementations.
  • a computer program product is provided.
  • the computer program product When the computer program product is run on a computer, it causes the computer to execute the method described in the above aspects and any of the possible implementations.
  • Figure 1 is a schematic diagram of the hardware structure of an electronic device provided by an embodiment of the present application.
  • Figure 2A is a schematic diagram of the software structure of an electronic device provided by an embodiment of the present application.
  • Figure 2B is a schematic diagram of memory occupied by a process of an application provided by an embodiment of the present application
  • FIG. 3 is a schematic flowchart of an application process checking and killing method provided by an embodiment of the present application
  • Figure 4 is a schematic diagram of a process association provided by an embodiment of the present application.
  • Figure 5 is a schematic diagram of a statistical method for process memory usage provided by an embodiment of the present application.
  • Figure 6 is a schematic flowchart of another application process checking and killing method provided by an embodiment of the present application.
  • Figure 7 is a schematic flowchart of a method for recovering key components in an application provided by an embodiment of the present application.
  • FIG. 8 is a schematic structural diagram of a chip system provided by an embodiment of the present application.
  • first and second are used for descriptive purposes only and cannot be understood as indicating or implying relative importance or implicitly indicating the quantity of indicated technical features. Therefore, features defined as “first” and “second” may explicitly or implicitly include one or more of these features. In the description of the embodiments of this application, unless otherwise specified, "plurality” means two or more.
  • Embodiments of the present application provide a process checking and killing method for an application (application, APP), which can be applied to an electronic device installed with one or more APPs.
  • the electronic device in the embodiment of the present application may be a mobile phone, a tablet computer, a personal computer (PC), a personal digital assistant (PDA), a smart watch, a netbook, a wearable electronic device, an enhanced Reality technology (augmented reality, AR) equipment, virtual reality (VR) equipment, vehicle-mounted equipment, smart screens, smart cars, smart speakers, robots, etc.
  • This application does not place special restrictions on the specific forms of this electronic equipment.
  • FIG. 1 shows a schematic structural diagram of an electronic device 100 .
  • the electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2 , mobile communication module 150, wireless communication module 160, audio module 170, speaker 170A, receiver 170B, microphone 170C, headphone interface 170D, sensor module 180, button 190, motor 191, indicator 192, camera 193, display screen 194, and Subscriber identification module (SIM) card interface 195, etc.
  • a processor 110 an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2 , mobile communication module 150, wireless communication module 160, audio module 170, speaker 170A, receiver 170B, microphone 170C, headphone interface 170D, sensor module 180, button 190, motor 191, indicator 192, camera 193, display
  • the sensor module 180 may include a pressure sensor 180A, a gyro sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, and ambient light. Sensor 180L, bone conduction sensor 180M, etc.
  • the structure illustrated in the embodiment of the present invention does not constitute a specific limitation on the electronic device 100 .
  • the electronic device 100 may include more or fewer components than shown in the figures, or some components may be combined, some components may be separated, or some components may be arranged differently.
  • the components illustrated may be implemented in hardware, software, or a combination of software and hardware.
  • the processor 110 may include one or more processing units.
  • the processor 110 may include an application processor (application processor, AP), a modem processor, a graphics processing unit (GPU), and an image signal processor. (image signal processor, ISP), controller, video codec, digital signal processor (digital signal processor, DSP), baseband processor, and/or neural network processor (neural-network processing unit, NPU), etc.
  • application processor application processor, AP
  • modem processor graphics processing unit
  • GPU graphics processing unit
  • image signal processor image signal processor
  • ISP image signal processor
  • controller video codec
  • digital signal processor digital signal processor
  • DSP digital signal processor
  • baseband processor baseband processor
  • neural network processor neural-network processing unit
  • the controller can generate operation control signals based on the instruction operation code and timing signals to complete the control of fetching and executing instructions.
  • the processor 110 may also be provided with a memory for storing instructions and data.
  • the memory in processor 110 is cache memory. This memory may hold instructions or data that have been recently used or recycled by processor 110 . If the processor 110 needs to use the instructions or data again, it can be called directly from the memory. Repeated access is avoided and the waiting time of the processor 110 is reduced, thus improving the efficiency of the system.
  • processor 110 may include one or more interfaces.
  • Interfaces may include integrated circuit (inter-integrated circuit, I2C) interface, integrated circuit built-in audio (inter-integrated circuit sound, I2S) interface, pulse code modulation (pulse code modulation, PCM) interface, universal asynchronous receiver and transmitter (universal asynchronous receiver/transmitter (UART) interface, mobile industry processor interface (MIPI), general-purpose input/output (GPIO) interface, subscriber identity module (SIM) interface, and /or universal serial bus (USB) interface, etc.
  • I2C integrated circuit
  • I2S integrated circuit built-in audio
  • PCM pulse code modulation
  • UART universal asynchronous receiver and transmitter
  • MIPI mobile industry processor interface
  • GPIO general-purpose input/output
  • SIM subscriber identity module
  • USB universal serial bus
  • the charging management module 140 is used to receive charging input from the charger.
  • the charger can be a wireless charger or a wired charger.
  • the charging management module 140 may receive charging input from the wired charger through the USB interface 130 .
  • the charging management module 140 may receive wireless charging input through the wireless charging coil of the electronic device 100 . While the charging management module 140 charges the battery 142, it can also provide power to the electronic device through the power management module 141.
  • the power management module 141 is used to connect the battery 142, the charging management module 140 and the processor 110.
  • the power management module 141 receives input from the battery 142 and/or the charging management module 140, and supplies power to the processor 110, the internal memory 121, the display screen 194, the camera 193, the wireless communication module 160, and the like.
  • the power management module 141 can also be used to monitor battery capacity, battery cycle times, battery health status (leakage, impedance) and other parameters.
  • the power management module 141 may also be provided in the processor 110 .
  • the power management module 141 and the charging management module 140 may also be provided in the same device.
  • the wireless communication function of the electronic device 100 can be implemented through the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modem processor and the baseband processor.
  • Antenna 1 and Antenna 2 are used to transmit and receive electromagnetic wave signals.
  • Each antenna in electronic device 100 may be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve antenna utilization. For example: Antenna 1 can be reused as a diversity antenna for a wireless LAN. In other embodiments, antennas may be used in conjunction with tuning switches.
  • the mobile communication module 150 can provide solutions for wireless communication including 2G/3G/4G/5G applied on the electronic device 100 .
  • the mobile communication module 150 may include at least one filter, switch, power amplifier, low noise amplifier (LNA), etc.
  • the mobile communication module 150 can receive electromagnetic waves through the antenna 1, perform filtering, amplification and other processing on the received electromagnetic waves, and transmit them to the modem processor for demodulation.
  • the mobile communication module 150 can also amplify the signal modulated by the modem processor and convert it into electromagnetic waves through the antenna 1 for radiation.
  • at least part of the functional modules of the mobile communication module 150 may be disposed in the processor 110 .
  • at least part of the functional modules of the mobile communication module 150 and at least part of the modules of the processor 110 may be provided in the same device.
  • a modem processor may include a modulator and a demodulator.
  • the modulator is used to modulate the low-frequency baseband signal to be sent into a medium-high frequency signal.
  • the demodulator is used to demodulate the received electromagnetic wave signal into a low-frequency baseband signal.
  • the demodulator then transmits the demodulated low-frequency baseband signal to the baseband processor for processing.
  • the application processor outputs sound signals through audio devices (not limited to speaker 170A, receiver 170B, etc.), or displays images or videos through display screen 194.
  • the modem processor may be a stand-alone device.
  • the modem processor may be independent of the processor 110 and may be provided in the same device as the mobile communication module 150 or other functional modules.
  • the wireless communication module 160 can provide applications on the electronic device 100 including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) network), Bluetooth (bluetooth, BT), and global navigation satellites.
  • WLAN wireless local area networks
  • System global navigation satellite system, GNSS
  • frequency modulation frequency modulation, FM
  • near field communication technology near field communication, NFC
  • infrared technology infrared, IR
  • the wireless communication module 160 may be one or more devices integrating at least one communication processing module.
  • the wireless communication module 160 receives electromagnetic waves via the antenna 2 , frequency modulates and filters the electromagnetic wave signals, and sends the processed signals to the processor 110 .
  • the wireless communication module 160 can also receive the signal to be sent from the processor 110, frequency modulate it, amplify it, and convert it into electromagnetic waves through the antenna 2 for radiation.
  • the electronic device 100 implements display functions through a GPU, a display screen 194, an application processor, and the like.
  • the GPU is an image processing microprocessor and is connected to the display screen 194 and the application processor. GPUs are used to perform mathematical and geometric calculations for graphics rendering.
  • Processor 110 may include one or more GPUs that execute program instructions to generate or alter display information.
  • the display screen 194 is used to display images, videos, etc.
  • Display 194 includes a display panel.
  • the display panel can use a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active matrix organic light emitting diode or an active matrix organic light emitting diode (active-matrix organic light emitting diode).
  • LCD liquid crystal display
  • OLED organic light-emitting diode
  • AMOLED organic light-emitting diode
  • FLED flexible light-emitting diode
  • Miniled MicroLed, Micro-oLed, quantum dot light emitting diode (QLED), etc.
  • the electronic device 100 may include 1 or N display screens 194, where N is a positive integer greater than 1.
  • the electronic device 100 can implement the shooting function through an ISP, a camera 193, a video codec, a GPU, a display screen 194, an application processor, and the like.
  • the ISP is used to process the data fed back by the camera 193.
  • Camera 193 is used to capture still images or video.
  • Digital signal processors are used to process digital signals. In addition to digital image signals, they can also process other digital signals. For example, when the electronic device 100 selects a frequency point, the digital signal processor is used to perform Fourier transform on the frequency point energy.
  • Video codecs are used to compress or decompress digital video. Electronic device 100 may support one or more video codecs. In this way, the electronic device 100 can play or record videos in multiple encoding formats, such as moving picture experts group (MPEG) 1, MPEG2, MPEG3, MPEG4, etc.
  • MPEG moving picture experts group
  • the external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100.
  • the external memory card communicates with the processor 110 through the external memory interface 120 to implement the data storage function. Such as saving music, videos, etc. files in external memory card.
  • Internal memory 121 may be used to store computer executable program code including instruction.
  • the internal memory 121 may include a program storage area and a data storage area.
  • the stored program area can store an operating system, at least one application program required for a function (such as a sound playback function, an image playback function, etc.).
  • the storage data area may store data created during use of the electronic device 100 (such as audio data, phone book, etc.).
  • the internal memory 121 may include high-speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, universal flash storage (UFS), etc.
  • the processor 110 executes various functional applications and data processing of the electronic device 100 by executing instructions stored in the internal memory 121 and/or instructions stored in a memory provided in the processor.
  • the electronic device 100 can implement audio functions through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the headphone interface 170D, and the application processor. Such as music playback, recording, etc.
  • the buttons 190 include a power button, a volume button, etc.
  • Key 190 may be a mechanical key. It can also be a touch button.
  • the electronic device 100 may receive key inputs and generate key signal inputs related to user settings and function control of the electronic device 100 .
  • the software system of the electronic device 100 may adopt a layered architecture, an event-driven architecture, a microkernel architecture, a microservice architecture, or a cloud architecture.
  • the software system of the electronic device 100 may be the Hongmeng system, Android system, etc.
  • This embodiment of the present invention takes the Android system with a layered architecture as an example to illustrate the software structure of the electronic device 100 .
  • FIG. 2A is a software structure block diagram of the electronic device 100 according to the embodiment of the present invention.
  • the layered architecture divides the software into several layers, and each layer has clear roles and division of labor.
  • the layers communicate through software interfaces.
  • the Android system is divided into five layers. From top to bottom, they are the application layer (referred to as the application layer), the application framework layer (referred to as the framework layer), the Android runtime (Android runtime) and the system library. Hardware Abstraction Layer (HAL) and kernel layer.
  • the application layer can include a series of application packages. As shown in Figure 2A, the application package can include camera, gallery, calendar, calling, map, navigation, WLAN, Bluetooth, music, video, short message and other applications.
  • the framework layer provides application programming interface (API) and programming framework for applications in the application layer.
  • API application programming interface
  • the framework layer includes some predefined functions.
  • the framework layer can include activity manager, window manager, content provider, view system, phone manager, resource manager, notification manager, etc.
  • the activity manager is responsible for the startup of all APP processes, the startup of the four major components of the APP (such as activity, service, broadcast receiver, content provider), the interface between APPs and within the APP. switching and the life cycle of various components.
  • a window manager is used to manage window programs. The window manager can obtain the display size, determine whether there is a status bar, lock the screen, capture the screen, etc.
  • Content providers are used to store and retrieve data and make this data accessible to applications. Said data can include videos, images, audio, calls made and received, browsing history and bookmarks, phone books, etc.
  • the view system includes visual controls, such as controls that display text, controls that display pictures, etc.
  • a view system can be used to build applications.
  • the display interface can be composed of one or more views.
  • a display interface including a text message notification icon may include a view for displaying text and a view for displaying pictures.
  • the phone manager is used to provide communication functions of the electronic device 100 . For example, call status management (including connected, hung up, etc.).
  • the resource manager provides various resources to applications, such as localized strings, icons, pictures, layout files, video files, etc.
  • Notification manager enables The application can display notification information in the status bar, which can be used to convey notification-type messages, and can automatically disappear after a short stay without user interaction. For example, the notification manager is used to notify download completion, message reminders, etc.
  • the notification manager can also be notifications that appear in the status bar at the top of the system in the form of charts or scroll bar text, such as notifications for applications running in the background, or notifications that appear on the screen in the form of conversation windows. For example, text information is prompted in the status bar, a beep sounds, the electronic device vibrates, the indicator light flashes, etc.
  • the framework layer also includes a component cleaning module.
  • This component cleaning module is used to clean components according to certain strategies. For example, the least recently used (Least Recently Used, LRU) algorithm is used to filter components that are not frequently used recently, and the filtered components are cleaned up.
  • LRU least recently used
  • the component cleaning module is also used to clean up the components associated with the killed process after receiving information about the kernel-level killing process.
  • the component cleaning module is also used to determine whether the component associated with the process to be killed is a critical component to determine whether to clean the component.
  • key components refer to components that contain key information.
  • the key information includes information that will affect the stability of the system when the target process is running, or affect the user experience. This embodiment will be described in detail below, and will not be described here.
  • Android Runtime includes core libraries and virtual machines. Android runtime is responsible for the scheduling and management of the Android system.
  • the core library contains two parts: one is the functional functions that need to be called by the Java language, and the other is the core library of Android.
  • the application layer and framework layer run in virtual machines.
  • the virtual machine executes the java files of the application layer and framework layer into binary files.
  • the virtual machine is used to perform object life cycle management, stack management, thread management, security and exception management, and garbage collection and other functions.
  • System libraries can include multiple functional modules. For example: surface manager (surface manager), media libraries (Media Libraries), 3D graphics processing libraries (for example: OpenGL ES), 2D graphics engines (for example: SGL), etc.
  • the surface manager is used to manage the display subsystem and provides the integration of 2D and 3D layers for multiple applications.
  • the media library supports playback and recording of a variety of commonly used audio and video formats, as well as static image files, etc.
  • the media library can support a variety of audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.
  • the 3D graphics processing library is used to implement 3D graphics drawing, image rendering, composition, and layer processing.
  • 2D Graphics Engine is a drawing engine for 2D drawing.
  • HAL used to abstract hardware. HAL hides the hardware interface details of a specific platform and provides a virtual hardware platform for the operating system, making it hardware-independent and portable on multiple platforms. In other words, all hardware-related operations required by the upper layer require calling HAL-related APIs, such as audio and video interfaces, GPS interfaces, call interfaces, Wi-Fi interfaces, and other interfaces.
  • HAL-related APIs such as audio and video interfaces, GPS interfaces, call interfaces, Wi-Fi interfaces, and other interfaces.
  • the kernel layer is the layer between hardware and software.
  • the kernel layer includes the kernel allocator, memory statistics module and process killing module. Furthermore, the kernel layer also includes processes/threads, audio and video drivers, GPS drivers, Wi-Fi drivers, etc.
  • the kernel allocator can allocate memory to maintain the running status of each process on the electronic device.
  • the memory statistics module is used to count the various types of memory requested by each process. This memory statistics module is used to count power
  • the various types of memory occupied by each process in the sub-device can include memory occupied by files, memory occupied by user-mode anonymous pages, memory occupied by streaming media, and memory occupied by the kernel.
  • the memory occupied by the above file types may include the memory occupied by file pages, the memory occupied by core library files, and the memory occupied by cache data.
  • the file page may include code files of the application program and resource files (such as icons and pictures) when the application is running.
  • the code files of the application may include the application's configuration files (such as .dex files) and class files (such as .class files).
  • Core library files can include dynamic link libraries (such as .so files, a binary file) that the application needs to access when running.
  • Cached data may include data on file attributes stored in the electronic device for caching purposes.
  • the electronic device can use the mmap allocator (more specifically, the file page allocator) between the application layer and the framework layer in Figure 2A to allocate the memory occupied by the file page and the memory occupied by the cache data.
  • the electronic device can use the mmap allocator (more specifically, the core library file allocator) between the framework layer and the Android runtime layer in Figure 2A to allocate the memory occupied by the core library file.
  • the core library file allocator can be implemented by encapsulating the file page allocator. The embodiments of this application do not limit the specific implementation of the core library file allocator.
  • the memory occupied by the above-mentioned user-mode anonymous page can include dynamically allocated memory during the running of the application, and can include memory consumption caused by calling the API of the framework layer and the programming framework.
  • the APIs and programming frameworks of the called framework layer may include: APIs of high-level languages (such as Java language, JavaScript language, TypeScript language), system components of high-level languages, and system frameworks of system languages (such as C++ language, C language).
  • the electronic device can use the mmap allocator (more specifically the anonymous page allocator) between the framework layer and the Android runtime in Figure 2A to call high-level language APIs and high-level language system components for the application. Allocate the required memory.
  • the electronic device can use the C++ allocator between the framework layer and the system library in Figure 2A to allocate the memory required for the system framework that the application calls the system language (such as C++ language, C language).
  • the operating system can compress user-mode anonymous page data that is not used frequently.
  • the electronic device specifically triggers the behavior of compressing user-mode anonymous page data by the kernel layer, and stores the compressed data (also called Zram compressed data) in the memory space used to store Zram compressed data.
  • the kernel provides unified management and control of Zram compressed data. That is to say, in a specific implementation, the memory space for storing Zram compressed data can be allocated by the kernel allocator of the kernel layer in Figure 2A.
  • the memory occupied by the above streaming media includes the memory allocated by the dedicated streaming media memory allocator.
  • most applications such as video applications, music applications, game applications, social applications, etc.
  • This type of application often requires the computing power of different hardware in the SoC chip in the electronic device.
  • the operating system provides a dedicated streaming media memory allocator (such as Android's ION memory allocator).
  • the electronic device can use the streaming media memory allocator between the system library and HAL in Figure 2A to allocate memory for these applications to play streaming media. It should be noted that the memory occupied by streaming media can only be actively released by the applicant (that is, the application that applies for streaming media memory), and the kernel cannot uniformly control the memory occupied by streaming media.
  • the memory occupied by the above kernel can include: memory consumed by kernel operations such as Vmalloc and Slab, memory used for page table conversion (Page Table Entries, PTE), Kernel Stack that maintains application process information, and memory occupied by Zram compressed data. memory, and shared memory (such as Shmem) for efficient communication between multiple processes.
  • kernel operations such as Vmalloc and Slab
  • memory used for page table conversion Page Table Entries, PTE
  • Kernel Stack that maintains application process information
  • memory occupied by Zram compressed data occupied by Zram compressed data.
  • memory and shared memory (such as Shmem) for efficient communication between multiple processes.
  • the electronic device can use the kernel segmentation of the kernel layer in Figure 2A
  • the orchestrator allocates memory occupied by the kernel.
  • the above memory statistics module can obtain various types of memory occupied by each process from the mmap allocator, C++ allocator, streaming media memory allocator and kernel allocator.
  • the electronic device may also include multiple sub-statistical modules, for example, different sub-statistical modules are respectively provided at mmap allocator, C++ allocator, streaming media memory allocator, etc., for Count the memory allocated by each allocator for the process.
  • the sub-statistics module summarizes the statistical data to the memory statistics module of the kernel layer (also called the total statistics module).
  • the statistics module of the kernel layer analyzes the various types of memory of each process to determine the target of killing. process.
  • the electronic device only sets sub-statistics modules at, for example, mmap allocator, C++ allocator, streaming media memory allocator, kernel allocator, etc., and does not set a total statistics module. Then, the sub-statistical modules directly pass their respective statistical data to the process killing module, and the process killing module analyzes the various types of memory of each process to determine the target process for killing.
  • the embodiments of this application do not specifically limit this.
  • the above-mentioned process killing module is used to detect the triggering events of the process killing process, and select the process to be killed (i.e. the target process) based on the various types of memory occupied by each process detected by the above-mentioned memory statistics module. ), perform scanning and killing on the selected target process, etc.
  • the electronic device can use a waterline triggering mechanism based on the amount of remaining memory to kill the process. Specifically, the electronic device can monitor the remaining memory amount of the electronic device. When it is detected that the remaining memory amount is less than or equal to the threshold 1, the electronic device starts the process killing process.
  • the remaining memory refers to the available memory, which can include the free memory in the system and the memory occupied by files (including the memory occupied by file pages, core library files and cached data). It should be noted that since most file pages, core library files and cache data are backed up in the storage devices of electronic devices (such as Flash devices), during the memory recycling process, the electronic device can directly clean up the memory occupied by this part of the data.
  • the memory occupied by this part of the data is low-overhead recyclable memory. Therefore, the memory occupied by this part of the data belongs to available memory.
  • the electronic device can determine the target process for checking and killing by combining the usage frequency of the process and the amount of memory occupied by the process. For example, when an electronic device starts the killing process, the electronic device first uses the least recently used (Least Recently Used, LRU) algorithm to filter out processes that are not frequently used as candidate processes, and then selects processes based on the memory usage of each candidate process. Select the candidate process that occupies a large amount of memory as the target process, and then kill the target process to release the memory occupied by the target process.
  • LRU least recently used
  • the electronic device can use the top command, the ps command, and other commands, or a combination of any of these commands to obtain the memory usage of each candidate process.
  • the existing technology only counts the memory occupied by the process in the user mode (recorded as the first type of memory), but does not count the memory occupied by the process in the kernel state (recorded as the first type of memory). is the second type of memory).
  • the first type of memory can include memory occupied by files and memory occupied by user-mode anonymous pages.
  • the memory occupied during the running of the process that is not counted in the prior art is recorded as the second type of memory.
  • the second type of memory can include memory occupied by streaming media and memory occupied by the kernel.
  • the first type of memory can be a process using a memory allocator (such as the mmap allocator), or memory allocated through the framework layer using a memory allocator (such as the C++ allocator).
  • the second type of memory can be memory allocated by the process through the system library using a dedicated streaming allocator, or through the kernel allocator at the kernel level.
  • the electronic device since the prior art only counts the first type of memory occupied during the running process of the process, when the electronic device determines the target process based on the occupation of the first type of memory of each candidate process, the electronic device selects the third type of memory. One type of candidate process that occupies a large amount of memory is the target process. Then, after killing the target process, the electronic device will reclaim the first type of memory occupied by the target process. It is understandable that in actual usage scenarios, the proportion of the first type of memory occupied by the process in the whole machine memory may not be high, so the benefit of killing the target process determined based on the first type of memory usage is small. If it is not conducive to maintaining the available memory of the electronic device at a high value, the electronic device may need to frequently trigger process killing behaviors, which may easily cause the system to crash.
  • an embodiment of the present application provides a method.
  • the first type of memory and the second type of memory occupied during the running of the process are also counted. That is, the first type of memory and the second type of memory are counted. The total amount of memory occupied by the second type of memory.
  • the electronic device performs process killing, it will determine the target process based on the total occupation of the first type of memory and the second type of memory of each candidate process. Moreover, after killing the target processes, the electronic device will reclaim the first type of memory and the second type of memory occupied by these target processes.
  • the first type of memory and the second type of memory recovered through this method account for a high proportion of the entire machine memory, it is conducive to maintaining the available memory of the electronic device at a higher value and preventing the electronic device from frequently triggering process checks. Killing behavior is conducive to improving the smoothness and stability of the operation of electronic devices.
  • FIG. 3 it is a schematic flow chart of a method for checking and killing application processes provided by the embodiment of the present application.
  • the process includes:
  • the electronic device runs one or more APPs.
  • APP1 can start multiple processes, such as a foreground process and a background process.
  • the foreground process can be used to present the user interface of APP1 and interact with the user.
  • APP1 first starts a foreground process, which can launch one or more background processes.
  • the background processes do not need to interact with the user.
  • the one or more background processes may include a background service process of APP1 or a system service process of the electronic device.
  • this one or more background processes can also start other background processes again.
  • an APP may start multiple processes, and these processes will apply for corresponding memory and other system resources in the electronic device during operation.
  • an APP may only start one process, or the APP may only start one process in some scenarios and multiple processes in other scenarios.
  • the electronic device counts the first type of memory and the second type of memory occupied by each process started by the one or more APPs.
  • the electronic device can instrument each memory allocator and count the types of memory requested by each process from each memory allocator, including the first type of memory and the second type of memory.
  • instrumentation refers to inserting some probes (also called “probes") into the program on the basis of ensuring the original logical integrity of each memory allocator.
  • probes also called "probes”
  • They are essentially code segments for information collection, which can be assignments. statement or function call to collect coverage information), and through the execution of the probe, the classified memory requested by each process through each memory allocator is collected.
  • the process occupies the second Class memory can include memory allocated by streaming allocators (such as the ION memory allocator) and memory allocated by kernel allocators.
  • the memory allocated by the kernel allocator includes the memory consumption of kernel operations such as Vmalloc and Slab, PTE (Page Table Entries) memory for page table conversion, Kernel Stack for maintaining application process information, and Zram compressed data storage. memory, and shared memory (such as Shmem) for efficient communication between multiple processes.
  • monitoring can be implemented at the EGL Track interface of the streaming media allocator (such as the ION memory allocator) to count the memory allocated by the streaming media allocator to the process.
  • Monitoring can be implemented by instrumenting the kernel zsalloc memory allocation interface to count the memory occupied by Zram compressed data.
  • Monitoring can be implemented by instrumenting the kernel Shmem memory allocation interface to count the shared memory requested by the process.
  • Other allocators in the kernel such as PTE, Kernel Stack, Slab, Slab Large, Vmalloc, etc., also provide corresponding memory statistics interfaces. They can be installed at the corresponding statistics interfaces to implement monitoring to count various types of memory requested by the process. , I won’t go into details here.
  • process 1 may start another or multiple processes (such as process 2).
  • process 2 may also apply for memory, such as first-class memory, and/or second-class memory).
  • process 2 applies for the first type of memory
  • the first type of memory applied by process 2 may be counted as the memory occupied by process 2, and will not be counted as the memory occupied by process 1.
  • the memory occupied by process 2 will not be reclaimed when killing process 1. It is understandable that the memory requested by process 2 is to support the operation of process 1.
  • process 1 If process 1 is killed, the memory requested by process 2 will have no effect, which causes a waste of memory. Or, if process 2 applies for the second type of memory, the existing technology cannot count the second type of memory applied by process 2, which will still cause the problem of low profits after the process is killed.
  • the electronic device when counting the memory of each process, the electronic device will calculate the memory applied for by each process based on the linkage relationship between the processes (also known as the pull-up relationship, calling relationship, etc.) Assigned to the source process.
  • the linkage relationship between the processes also known as the pull-up relationship, calling relationship, etc.
  • the subsequent electronic device selects the target process to be checked and killed, it can accurately determine the target process that occupies the largest amount of the first type of memory and the second type of memory of the system, and can recover more when checking and killing the target process.
  • the first type of memory and the second type of memory thereby increasing the benefits of process killing and improving the smoothness and stability of the system.
  • the linkage relationship between processes requires inter-process communication services in the system (such as Binder, Socket, and Signal)
  • electronic devices can collect statistics on each process by monitoring the inter-process communication services.
  • Linkage relationship In some examples, the electronic device can maintain a linked list of linkage relationships between processes ( Figure 4 shows an example of a linked list of linkage relationships between processes) to collect statistics on linkage relationships between different processes.
  • the electronic equipment can be counted using methods such as red-black trees or hash tables. Then, based on the linkage relationship of each process, the memory requested by each process is finally counted to the source process.
  • the source process refers to the first caller. For example, process 1 calls process 2, and process 2 calls process 3. Then, the source process of process 2 and process 3 is process 1.
  • APP1 is taken as an example to illustrate the linkage relationship between processes of APP1 and the method of counting memory.
  • the main process of APP1 (such as the foreground process) will be started.
  • the main process of APP1 may call the background services of the framework layer, and/or the system library and runtime layer (each service will correspond to a process).
  • the main process calls audio and video services, and the audio and video services pass the graphical allocator (Graghic Allocator). ) applies for streaming media memory (such as ION memory).
  • the electronic device establishes the main process of APP1 (or APP1)
  • the linkage relationship with the audio and video service counts the memory requested by the audio and video service to the main process of APP1 (or APP1).
  • the image rendering service applies for streaming media memory (such as ION memory) through the graphics allocator (Graghic Allocator).
  • the electronic device establishes a linkage relationship between the main process of APP1 (or APP1) and the image rendering service, and counts the memory requested by the image rendering service to the main process of APP1 (or APP1).
  • the APP1 main process may also call the kernel layer's memory management service to compress the user-mode anonymous page data and apply for memory to store the compressed data (for example, to store Zram compression data memory). Then, the electronic device can count the memory applied for this time by the memory management service to the APP1 main process (or APP1).
  • the APP1 main process may also call the inter-process communication (such as Binder) module of the kernel layer to apply for shared memory (such as Ashmem). Then, the electronic device counts the shared memory applied for this time by the inter-process communication module to the main process of APP1 (or APP1).
  • the inter-process communication such as Binder
  • shared memory such as Ashmem
  • the main process of APP1 calls the memory business module of the kernel layer to apply for other kernel memory (such as page table PT, Stack, Slab, Vmalloc). Then, the electronic device counts the various kernel memories applied for this time by the memory business module to the main process of APP1 (or APP1).
  • kernel memory such as page table PT, Stack, Slab, Vmalloc
  • the electronic device determines the target process from the processes started by the one or more APPs.
  • the memory of the electronic device meets the preset conditions, which is the trigger condition for the electronic device to execute process killing.
  • the memory of the electronic device that meets the preset conditions includes: the remaining memory amount of the electronic device is less than or equal to the threshold 1; or the blocking duration of the process in the electronic device due to untimely memory allocation is greater than or equal to the threshold 2; or the electronic device The total occupancy of the second type of memory is greater than or equal to any of threshold 3.
  • the electronic device may use a waterline triggering mechanism based on the amount of remaining memory to kill processes. Specifically, the electronic device can monitor the amount of remaining memory of the electronic device, where the remaining memory refers to available memory, which can include free memory in the system, as well as memory occupied by file pages, core library files, and cached data. When it is detected that the remaining memory amount is less than or equal to the threshold 1, the electronic device starts the process killing process.
  • the electronic device can determine the target process for checking and killing by combining the usage frequency of the process and the amount of memory occupied by the process. For example, when the electronic device starts the killing process, the electronic device first uses, for example, the LRU algorithm to filter out processes that are not frequently used as candidate processes, and then selects the candidate process with a larger memory footprint based on the memory usage of each candidate process. As the target process, then kill the target process to release the memory occupied by the target process.
  • each candidate process includes the first type of memory usage and the second type of memory usage. That is to say, the electronic device is based on the first type of memory and the second type of memory occupied by each candidate process. The total usage is used to determine the target process.
  • the memory usage of each candidate process may also include the memory requested by other processes called by each candidate process (also including the first type of memory and Type II memory).
  • the electronic device can also be configured according to the target process and the electronic device maintenance Use the linkage relationship between different processes protected to determine other processes called by the target process, and determine that these other processes are also processes that need to be killed, that is, they are also target processes. It is understandable that after the target process is checked and killed, if other processes called by the target process are only called by the target process, then these other processes can also be checked and killed, and the memory occupied by these other processes can also be recycled. This will help further improve memory utilization and improve the system's operating speed. Of course, if other processes called by the target process are also called by other non-target processes, these other processes cannot be killed to ensure the normal operation of other non-target processes.
  • the main process of APP1 is determined to be the target process, in addition to killing the main process of APP1 and reclaiming the memory requested by the main process of APP1, if the audio and video services and image rendering services called by APP1 have not been If the process calls of other applications, it can also be determined that the audio and video service and image rendering service are also target processes. Then, the electronic device also kills the audio and video services and image rendering services, and recovers the streaming media memory (such as ION memory) occupied by the audio and video services and image rendering services. It is understandable that streaming media usually takes up a large amount of memory. Then, the audio and video killing service and image rendering service will recycle this part of the streaming media memory, which is more conducive to increasing the benefits of process killing and maintaining the stability and smoothness of system operation.
  • the audio and video killing service and image rendering service will recycle this part of the streaming media memory, which is more conducive to increasing the benefits of process killing and maintaining the stability and smoothness of system operation.
  • the electronic device may also use a triggering mechanism based on Pressure Stall Information (PSI) to kill the process.
  • PSI Pressure Stall Information
  • the electronic device can monitor the blocking time caused by untimely memory allocation when each process on the electronic device is running, that is, the time the process waits for memory allocation. When it is detected that the blocking time of the process is greater than or equal to the threshold 2, the process killing process is started.
  • PSI Pressure Stall Information
  • the electronic device can also use a waterline triggering mechanism based on the second type of memory usage to kill the process. Specifically, the electronic device can monitor the total occupied amount of the second type of memory in the electronic device. When it is detected that the total occupied amount of the second type of memory is greater than or equal to the threshold 3, the electronic device starts the process killing process. It should be noted that the difference between this embodiment and the above-mentioned embodiment is that the triggering conditions for initiating the process checking and killing process are different. The specific method of executing process checking and killing by the electronic device is the same as that in the above-mentioned embodiment, and will not be described again here.
  • this embodiment provides a method for monitoring the memory usage of an electronic device from the perspective of monitoring the second type of memory usage.
  • the second type of memory occupancy is usually large, which is one of the main reasons for the memory shortage of electronic devices. Therefore, the startup process killing process is determined from the perspective of monitoring the second type of memory occupancy. Being able to more accurately monitor the memory usage of electronic devices is more conducive to fundamentally solving the problems of high memory pressure and slow system operation caused by high second-type memory usage of electronic devices.
  • this embodiment realizes the function of recycling the second type of memory, it effectively reduces the occupation of the second type of memory, which helps the system's available memory to stay at a higher threshold for a long time, ensuring the stability and smoothness of the system operation. .
  • the electronic device may simultaneously adopt a watermark triggering mechanism based on the amount of remaining memory and a watermark triggering mechanism based on the second type of memory usage.
  • the process of killing the process is started.
  • the process checking and killing method here may adopt existing technology, or may adopt the process checking and killing method provided by the embodiments of this application.
  • the process of killing the process is also started.
  • the electronic device since the electronic device adopts a trigger mechanism based on the second-type memory usage waterline, and the electronic device recycles more second-class memory when executing the scanning and killing process of the process, it is conducive to the remaining memory of the electronic device. Inside If the inventory is at a high threshold for a long time, it also reduces the frequency of process killing triggered by electronic devices using a trigger mechanism based on the remaining memory waterline of the electronic device, and reduces the system consumption of electronic devices executing the process killing process. Resources, such as CPU resources, memory resources, etc.
  • the electronic device scans and kills the determined target process, and reclaims the first type of memory and the second type of memory occupied by the target process. More specifically, after the kernel layer of the electronic device kills the target process, it notifies the upper layer that the target process has been killed. After receiving the notification information, the framework layer further cleans up the components associated with the target process and further releases the memory occupied by the components.
  • the first type of memory and the second type of memory recovered through this method account for a high proportion of the entire machine's memory, it is conducive to maintaining the available memory of the electronic device at a higher value, which is conducive to improving the operation of the electronic device. fluency and stability.
  • the process checking and killing method provided by the embodiment of the present application has greater benefits, it is conducive to maintaining the available memory of the electronic device at a higher value, reducing the frequency of the electronic device executing the process checking and killing process, and reducing the cost of the process.
  • the system resources consumed by electronic devices when executing process killing processes such as CPU resources, memory resources, etc.
  • some processes with higher priority or system level may be determined as the target process.
  • the key components in the target process are identified (that is, the information in the key components affects the stability of the system or the user experience) , and preserve key components in the target process. Later, when the target process is restarted (or the APP corresponding to the target process is restarted), the retained key components can be directly used to restore the target process to ensure the stability of the system operation or the user experience.
  • FIG. 6 it is a schematic flowchart of another method for detecting and killing an application process provided by an embodiment of the present application.
  • the process includes:
  • step S601. Monitor whether the occupancy of the second type of memory of the electronic device is greater than or equal to threshold 3. If it is detected that the occupancy of the second type of memory of the electronic device is greater than or equal to threshold 3, step S602 is executed.
  • the occupancy of the second type of memory of the electronic device is greater than or equal to the threshold 3 as the trigger condition for the electronic device to execute process killing.
  • the electronic device may also adopt Other triggering conditions will not be described here.
  • the kernel layer (for example, more specifically, the memory statistics module of the kernel layer) monitors whether the occupation amount of the second type of memory of the electronic device is greater than or equal to the threshold 3.
  • the memory usage of each process includes the total usage of the first type of memory and the second type of memory.
  • the electronic device may also start to count the memory usage of each process in real time while executing step S601 or before executing step S601.
  • the kernel layer (for example, more specifically, the memory statistics module of the kernel layer) is used to count the memory usage of each process.
  • step S302 For other contents of this step, please refer to the relevant contents in the above-mentioned step S302, which will not be described again here.
  • the electronic device may determine the target process for scanning and killing by combining the usage frequency of the process and the amount of memory occupied by the process.
  • the kernel layer for example, more specifically, the inner layer of the kernel layer The memory statistics module
  • the kernel layer is used to select the target process based on the statistical memory usage of each process.
  • the kernel layer (for example, more specifically, the process killing module of the kernel layer) is used to kill the target process.
  • step S605. Determine whether the component associated with the target process is a critical component. If it is a key component, perform step S606. If it is not a critical component, perform step S607.
  • key components refer to components that contain key information.
  • the key information includes information that will affect the stability of the system when the target process is running, or affect the user experience. It is understandable that some temporary data while the target process is running will be stored in the component. If you clean up the components associated with the target process directly after killing the target process, this part of the temporary data will be lost. If the temporary data contains critical information, it will inevitably affect the restart of the target process, the stability of the target process, or the user experience.
  • key components may include information about some permanent functions when the system is running, such as information about the electronic device's negative screen, magazine lock screen information, information displayed on the active screen, weather widget information, etc.
  • the key component may include the reading progress information of the electronic document, and the reading progress information of the electronic document will affect the user's experience when reading the electronic document.
  • the electronic device cleans the components associated with the target process, it will first determine whether the components associated with the target process contain key components. For key components, retain the information of the key components, or retain the key information in the key components, that is, perform step S606. For non-critical components, clean up non-associated components, that is, perform step S607.
  • the kernel layer for example, the process killing module of the kernel layer kills the target process
  • the framework layer (for example, more specifically, the component cleaning module of the framework layer) determines whether the components associated with the target process are critical components, and further retains the critical components and cleans the non-critical components.
  • the electronic device can also modify the life cycle of key components to retain information about key components.
  • the information of key components associated with the target process is retained, so that the electronic device can subsequently restore the information of key components, maintain the stability of system operation, and provide user experience.
  • FIG. 7 it is a schematic flowchart of a method for restoring a target process provided by an embodiment of the present application.
  • the process includes:
  • the main process of the APP can call components in the framework layer to implement corresponding functions.
  • the APP does not exit, and the APP's main process (or other processes, such as other processes called by the main process) needs to call the components in the framework layer again to implement the corresponding functions.
  • step S702 Determine whether the called component is a recoverable key component. If yes, execute step S703; if not, execute step S706.
  • the main process of the APP can query the component records to determine whether the component to be called is a recoverable key component. That is, whether the electronic device saves information about the component to be called. If it is determined that the component to be called is a recoverable key component, the component can be recovered using the information of the key component retained by the electronic device, that is, steps S703 to S705 are performed. If it is determined that the component to be called is not a recoverable critical component, the system's native process is adopted, that is, steps S706 to S709 are executed.
  • the electronic device Since the component needs to rely on a process to run, the electronic device creates a new process for running the component.
  • step S706 Determine whether a component needs to be created. If not, execute step S707. If so, execute step S708,
  • step S707 For example, before calling, query whether the electronic device runs the component. If the electronic device does not run the component, the component needs to be created, that is, step S707 is performed. If the electronic device runs the component, there is no need to create the component again, and step S708 is executed.
  • step S707. Determine whether a new process needs to be created. If so, execute step S703.
  • step S709. Determine whether there is an existing process that can take over the created component. If yes, execute step S704. If not, execute step S703.
  • the chip system includes at least one processor 1101 and at least one interface circuit 1102 .
  • the processor 1101 and the interface circuit 1102 may be interconnected by wires.
  • interface circuitry 1102 may be used to receive signals from other devices, such as the memory of electronic device 100 .
  • interface circuit 1102 may be used to send signals to other devices (eg, processor 1101).
  • the interface circuit 1102 can read instructions stored in the memory and send the instructions to the processor 1101.
  • the electronic device can be caused to perform various steps performed by the electronic device 100 (such as a mobile phone) in the above embodiments.
  • the chip system may also include other discrete devices, which are not specifically limited in the embodiments of this application.
  • An embodiment of the present application also provides a device, which is included in an electronic device and has the function of realizing the behavior of the electronic device in any of the methods in the above embodiments.
  • This function can be implemented by hardware, or it can be implemented by hardware executing corresponding software.
  • the hardware or software includes at least one module or unit corresponding to the above functions. For example, detection module or unit, statistical module or unit, determination module or unit, and killing module or unit, etc.
  • Embodiments of the present application also provide a computer storage medium that includes computer instructions.
  • the computer instructions When the computer instructions are run on an electronic device, the electronic device causes the electronic device to perform any of the methods in the above embodiments.
  • Embodiments of the present application also provide a computer program product.
  • the computer program product When the computer program product is run on a computer, it causes the computer to perform any of the methods in the above embodiments.
  • the above-mentioned electronic devices include hardware structures and/or software modules corresponding to each function.
  • Persons skilled in the art should easily realize that, in conjunction with the units and algorithm steps of each example described in the embodiments disclosed herein, the embodiments of the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a certain function is executed by hardware or by computer software driving the hardware? Depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementations should not be considered to be beyond the scope of the embodiments of the present invention.
  • Embodiments of the present application can divide the above-mentioned electronic equipment into functional modules according to the above-mentioned method examples.
  • each functional module can be divided corresponding to each function, or two or more functions can be integrated into one processing module.
  • the above integrated modules can be implemented in the form of hardware or software function modules. It should be noted that the division of modules in the embodiment of the present invention is schematic and is only a logical function division. In actual implementation, there may be other division methods.
  • Each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically alone, or two or more units may be integrated into one unit.
  • the above integrated units can be implemented in the form of hardware or software functional units.
  • the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it may be stored in a computer-readable storage medium.
  • the technical solutions of the embodiments of the present application are essentially or contribute to the existing technology, or all or part of the technical solution can be embodied in the form of a software product.
  • the computer software product is stored in a storage device.
  • the medium includes several instructions to cause a computer device (which may be a personal computer, a server, or a network device, etc.) or a processor to execute all or part of the steps of the methods described in various embodiments of this application.
  • the aforementioned storage media include: flash memory, mobile hard disk, read-only memory, random access memory, magnetic disk or optical disk and other media that can store program codes.

Abstract

A process killing method for an application, and an electronic device, relating to the field of operating systems and being capable of preventing an electronic device from frequently triggering a process killing operation and facilitating the improvement of the running fluency and stability of an electronic device. The method comprises: an electronic device calculating statistics on a first-type memory and a second-type memory occupied by running processes, wherein the first-type memory comprises one or more of a file page occupied memory, a core-library file occupied memory, a cache data occupied memory, and a user-mode anonymous page occupied memory, and the second-type memory comprises one or more of streaming media occupied memory and a kernel occupied memory; and if it is detected that a memory of the electronic device meets a preset condition, determining a target process from the running processes according to the first-type memory and the second-type memory occupied by the processes, and killing the target process.

Description

一种应用程序的进程查杀方法及电子设备Process checking and killing method of application program and electronic device
本申请要求于2022年4月1日提交国家知识产权局、申请号为202210339419.4、申请名称为“一种应用程序的进程查杀方法及电子设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application requires the priority of the Chinese patent application submitted to the State Intellectual Property Office on April 1, 2022, with the application number 202210339419.4 and the application title "A method for killing application processes and electronic equipment", and its entire content has been approved This reference is incorporated into this application.
技术领域Technical field
本申请涉及操作系统领域,尤其涉及一种应用程序的进程查杀方法及电子设备。The present application relates to the field of operating systems, and in particular, to an application process checking and killing method and an electronic device.
背景技术Background technique
当内存资源紧张时,电子设备可以采用进程查杀的方式来清理进程占用的内存。以交互式操作系统(例如Android系统)为例,电子设备通常会根据用户的使用习惯,清理不常用或短期内不会使用的进程占用的内存。然而,在实际的使用场景中,每次进程查杀后释放的内存在整机内存中占比并不高,那么电子设备需要频繁地触发进程查杀行为,易造成系统崩溃。When memory resources are tight, electronic devices can use process scanning and killing methods to clean up the memory occupied by processes. Taking interactive operating systems (such as Android systems) as an example, electronic devices usually clean up the memory occupied by processes that are not commonly used or will not be used in the short term based on the user's usage habits. However, in actual usage scenarios, the memory released after each process killing does not account for a high proportion of the entire machine's memory. Therefore, electronic devices need to frequently trigger process killing behaviors, which can easily cause system crashes.
发明内容Contents of the invention
本申请提供的一种应用程序的进程查杀方法及电子设备,可以避免电子设备频繁地触发进程查杀行为,有利于提升电子设备运行的流畅度和稳定性。This application provides a process checking and killing method for an application program and an electronic device, which can prevent electronic devices from frequently triggering process checking and killing behaviors, and is conducive to improving the smoothness and stability of the operation of electronic devices.
为了实现上述目的,本申请实施例提供了以下技术方案:In order to achieve the above objectives, the embodiments of the present application provide the following technical solutions:
第一方面、提供一种应用程序的进程查杀方法,该方法包括:电子设备运行一个或多个应用APP;电子设备统计一个或多个APP启动的各个进程占用的第一类内存和第二类内存,其中第一类内存包括文件页占用内存,核心库文件占用内存,缓存数据占用内存,以及用户态匿名页占用内存中一项或多项;第二类内存包括流媒体占用内存以及内核占用内存中一项或多项;当检测到电子设备的内存满足预设条件时,电子设备根据各个进程占用的第一类内存和第二类内存,从一个或多个APP启动的进程中确定目标进程;电子设备查杀目标进程。The first aspect provides a process checking and killing method for application programs. The method includes: an electronic device runs one or more application APPs; the electronic device counts the first type of memory and the second type of memory occupied by each process started by one or more APPs. Class memory, the first class of memory includes one or more of the memory occupied by file pages, core library files, cached data, and user-mode anonymous pages; the second class of memory includes the memory occupied by streaming media and the kernel Occupying one or more items in the memory; when it is detected that the memory of the electronic device meets the preset conditions, the electronic device determines from the processes started by one or more APPs based on the first type of memory and the second type of memory occupied by each process. Target process; electronic device killing target process.
也就是说,在统计进程运行过程中占用的内存时,一并统计进程运行过程中占用的第一类内存和第二类内存,即统计第一类内存和第二类内存的总占用量。那么,电子设备在执行进程查杀时,会根据各个候选进程的第一类内存和第二类内存的总占用量来确定目标进程。并且,电子设备在杀死目标进程后,会回收这些目标进程占用的第一类内存和第二类内存。由于通过该方法回收的第一类内存和第二类内存在整机内存的占比较高,有利于使得电子设备的可用内存维持在一个较高的数值上,能够避免电子设备频繁地触发进程查杀行为,有利于提升电子设备运行的流畅度和稳定性。That is to say, when counting the memory occupied during the running of the process, the first type of memory and the second type of memory occupied during the running of the process are also counted, that is, the total occupation of the first type of memory and the second type of memory is counted. Then, when the electronic device performs process killing, it will determine the target process based on the total occupation of the first type of memory and the second type of memory of each candidate process. Moreover, after killing the target processes, the electronic device will reclaim the first type of memory and the second type of memory occupied by these target processes. Since the first type of memory and the second type of memory recovered through this method account for a high proportion of the entire machine memory, it is conducive to maintaining the available memory of the electronic device at a higher value and preventing the electronic device from frequently triggering process checks. Killing behavior is conducive to improving the smoothness and stability of the operation of electronic devices.
在一种可能的实现方式中,电子设备的内存满足预设条件包括:电子设备的剩余内存量小于或等于第一阈值,电子设备中因内存分配不及时造成进程的阻塞时长大于或等于第二阈值,电子设备中第二类内存的总占用量大于或等于第三阈值中的任一项。In a possible implementation, the memory of the electronic device meeting the preset conditions includes: the remaining memory amount of the electronic device is less than or equal to the first threshold, and the blocking duration of the process in the electronic device due to untimely memory allocation is greater than or equal to the second threshold. Threshold, the total occupied amount of the second type of memory in the electronic device is greater than or equal to any of the third thresholds.
在一些实施例中,电子设备可以采用基于剩余内存量的水线触发机制来查杀进程。具体的,电子设备可以监测电子设备的剩余内存量,其中剩余内存是指可用内存,可以包括系统中空闲的内存,以及文件页、核心库文件和缓存数据占用的内存。当监测 到剩余内存量小于或等于阈值1时,电子设备启动进程查杀流程。In some embodiments, the electronic device may use a waterline triggering mechanism based on the amount of remaining memory to kill processes. Specifically, the electronic device can monitor the amount of remaining memory of the electronic device, where the remaining memory refers to available memory, which can include free memory in the system, as well as memory occupied by file pages, core library files, and cached data. when monitoring When the amount of remaining memory is less than or equal to the threshold 1, the electronic device starts the process killing process.
在另一些实施例中,电子设备也可以采用基于压力阻塞信息(Pressure Stall Information,PSI)的触发机制来查杀进程。具体的,电子设备可以监测电子设备上各个进程运行时因内存分配不及时造成的阻塞时长,即进程等待分配内存的时长。当监测到进程的阻塞时长大于或等于阈值2时,启动进程查杀流程。In other embodiments, the electronic device may also use a triggering mechanism based on Pressure Stall Information (PSI) to kill the process. Specifically, the electronic device can monitor the blocking time caused by untimely memory allocation when each process on the electronic device is running, that is, the time the process waits for memory allocation. When it is detected that the blocking time of the process is greater than or equal to the threshold 2, the process killing process is started.
在又一些实施例中,电子设备还可以采用基于第二类内存占用量的水线触发机制来查杀进程。具体的,电子设备可以监测电子设备中第二类内存的总占用量。当监测到第二类内存的总占用量大于或等于阈值3时,电子设备启动进程查杀流程。In some embodiments, the electronic device can also use a waterline triggering mechanism based on the second type of memory usage to kill the process. Specifically, the electronic device can monitor the total occupied amount of the second type of memory in the electronic device. When it is detected that the total occupied amount of the second type of memory is greater than or equal to the threshold 3, the electronic device starts the process killing process.
需要说明的是,该实施例提供了一种从监测第二类内存占用量的角度监测电子设备的内存占用情况的方法。在电子设备真实的使用过程中,第二类内存占用量通常较大,是造成电子设备内存紧张的主要原因之一,因此,从监测第二类内存占用量的角度确定启动进程查杀流程,能够更准确地监测电子设备的内存占用情况,更有利于从根本上解决电子设备因第二类内存占用量高造成内存压力大、系统运行缓慢等的问题。另外,由于本实施例实现了回收第二类内存的功能,有效地减少了第二类内存的占用量,有利于系统的可用内存长时间处于一个较高的阈值,保证系统运行稳定和流畅性。It should be noted that this embodiment provides a method of monitoring the memory occupancy of an electronic device from the perspective of monitoring the second type of memory occupancy. In the actual use of electronic devices, the second type of memory occupancy is usually large, which is one of the main reasons for the memory shortage of electronic devices. Therefore, the startup process killing process is determined from the perspective of monitoring the second type of memory occupancy. Being able to more accurately monitor the memory usage of electronic devices is more conducive to fundamentally solving the problems of high memory pressure and slow system operation caused by high second-type memory usage of electronic devices. In addition, since this embodiment realizes the function of recycling the second type of memory, it effectively reduces the occupation of the second type of memory, which helps the system's available memory to stay at a higher threshold for a long time, ensuring the stability and smoothness of the system operation. .
在一种可能的实现方式中,第一进程占用的第一类内存和第二类内存包括第一进程所调用的第二进程占用的第一类内存和/或第二类内存,第一进程为一个或多个APP启动的进程中的任一个,且第二进程不被除第一进程之外的其他进程所调用。电子设备根据各个进程占用的第一类内存和第二类内存,从一个或多个APP启动的进程中确定目标进程,包括:电子设备确定第一进程为目标进程后,确定第二进程也为目标进程。In a possible implementation, the first type of memory and the second type of memory occupied by the first process include the first type of memory and/or the second type of memory occupied by the second process called by the first process. Any one of the processes started for one or more APPs, and the second process is not called by other processes except the first process. The electronic device determines the target process from the processes started by one or more APPs based on the first type of memory and the second type of memory occupied by each process, including: after the electronic device determines that the first process is the target process, it determines that the second process is also target process.
示例性的,电子设备运行的多个进程之间存在联动关联的场景中,电子设备还可以根据目标进程,以及电子设备维护的不同进程间的联动关系来确定目标进程调用的其他进程,并确定这些其他进程也为需要查杀的进程,即也为目标进程。可以理解的是,当目标进程(例如第一进程)被查杀后,如果目标进程调用的其他进程(如第二进程)仅被目标进程所调用,那么这些其他进程也可以被查杀,这些其他进程占用的内存也可以被回收。这样,有利于进一步提升内存的利用率,提升系统的运行速率。当然,如果目标进程调用的其他进程还被其他非目标进程调用,则这些其他进程不能被查杀,以保证其他非目标进程的正常运行。For example, in a scenario where there are linkages between multiple processes running on an electronic device, the electronic device can also determine other processes called by the target process based on the target process and the linkage relationships between different processes maintained by the electronic device, and determine These other processes are also processes that need to be killed, that is, they are also target processes. It can be understood that after the target process (for example, the first process) is checked and killed, if other processes (such as the second process) called by the target process are only called by the target process, then these other processes can also be checked and killed. Memory occupied by other processes can also be reclaimed. This will help further improve memory utilization and improve the system's operating speed. Of course, if other processes called by the target process are also called by other non-target processes, these other processes cannot be killed to ensure the normal operation of other non-target processes.
在一种可能的实现方式中,在电子设备查杀目标进程之后,该方法还包括:电子设备确定目标进程关联的第一组件是否为关键组件;其中关键组件为包含关键信息的组件,关键信息包括目标进程运行时会影响系统运行稳定性或者影响到用户的使用体验的信息;若确定第一组件为关键组件,则电子设备保留第一组件的信息;若确定第一组件不为关键组件,则电子设备清理第一组件的信息。In a possible implementation, after the electronic device kills the target process, the method further includes: the electronic device determines whether the first component associated with the target process is a key component; where the key component is a component containing key information, and the key information Including information that will affect the stability of the system operation or the user experience when the target process is running; if it is determined that the first component is a critical component, the electronic device retains the information of the first component; if it is determined that the first component is not a critical component, The electronic device then clears the information of the first component.
考虑到在选择目标进程时,可能将一些优先级较高或系统级的进程确定为目标进程。为了保证系统运行的稳定性,或者保证用户的使用体验,在查杀目标进程的过程中,识别目标进程中的关键组件(即关键组件中的信息影响系统的稳定性或者影响用户的使用体验),并保留目标进程中的关键组件。后续在重新启动目标进程(或者重启目标进程对应的APP)时,可以直接利用保留的关键组件恢复目标进程,保证系统 运行的稳定性或者保证用户的使用体验。Consider that when selecting a target process, some processes with higher priority or system level may be determined as target processes. In order to ensure the stability of the system operation or ensure the user experience, during the process of killing the target process, the key components in the target process are identified (that is, the information in the key components affects the stability of the system or the user experience) , and preserve key components in the target process. Later, when restarting the target process (or restarting the APP corresponding to the target process), you can directly use the retained key components to restore the target process to ensure that the system Operation stability or ensuring user experience.
在一种可能的实现方式中,关键信息包括负一屏的信息,杂志锁屏的信息,息屏显示的信息,天气widget的信息,电子文档的阅读进度信息中一项或多项。In a possible implementation manner, the key information includes one or more of the information on the negative screen, the information on the magazine lock screen, the information displayed on the active screen, the information on the weather widget, and the reading progress information of the electronic document.
在一种可能的实现方式中,在电子设备查杀目标进程后,在电子设备保留第一组件的信息之后,该方法还包括:电子设备调用第一组件;当查询到电子设备保留有第一组件的信息后,电子设备启动第三进程;电子设备根据保留的第一组件的信息,建立第三进程和第一组件关联关系。In a possible implementation, after the electronic device kills the target process and after the electronic device retains the information of the first component, the method further includes: the electronic device calls the first component; when it is queried that the electronic device retains the first component After receiving the information of the component, the electronic device starts the third process; the electronic device establishes an association between the third process and the first component based on the retained information of the first component.
第二方面、提供一种电子设备,包括:处理器和存储器,所述存储器与所述处理器耦合,所述存储器用于存储计算机程序代码,所述计算机程序代码包括计算机指令,所述处理器从所述存储器中读取所述计算机指令,以使得电子设备执行如上述方面及其中任一种可能的实现方式中所述的方法。In a second aspect, an electronic device is provided, including: a processor and a memory, the memory is coupled to the processor, the memory is used to store computer program code, the computer program code includes computer instructions, the processor The computer instructions are read from the memory, so that the electronic device performs the method described in the above aspect and any possible implementation manner therein.
第三方面、提供一种装置,该装置包含在电子设备中,该装置具有实现上述方面及可能的实现方式中任一方法中电子设备行为的功能。该功能可以通过硬件实现,也可以通过硬件执行相应的软件实现。硬件或软件包括至少一个与上述功能相对应的模块或单元。例如,检测模块或单元、统计模块或单元、确定模块或单元、以及查杀模块或单元等。A third aspect is to provide a device, which is included in an electronic device and has the function of realizing the behavior of the electronic device in any of the above aspects and possible implementation methods. This function can be implemented by hardware, or it can be implemented by hardware executing corresponding software. The hardware or software includes at least one module or unit corresponding to the above functions. For example, detection module or unit, statistical module or unit, determination module or unit, and killing module or unit, etc.
第四方面、提供一种计算机可读存储介质,该计算机可读存储介质包括计算机指令,当计算机指令在电子设备上运行时,使得电子设备执行如上述方面及其中任一种可能的实现方式中所述的方法。The fourth aspect is to provide a computer-readable storage medium. The computer-readable storage medium includes computer instructions. When the computer instructions are run on an electronic device, the electronic device causes the electronic device to perform the above aspects and any possible implementation manner thereof. the method described.
第五方面、提供一种芯片系统,包括处理器,当处理器执行指令时,处理器执行如上述方面中及其中任一种可能的实现方式中所述的方法。A fifth aspect provides a chip system, including a processor. When the processor executes instructions, the processor executes the method described in the above aspects and any of the possible implementations.
第六方面、提供一种计算机程序产品,当计算机程序产品在计算机上运行时,使得计算机执行如上述方面中及其中任一种可能的实现方式中所述的方法。In a sixth aspect, a computer program product is provided. When the computer program product is run on a computer, it causes the computer to execute the method described in the above aspects and any of the possible implementations.
上述第二方面提供的电子设备、第三方面提供的装置、第四方面提供的计算机可读存储介质、第五方面提供的芯片系统、以及第六方面提供的计算机程序产品所能达到的技术效果,可以参考上述第一方面以及第一方面中可能的实现方式中有关技术效果的描述,这里不再赘述。The technical effects achieved by the electronic equipment provided by the second aspect, the device provided by the third aspect, the computer-readable storage medium provided by the fourth aspect, the chip system provided by the fifth aspect, and the computer program product provided by the sixth aspect , reference may be made to the description of technical effects in the above first aspect and possible implementations in the first aspect, which will not be described again here.
附图说明Description of drawings
图1为本申请实施例提供的一种电子设备的硬件结构示意图;Figure 1 is a schematic diagram of the hardware structure of an electronic device provided by an embodiment of the present application;
图2A为本申请实施例提供的一种电子设备的软件结构示意图;Figure 2A is a schematic diagram of the software structure of an electronic device provided by an embodiment of the present application;
图2B为本申请实施例提供的一种应用程序的进程占用内存的示意图;Figure 2B is a schematic diagram of memory occupied by a process of an application provided by an embodiment of the present application;
图3为本申请实施例提供的一种应用程序的进程查杀方法的流程示意图;Figure 3 is a schematic flowchart of an application process checking and killing method provided by an embodiment of the present application;
图4为本申请实施例提供的一种进程关联关系的示意图;Figure 4 is a schematic diagram of a process association provided by an embodiment of the present application;
图5为本申请实施例提供的一种进程内存占用量的统计方法的示意图;Figure 5 is a schematic diagram of a statistical method for process memory usage provided by an embodiment of the present application;
图6为本申请实施例提供的另一种应用程序的进程查杀方法的流程示意图;Figure 6 is a schematic flowchart of another application process checking and killing method provided by an embodiment of the present application;
图7为本申请实施例提供的一种应用程序中关键组件的恢复方法的流程示意图;Figure 7 is a schematic flowchart of a method for recovering key components in an application provided by an embodiment of the present application;
图8为本申请实施例提供的一种芯片系统的结构示意图。FIG. 8 is a schematic structural diagram of a chip system provided by an embodiment of the present application.
具体实施方式Detailed ways
在本申请实施例的描述中,除非另有说明,“/”表示或的意思,例如,A/B可以表 示A或B;本文中的“和/或”仅仅是一种描述关联对象的联动关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B这三种情况。In the description of the embodiments of this application, unless otherwise stated, "/" means or, for example, A/B can mean means A or B; the "and/or" in this article is just a linkage relationship describing related objects, indicating that there can be three relationships, for example, A and/or B, which can mean: A alone exists, and A and A exist simultaneously. B, there are three situations of B alone.
以下,术语“第一”、“第二”仅用于描述目的,而不能理解为指示或暗示相对重要性或者隐含指明所指示的技术特征的数量。由此,限定有“第一”、“第二”的特征可以明示或者隐含地包括一个或者更多个该特征。在本申请实施例的描述中,除非另有说明,“多个”的含义是两个或两个以上。Hereinafter, the terms “first” and “second” are used for descriptive purposes only and cannot be understood as indicating or implying relative importance or implicitly indicating the quantity of indicated technical features. Therefore, features defined as "first" and "second" may explicitly or implicitly include one or more of these features. In the description of the embodiments of this application, unless otherwise specified, "plurality" means two or more.
在本申请实施例中,“示例性的”或者“例如”等词用于表示作例子、例证或说明。本申请实施例中被描述为“示例性的”或者“例如”的任何实施例或设计方案不应被解释为比其它实施例或设计方案更优选或更具优势。确切而言,使用“示例性的”或者“例如”等词旨在以具体方式呈现相关概念。In the embodiments of this application, words such as "exemplary" or "for example" are used to represent examples, illustrations or explanations. Any embodiment or design described as "exemplary" or "such as" in the embodiments of the present application is not to be construed as preferred or advantageous over other embodiments or designs. Rather, use of the words "exemplary" or "such as" is intended to present the concept in a concrete manner.
本申请实施例提供一种应用程序(application,APP)的进程查杀方法,可应用于安装有一个或多个APP的电子设备。示例性的,本申请实施例中电子设备例如可以为手机、平板电脑、个人计算机(personal computer,PC)、个人数字助理(personal digital assistant,PDA)、智能手表、上网本、可穿戴电子设备、增强现实技术(augmented reality,AR)设备、虚拟现实(virtual reality,VR)设备、车载设备、智慧屏、智能汽车、智能音响、机器人等,本申请对该电子设备的具体形式不做特殊限制。Embodiments of the present application provide a process checking and killing method for an application (application, APP), which can be applied to an electronic device installed with one or more APPs. Illustratively, the electronic device in the embodiment of the present application may be a mobile phone, a tablet computer, a personal computer (PC), a personal digital assistant (PDA), a smart watch, a netbook, a wearable electronic device, an enhanced Reality technology (augmented reality, AR) equipment, virtual reality (VR) equipment, vehicle-mounted equipment, smart screens, smart cars, smart speakers, robots, etc. This application does not place special restrictions on the specific forms of this electronic equipment.
图1示出了电子设备100的结构示意图。FIG. 1 shows a schematic structural diagram of an electronic device 100 .
电子设备100可以包括处理器110,外部存储器接口120,内部存储器121,通用串行总线(universal serial bus,USB)接口130,充电管理模块140,电源管理模块141,电池142,天线1,天线2,移动通信模块150,无线通信模块160,音频模块170,扬声器170A,受话器170B,麦克风170C,耳机接口170D,传感器模块180,按键190,马达191,指示器192,摄像头193,显示屏194,以及用户标识模块(subscriber identification module,SIM)卡接口195等。其中传感器模块180可以包括压力传感器180A,陀螺仪传感器180B,气压传感器180C,磁传感器180D,加速度传感器180E,距离传感器180F,接近光传感器180G,指纹传感器180H,温度传感器180J,触摸传感器180K,环境光传感器180L,骨传导传感器180M等。The electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2 , mobile communication module 150, wireless communication module 160, audio module 170, speaker 170A, receiver 170B, microphone 170C, headphone interface 170D, sensor module 180, button 190, motor 191, indicator 192, camera 193, display screen 194, and Subscriber identification module (SIM) card interface 195, etc. The sensor module 180 may include a pressure sensor 180A, a gyro sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, and ambient light. Sensor 180L, bone conduction sensor 180M, etc.
可以理解的是,本发明实施例示意的结构并不构成对电子设备100的具体限定。在本申请另一些实施例中,电子设备100可以包括比图示更多或更少的部件,或者组合某些部件,或者拆分某些部件,或者不同的部件布置。图示的部件可以以硬件,软件或软件和硬件的组合实现。It can be understood that the structure illustrated in the embodiment of the present invention does not constitute a specific limitation on the electronic device 100 . In other embodiments of the present application, the electronic device 100 may include more or fewer components than shown in the figures, or some components may be combined, some components may be separated, or some components may be arranged differently. The components illustrated may be implemented in hardware, software, or a combination of software and hardware.
处理器110可以包括一个或多个处理单元,例如:处理器110可以包括应用处理器(application processor,AP),调制解调处理器,图形处理器(graphics processing unit,GPU),图像信号处理器(image signal processor,ISP),控制器,视频编解码器,数字信号处理器(digital signal processor,DSP),基带处理器,和/或神经网络处理器(neural-network processing unit,NPU)等。其中,不同的处理单元可以是独立的器件,也可以集成在一个或多个处理器中。The processor 110 may include one or more processing units. For example, the processor 110 may include an application processor (application processor, AP), a modem processor, a graphics processing unit (GPU), and an image signal processor. (image signal processor, ISP), controller, video codec, digital signal processor (digital signal processor, DSP), baseband processor, and/or neural network processor (neural-network processing unit, NPU), etc. Among them, different processing units can be independent devices or integrated in one or more processors.
控制器可以根据指令操作码和时序信号,产生操作控制信号,完成取指令和执行指令的控制。 The controller can generate operation control signals based on the instruction operation code and timing signals to complete the control of fetching and executing instructions.
处理器110中还可以设置存储器,用于存储指令和数据。在一些实施例中,处理器110中的存储器为高速缓冲存储器。该存储器可以保存处理器110刚用过或循环使用的指令或数据。如果处理器110需要再次使用该指令或数据,可从所述存储器中直接调用。避免了重复存取,减少了处理器110的等待时间,因而提高了系统的效率。The processor 110 may also be provided with a memory for storing instructions and data. In some embodiments, the memory in processor 110 is cache memory. This memory may hold instructions or data that have been recently used or recycled by processor 110 . If the processor 110 needs to use the instructions or data again, it can be called directly from the memory. Repeated access is avoided and the waiting time of the processor 110 is reduced, thus improving the efficiency of the system.
在一些实施例中,处理器110可以包括一个或多个接口。接口可以包括集成电路(inter-integrated circuit,I2C)接口,集成电路内置音频(inter-integrated circuit sound,I2S)接口,脉冲编码调制(pulse code modulation,PCM)接口,通用异步收发传输器(universal asynchronous receiver/transmitter,UART)接口,移动产业处理器接口(mobile industry processor interface,MIPI),通用输入输出(general-purpose input/output,GPIO)接口,用户标识模块(subscriber identity module,SIM)接口,和/或通用串行总线(universal serial bus,USB)接口等。可以理解的是,本发明实施例示意的各模块间的接口连接关系,只是示意性说明,并不构成对电子设备100的结构限定。在本申请另一些实施例中,电子设备100也可以采用上述实施例中不同的接口连接方式,或多种接口连接方式的组合。In some embodiments, processor 110 may include one or more interfaces. Interfaces may include integrated circuit (inter-integrated circuit, I2C) interface, integrated circuit built-in audio (inter-integrated circuit sound, I2S) interface, pulse code modulation (pulse code modulation, PCM) interface, universal asynchronous receiver and transmitter (universal asynchronous receiver/transmitter (UART) interface, mobile industry processor interface (MIPI), general-purpose input/output (GPIO) interface, subscriber identity module (SIM) interface, and /or universal serial bus (USB) interface, etc. It can be understood that the interface connection relationships between the modules illustrated in the embodiment of the present invention are only schematic illustrations and do not constitute a structural limitation of the electronic device 100 . In other embodiments of the present application, the electronic device 100 may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.
充电管理模块140用于从充电器接收充电输入。其中,充电器可以是无线充电器,也可以是有线充电器。在一些有线充电的实施例中,充电管理模块140可以通过USB接口130接收有线充电器的充电输入。在一些无线充电的实施例中,充电管理模块140可以通过电子设备100的无线充电线圈接收无线充电输入。充电管理模块140为电池142充电的同时,还可以通过电源管理模块141为电子设备供电。The charging management module 140 is used to receive charging input from the charger. Among them, the charger can be a wireless charger or a wired charger. In some wired charging embodiments, the charging management module 140 may receive charging input from the wired charger through the USB interface 130 . In some wireless charging embodiments, the charging management module 140 may receive wireless charging input through the wireless charging coil of the electronic device 100 . While the charging management module 140 charges the battery 142, it can also provide power to the electronic device through the power management module 141.
电源管理模块141用于连接电池142,充电管理模块140与处理器110。电源管理模块141接收电池142和/或充电管理模块140的输入,为处理器110,内部存储器121,显示屏194,摄像头193,和无线通信模块160等供电。电源管理模块141还可以用于监测电池容量,电池循环次数,电池健康状态(漏电,阻抗)等参数。在其他一些实施例中,电源管理模块141也可以设置于处理器110中。在另一些实施例中,电源管理模块141和充电管理模块140也可以设置于同一个器件中。The power management module 141 is used to connect the battery 142, the charging management module 140 and the processor 110. The power management module 141 receives input from the battery 142 and/or the charging management module 140, and supplies power to the processor 110, the internal memory 121, the display screen 194, the camera 193, the wireless communication module 160, and the like. The power management module 141 can also be used to monitor battery capacity, battery cycle times, battery health status (leakage, impedance) and other parameters. In some other embodiments, the power management module 141 may also be provided in the processor 110 . In other embodiments, the power management module 141 and the charging management module 140 may also be provided in the same device.
电子设备100的无线通信功能可以通过天线1,天线2,移动通信模块150,无线通信模块160,调制解调处理器以及基带处理器等实现。The wireless communication function of the electronic device 100 can be implemented through the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modem processor and the baseband processor.
天线1和天线2用于发射和接收电磁波信号。电子设备100中的每个天线可用于覆盖单个或多个通信频带。不同的天线还可以复用,以提高天线的利用率。例如:可以将天线1复用为无线局域网的分集天线。在另外一些实施例中,天线可以和调谐开关结合使用。Antenna 1 and Antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in electronic device 100 may be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve antenna utilization. For example: Antenna 1 can be reused as a diversity antenna for a wireless LAN. In other embodiments, antennas may be used in conjunction with tuning switches.
移动通信模块150可以提供应用在电子设备100上的包括2G/3G/4G/5G等无线通信的解决方案。移动通信模块150可以包括至少一个滤波器,开关,功率放大器,低噪声放大器(low noise amplifier,LNA)等。移动通信模块150可以由天线1接收电磁波,并对接收的电磁波进行滤波,放大等处理,传送至调制解调处理器进行解调。移动通信模块150还可以对经调制解调处理器调制后的信号放大,经天线1转为电磁波辐射出去。在一些实施例中,移动通信模块150的至少部分功能模块可以被设置于处理器110中。在一些实施例中,移动通信模块150的至少部分功能模块可以与处理器110的至少部分模块被设置在同一个器件中。 The mobile communication module 150 can provide solutions for wireless communication including 2G/3G/4G/5G applied on the electronic device 100 . The mobile communication module 150 may include at least one filter, switch, power amplifier, low noise amplifier (LNA), etc. The mobile communication module 150 can receive electromagnetic waves through the antenna 1, perform filtering, amplification and other processing on the received electromagnetic waves, and transmit them to the modem processor for demodulation. The mobile communication module 150 can also amplify the signal modulated by the modem processor and convert it into electromagnetic waves through the antenna 1 for radiation. In some embodiments, at least part of the functional modules of the mobile communication module 150 may be disposed in the processor 110 . In some embodiments, at least part of the functional modules of the mobile communication module 150 and at least part of the modules of the processor 110 may be provided in the same device.
调制解调处理器可以包括调制器和解调器。其中,调制器用于将待发送的低频基带信号调制成中高频信号。解调器用于将接收的电磁波信号解调为低频基带信号。随后解调器将解调得到的低频基带信号传送至基带处理器处理。低频基带信号经基带处理器处理后,被传递给应用处理器。应用处理器通过音频设备(不限于扬声器170A,受话器170B等)输出声音信号,或通过显示屏194显示图像或视频。在一些实施例中,调制解调处理器可以是独立的器件。在另一些实施例中,调制解调处理器可以独立于处理器110,与移动通信模块150或其他功能模块设置在同一个器件中。A modem processor may include a modulator and a demodulator. Among them, the modulator is used to modulate the low-frequency baseband signal to be sent into a medium-high frequency signal. The demodulator is used to demodulate the received electromagnetic wave signal into a low-frequency baseband signal. The demodulator then transmits the demodulated low-frequency baseband signal to the baseband processor for processing. After the low-frequency baseband signal is processed by the baseband processor, it is passed to the application processor. The application processor outputs sound signals through audio devices (not limited to speaker 170A, receiver 170B, etc.), or displays images or videos through display screen 194. In some embodiments, the modem processor may be a stand-alone device. In other embodiments, the modem processor may be independent of the processor 110 and may be provided in the same device as the mobile communication module 150 or other functional modules.
无线通信模块160可以提供应用在电子设备100上的包括无线局域网(wireless local area networks,WLAN)(如无线保真(wireless fidelity,Wi-Fi)网络),蓝牙(bluetooth,BT),全球导航卫星系统(global navigation satellite system,GNSS),调频(frequency modulation,FM),近距离无线通信技术(near field communication,NFC),红外技术(infrared,IR)等无线通信的解决方案。无线通信模块160可以是集成至少一个通信处理模块的一个或多个器件。无线通信模块160经由天线2接收电磁波,将电磁波信号调频以及滤波处理,将处理后的信号发送到处理器110。无线通信模块160还可以从处理器110接收待发送的信号,对其进行调频,放大,经天线2转为电磁波辐射出去。The wireless communication module 160 can provide applications on the electronic device 100 including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) network), Bluetooth (bluetooth, BT), and global navigation satellites. System (global navigation satellite system, GNSS), frequency modulation (frequency modulation, FM), near field communication technology (near field communication, NFC), infrared technology (infrared, IR) and other wireless communication solutions. The wireless communication module 160 may be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via the antenna 2 , frequency modulates and filters the electromagnetic wave signals, and sends the processed signals to the processor 110 . The wireless communication module 160 can also receive the signal to be sent from the processor 110, frequency modulate it, amplify it, and convert it into electromagnetic waves through the antenna 2 for radiation.
电子设备100通过GPU,显示屏194,以及应用处理器等实现显示功能。GPU为图像处理的微处理器,连接显示屏194和应用处理器。GPU用于执行数学和几何计算,用于图形渲染。处理器110可包括一个或多个GPU,其执行程序指令以生成或改变显示信息。The electronic device 100 implements display functions through a GPU, a display screen 194, an application processor, and the like. The GPU is an image processing microprocessor and is connected to the display screen 194 and the application processor. GPUs are used to perform mathematical and geometric calculations for graphics rendering. Processor 110 may include one or more GPUs that execute program instructions to generate or alter display information.
显示屏194用于显示图像,视频等。显示屏194包括显示面板。显示面板可以采用液晶显示屏(liquid crystal display,LCD),有机发光二极管(organic light-emitting diode,OLED),有源矩阵有机发光二极体或主动矩阵有机发光二极体(active-matrix organic light emitting diode的,AMOLED),柔性发光二极管(flex light-emitting diode,FLED),Miniled,MicroLed,Micro-oLed,量子点发光二极管(quantum dot light emitting diodes,QLED)等。在一些实施例中,电子设备100可以包括1个或N个显示屏194,N为大于1的正整数。The display screen 194 is used to display images, videos, etc. Display 194 includes a display panel. The display panel can use a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active matrix organic light emitting diode or an active matrix organic light emitting diode (active-matrix organic light emitting diode). emitting diode (AMOLED), flexible light-emitting diode (FLED), Miniled, MicroLed, Micro-oLed, quantum dot light emitting diode (QLED), etc. In some embodiments, the electronic device 100 may include 1 or N display screens 194, where N is a positive integer greater than 1.
电子设备100可以通过ISP,摄像头193,视频编解码器,GPU,显示屏194以及应用处理器等实现拍摄功能。The electronic device 100 can implement the shooting function through an ISP, a camera 193, a video codec, a GPU, a display screen 194, an application processor, and the like.
ISP用于处理摄像头193反馈的数据。摄像头193用于捕获静态图像或视频。数字信号处理器用于处理数字信号,除了可以处理数字图像信号,还可以处理其他数字信号。例如,当电子设备100在频点选择时,数字信号处理器用于对频点能量进行傅里叶变换等。视频编解码器用于对数字视频压缩或解压缩。电子设备100可以支持一种或多种视频编解码器。这样,电子设备100可以播放或录制多种编码格式的视频,例如:动态图像专家组(moving picture experts group,MPEG)1,MPEG2,MPEG3,MPEG4等。The ISP is used to process the data fed back by the camera 193. Camera 193 is used to capture still images or video. Digital signal processors are used to process digital signals. In addition to digital image signals, they can also process other digital signals. For example, when the electronic device 100 selects a frequency point, the digital signal processor is used to perform Fourier transform on the frequency point energy. Video codecs are used to compress or decompress digital video. Electronic device 100 may support one or more video codecs. In this way, the electronic device 100 can play or record videos in multiple encoding formats, such as moving picture experts group (MPEG) 1, MPEG2, MPEG3, MPEG4, etc.
外部存储器接口120可以用于连接外部存储卡,例如Micro SD卡,实现扩展电子设备100的存储能力。外部存储卡通过外部存储器接口120与处理器110通信,实现数据存储功能。例如将音乐,视频等文件保存在外部存储卡中。The external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100. The external memory card communicates with the processor 110 through the external memory interface 120 to implement the data storage function. Such as saving music, videos, etc. files in external memory card.
内部存储器121可以用于存储计算机可执行程序代码,所述可执行程序代码包括 指令。内部存储器121可以包括存储程序区和存储数据区。其中,存储程序区可存储操作系统,至少一个功能所需的应用程序(比如声音播放功能,图像播放功能等)等。存储数据区可存储电子设备100使用过程中所创建的数据(比如音频数据,电话本等)等。此外,内部存储器121可以包括高速随机存取存储器,还可以包括非易失性存储器,例如至少一个磁盘存储器件,闪存器件,通用闪存存储器(universal flash storage,UFS)等。处理器110通过运行存储在内部存储器121的指令,和/或存储在设置于处理器中的存储器的指令,执行电子设备100的各种功能应用以及数据处理。Internal memory 121 may be used to store computer executable program code including instruction. The internal memory 121 may include a program storage area and a data storage area. Among them, the stored program area can store an operating system, at least one application program required for a function (such as a sound playback function, an image playback function, etc.). The storage data area may store data created during use of the electronic device 100 (such as audio data, phone book, etc.). In addition, the internal memory 121 may include high-speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, universal flash storage (UFS), etc. The processor 110 executes various functional applications and data processing of the electronic device 100 by executing instructions stored in the internal memory 121 and/or instructions stored in a memory provided in the processor.
电子设备100可以通过音频模块170,扬声器170A,受话器170B,麦克风170C,耳机接口170D,以及应用处理器等实现音频功能。例如音乐播放,录音等。The electronic device 100 can implement audio functions through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the headphone interface 170D, and the application processor. Such as music playback, recording, etc.
按键190包括开机键,音量键等。按键190可以是机械按键。也可以是触摸式按键。电子设备100可以接收按键输入,产生与电子设备100的用户设置以及功能控制有关的键信号输入。The buttons 190 include a power button, a volume button, etc. Key 190 may be a mechanical key. It can also be a touch button. The electronic device 100 may receive key inputs and generate key signal inputs related to user settings and function control of the electronic device 100 .
电子设备100的软件系统可以采用分层架构,事件驱动架构,微核架构,微服务架构,或云架构。例如,该电子设备100的软件系统可以是鸿蒙系统、Android系统等。本发明实施例以分层架构的Android系统为例,示例性说明电子设备100的软件结构。The software system of the electronic device 100 may adopt a layered architecture, an event-driven architecture, a microkernel architecture, a microservice architecture, or a cloud architecture. For example, the software system of the electronic device 100 may be the Hongmeng system, Android system, etc. This embodiment of the present invention takes the Android system with a layered architecture as an example to illustrate the software structure of the electronic device 100 .
图2A是本发明实施例的电子设备100的软件结构框图。FIG. 2A is a software structure block diagram of the electronic device 100 according to the embodiment of the present invention.
分层架构将软件分成若干个层,每一层都有清晰的角色和分工。层与层之间通过软件接口通信。在一些实施例中,将Android系统分为五层,从上至下分别为应用程序层(简称应用层),应用程序框架层(简称框架层),安卓运行时(Android runtime)和系统库,硬件抽象层(Hardware Abstraction Layer,HAL)以及内核层。The layered architecture divides the software into several layers, and each layer has clear roles and division of labor. The layers communicate through software interfaces. In some embodiments, the Android system is divided into five layers. From top to bottom, they are the application layer (referred to as the application layer), the application framework layer (referred to as the framework layer), the Android runtime (Android runtime) and the system library. Hardware Abstraction Layer (HAL) and kernel layer.
(1)应用层(1)Application layer
应用层可以包括一系列应用程序包。如图2A所示,应用程序包可以包括相机,图库,日历,通话,地图,导航,WLAN,蓝牙,音乐,视频,短信息等应用程序。The application layer can include a series of application packages. As shown in Figure 2A, the application package can include camera, gallery, calendar, calling, map, navigation, WLAN, Bluetooth, music, video, short message and other applications.
(2)框架层(2)Frame layer
框架层为应用层的应用程序提供应用编程接口(application programming interface,API)和编程框架。框架层包括一些预先定义的函数。The framework layer provides application programming interface (API) and programming framework for applications in the application layer. The framework layer includes some predefined functions.
如图2A所示,框架层可以包括活动管理器,窗口管理器,内容提供器,视图系统,电话管理器,资源管理器,通知管理器等。As shown in Figure 2A, the framework layer can include activity manager, window manager, content provider, view system, phone manager, resource manager, notification manager, etc.
其中,活动管理器,用于负责所有APP进程的启动,APP四大组件(如活动activity、服务service、广播接收者broadcast receiver、内容提供者content provider)的启动,APP之间及APP内部界面之间切换和各种组件的生命周期。窗口管理器用于管理窗口程序。窗口管理器可以获取显示屏大小,判断是否有状态栏,锁定屏幕,截取屏幕等。内容提供器用来存放和获取数据,并使这些数据可以被应用程序访问。所述数据可以包括视频,图像,音频,拨打和接听的电话,浏览历史和书签,电话簿等。视图系统包括可视控件,例如显示文字的控件,显示图片的控件等。视图系统可用于构建应用程序。显示界面可以由一个或多个视图组成的。例如,包括短信通知图标的显示界面,可以包括显示文字的视图以及显示图片的视图。电话管理器用于提供电子设备100的通信功能。例如通话状态的管理(包括接通,挂断等)。资源管理器为应用程序提供各种资源,比如本地化字符串,图标,图片,布局文件,视频文件等等。通知管理器使 应用程序可以在状态栏中显示通知信息,可以用于传达告知类型的消息,可以短暂停留后自动消失,无需用户交互。比如通知管理器被用于告知下载完成,消息提醒等。通知管理器还可以是以图表或者滚动条文本形式出现在系统顶部状态栏的通知,例如后台运行的应用程序的通知,还可以是以对话窗口形式出现在屏幕上的通知。例如在状态栏提示文本信息,发出提示音,电子设备振动,指示灯闪烁等。Among them, the activity manager is responsible for the startup of all APP processes, the startup of the four major components of the APP (such as activity, service, broadcast receiver, content provider), the interface between APPs and within the APP. switching and the life cycle of various components. A window manager is used to manage window programs. The window manager can obtain the display size, determine whether there is a status bar, lock the screen, capture the screen, etc. Content providers are used to store and retrieve data and make this data accessible to applications. Said data can include videos, images, audio, calls made and received, browsing history and bookmarks, phone books, etc. The view system includes visual controls, such as controls that display text, controls that display pictures, etc. A view system can be used to build applications. The display interface can be composed of one or more views. For example, a display interface including a text message notification icon may include a view for displaying text and a view for displaying pictures. The phone manager is used to provide communication functions of the electronic device 100 . For example, call status management (including connected, hung up, etc.). The resource manager provides various resources to applications, such as localized strings, icons, pictures, layout files, video files, etc. Notification manager enables The application can display notification information in the status bar, which can be used to convey notification-type messages, and can automatically disappear after a short stay without user interaction. For example, the notification manager is used to notify download completion, message reminders, etc. The notification manager can also be notifications that appear in the status bar at the top of the system in the form of charts or scroll bar text, such as notifications for applications running in the background, or notifications that appear on the screen in the form of conversation windows. For example, text information is prompted in the status bar, a beep sounds, the electronic device vibrates, the indicator light flashes, etc.
在本申请的一些实施例中,框架层还包括组件清理模块。该组件清理模块用于按照一定策略清理组件。例如,采用最近最少使用(Least Recently Used,LRU)算法筛选最近不常使用的组件,并清理筛选出的组件。该组件清理模块还用于在接收到内核层查杀进程的信息后,清理被查杀进程所关联的组件。在另一些实施例中,该组件清理模块还用于判断被查杀进程所关联的组件是否为关键组件,以确定是否清理该组件。其中,关键组件是指包含关键信息的组件。其中关键信息包括目标进程运行时会影响系统运行稳定性,或者影响到用户的使用体验的信息。下文将对该实施例进行详细说明,这里先不展开说明。In some embodiments of the present application, the framework layer also includes a component cleaning module. This component cleaning module is used to clean components according to certain strategies. For example, the least recently used (Least Recently Used, LRU) algorithm is used to filter components that are not frequently used recently, and the filtered components are cleaned up. The component cleaning module is also used to clean up the components associated with the killed process after receiving information about the kernel-level killing process. In other embodiments, the component cleaning module is also used to determine whether the component associated with the process to be killed is a critical component to determine whether to clean the component. Among them, key components refer to components that contain key information. The key information includes information that will affect the stability of the system when the target process is running, or affect the user experience. This embodiment will be described in detail below, and will not be described here.
(3)Android Runtime和系统库(3)Android Runtime and system libraries
如图2A所示,Android Runtime包括核心库和虚拟机。Android runtime负责安卓系统的调度和管理。As shown in Figure 2A, Android Runtime includes core libraries and virtual machines. Android runtime is responsible for the scheduling and management of the Android system.
核心库包含两部分:一部分是java语言需要调用的功能函数,另一部分是安卓的核心库。The core library contains two parts: one is the functional functions that need to be called by the Java language, and the other is the core library of Android.
应用层和框架层运行在虚拟机中。虚拟机将应用层和框架层的java文件执行为二进制文件。虚拟机用于执行对象生命周期的管理,堆栈管理,线程管理,安全和异常的管理,以及垃圾回收等功能。The application layer and framework layer run in virtual machines. The virtual machine executes the java files of the application layer and framework layer into binary files. The virtual machine is used to perform object life cycle management, stack management, thread management, security and exception management, and garbage collection and other functions.
系统库可以包括多个功能模块。例如:表面管理器(surface manager),媒体库(Media Libraries),三维图形处理库(例如:OpenGL ES),2D图形引擎(例如:SGL)等。System libraries can include multiple functional modules. For example: surface manager (surface manager), media libraries (Media Libraries), 3D graphics processing libraries (for example: OpenGL ES), 2D graphics engines (for example: SGL), etc.
其中,表面管理器用于对显示子系统进行管理,并且为多个应用程序提供了2D和3D图层的融合。媒体库支持多种常用的音频,视频格式回放和录制,以及静态图像文件等。媒体库可以支持多种音视频编码格式,例如:MPEG4,H.264,MP3,AAC,AMR,JPG,PNG等。三维图形处理库用于实现三维图形绘图,图像渲染,合成,和图层处理等。2D图形引擎是2D绘图的绘图引擎。Among them, the surface manager is used to manage the display subsystem and provides the integration of 2D and 3D layers for multiple applications. The media library supports playback and recording of a variety of commonly used audio and video formats, as well as static image files, etc. The media library can support a variety of audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc. The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, composition, and layer processing. 2D Graphics Engine is a drawing engine for 2D drawing.
(4)HAL(4)HAL
HAL,用于将硬件抽象化。HAL隐藏了特定平台的硬件接口细节,为操作系统提供虚拟硬件平台,使其具有硬件无关性,可在多种平台上进行移植。也就是说,上层所需使需要的有关硬件的操作都需要调用HAL相关的API,例如音视频接口、GPS接口、通话接口、Wi-Fi接口以及其他接口。HAL, used to abstract hardware. HAL hides the hardware interface details of a specific platform and provides a virtual hardware platform for the operating system, making it hardware-independent and portable on multiple platforms. In other words, all hardware-related operations required by the upper layer require calling HAL-related APIs, such as audio and video interfaces, GPS interfaces, call interfaces, Wi-Fi interfaces, and other interfaces.
(5)内核层(5) Kernel layer
内核层是硬件和软件之间的层。The kernel layer is the layer between hardware and software.
内核层包括内核分配器、内存统计模块以及进程查杀模块。进一步的,内核层还包括进程/线程,音视频驱动、GPS驱动、Wi-Fi驱动等。The kernel layer includes the kernel allocator, memory statistics module and process killing module. Furthermore, the kernel layer also includes processes/threads, audio and video drivers, GPS drivers, Wi-Fi drivers, etc.
其中,内核分配器,可以为维护电子设备上各个进程的运行状态而分配内存。内存统计模块,用于统计各个进程申请的各类内存的情况。该内存统计模块用于统计电 子设备中各个进程占用的各类内存的情况。其中,各个进程占用的各类内存可包括文件类占用内存、用户态匿名页占用内存、流媒体占用内存、以及内核占用内存等。Among them, the kernel allocator can allocate memory to maintain the running status of each process on the electronic device. The memory statistics module is used to count the various types of memory requested by each process. This memory statistics module is used to count power The various types of memory occupied by each process in the sub-device. Among them, the various types of memory occupied by each process can include memory occupied by files, memory occupied by user-mode anonymous pages, memory occupied by streaming media, and memory occupied by the kernel.
如图2B所示,上述文件类占用内存可包括文件页占用内存、核心库文件占用内存以及缓存数据占用内存。具体的,文件页可包括应用程序的代码文件以及应用运行时的资源文件(例如图标、图片)等。例如,应用程序的代码文件可以包括应用程序的配置文件(如:.dex文件)和类文件(如:.class文件)等。核心库文件可包括应用程序运行时需要访问的动态链接库(如.so文件,一种二进制文件)。缓存数据可包括电子设备中存储的用于缓存目的的文件属性的数据。一个具体的实现方式中,电子设备可使用图2A中应用层和框架层之间的mmap分配器(更具体的为文件页分配器)分配文件页占用内存以及缓存数据占用内存。电子设备可使用图2A中框架层与安卓运行时层之间的mmap分配器(更具体的为核心库文件分配器)分配核心库文件占用内存。在一些示例中,核心库文件分配器可以通过封装文件页分配器的方式实现,本申请实施例对核心库文件分配器的具体实现不做限定。As shown in Figure 2B, the memory occupied by the above file types may include the memory occupied by file pages, the memory occupied by core library files, and the memory occupied by cache data. Specifically, the file page may include code files of the application program and resource files (such as icons and pictures) when the application is running. For example, the code files of the application may include the application's configuration files (such as .dex files) and class files (such as .class files). Core library files can include dynamic link libraries (such as .so files, a binary file) that the application needs to access when running. Cached data may include data on file attributes stored in the electronic device for caching purposes. In a specific implementation, the electronic device can use the mmap allocator (more specifically, the file page allocator) between the application layer and the framework layer in Figure 2A to allocate the memory occupied by the file page and the memory occupied by the cache data. The electronic device can use the mmap allocator (more specifically, the core library file allocator) between the framework layer and the Android runtime layer in Figure 2A to allocate the memory occupied by the core library file. In some examples, the core library file allocator can be implemented by encapsulating the file page allocator. The embodiments of this application do not limit the specific implementation of the core library file allocator.
上述用户态匿名页占用内存,可包括应用程序运行过程中动态分配的内存,可包括调用框架层的API和编程框架产生的内存消耗。其中,调用的框架层的API和编程框架可包括:高层语言(例如Java语言,JavaScript语言,TypeScript语言)API、高层语言的系统组件以及系统语言(例如C++语言,C语言)的系统框架。一个具体的实现方式中,电子设备可使用可图2A中框架层和安卓运行时之间的mmap分配器(更具体的为匿名页分配器)为应用程序调用高层语言API、高层语言的系统组件分配所需占用的内存。电子设备可使用图2A中框架层和系统库之间的C++分配器为应用程序调用系统语言(例如C++语言,C语言)的系统框架分配所需占用的内存。The memory occupied by the above-mentioned user-mode anonymous page can include dynamically allocated memory during the running of the application, and can include memory consumption caused by calling the API of the framework layer and the programming framework. The APIs and programming frameworks of the called framework layer may include: APIs of high-level languages (such as Java language, JavaScript language, TypeScript language), system components of high-level languages, and system frameworks of system languages (such as C++ language, C language). In a specific implementation, the electronic device can use the mmap allocator (more specifically the anonymous page allocator) between the framework layer and the Android runtime in Figure 2A to call high-level language APIs and high-level language system components for the application. Allocate the required memory. The electronic device can use the C++ allocator between the framework layer and the system library in Figure 2A to allocate the memory required for the system framework that the application calls the system language (such as C++ language, C language).
需要说明的是,在一些示例中,为了节省用户态匿名页数据在内存的占用,操作系统可以对使用频率不高的用户态匿名页数据进行压缩。需要说明的是,电子设备具体是由内核层触发压缩用户态匿名页数据的行为,并将压缩后的数据(也称为Zram压缩数据)存放在用于存放Zram压缩数据的内存空间中,由内核对Zram压缩数据进行统一管控。也就是说,一个具体的实现方式中,具体可由图2A中内核层的内核分配器分配用于存放Zram压缩数据的内存空间。It should be noted that in some examples, in order to save user-mode anonymous page data from occupying memory, the operating system can compress user-mode anonymous page data that is not used frequently. It should be noted that the electronic device specifically triggers the behavior of compressing user-mode anonymous page data by the kernel layer, and stores the compressed data (also called Zram compressed data) in the memory space used to store Zram compressed data. The kernel provides unified management and control of Zram compressed data. That is to say, in a specific implementation, the memory space for storing Zram compressed data can be allocated by the kernel allocator of the kernel layer in Figure 2A.
上述流媒体占用内存包括专用的流媒体内存分配器分配的内存。具体来说,多数应用程序(例如视频类应用、音乐类应用、游戏类应用、社交类应用等)具有流媒体播放能力。而这一类应用程序往往需要调用电子设备中SoC芯片中不同硬件的算力。而操作系统为保证不同硬件(如CPU、DSP、GPU、VPU)之间数据的高效共享,提供了专用的流媒体内存分配器(例如Android的ION内存分配器)。一个具体的实现方式中,电子设备可使用图2A中系统库与HAL之间的流媒体内存分配器为这些应用程序播放流媒体分配内存。需要注意的是,流媒体占用内存只能由申请者(即申请流媒体内存的应用程序)主动释放,内核无法对流媒体占用内存进行统一管控。The memory occupied by the above streaming media includes the memory allocated by the dedicated streaming media memory allocator. Specifically, most applications (such as video applications, music applications, game applications, social applications, etc.) have streaming media playback capabilities. This type of application often requires the computing power of different hardware in the SoC chip in the electronic device. In order to ensure efficient sharing of data between different hardware (such as CPU, DSP, GPU, VPU), the operating system provides a dedicated streaming media memory allocator (such as Android's ION memory allocator). In a specific implementation, the electronic device can use the streaming media memory allocator between the system library and HAL in Figure 2A to allocate memory for these applications to play streaming media. It should be noted that the memory occupied by streaming media can only be actively released by the applicant (that is, the application that applies for streaming media memory), and the kernel cannot uniformly control the memory occupied by streaming media.
上述内核占用内存可包括:Vmalloc、Slab等内核运行所消耗的内存,用于页表转换(Page Table Entries,PTE)的内存,维护应用程序的进程信息的Kernel Stack、用于存放Zram压缩数据占用内存、以及用于实现多个进程间的高效通信的共享内存(例如Shmem)等。一个具体的实现方式中,电子设备可以使用图2A中内核层的内核分 配器分配内核占用的内存。The memory occupied by the above kernel can include: memory consumed by kernel operations such as Vmalloc and Slab, memory used for page table conversion (Page Table Entries, PTE), Kernel Stack that maintains application process information, and memory occupied by Zram compressed data. memory, and shared memory (such as Shmem) for efficient communication between multiple processes. In a specific implementation, the electronic device can use the kernel segmentation of the kernel layer in Figure 2A The orchestrator allocates memory occupied by the kernel.
总而言之,上述内存统计模块可以从mmap分配器、C++分配器、流媒体内存分配器以及内核分配器处获取各个进程占用的各类内存。需要说明的是,在其他一些实施例中,电子设备还可以包括多个子统计模块,例如在mmap分配器、C++分配器、流媒体内存分配器等位置分别设置有不同的子统计模块,用于统计各个分配器为进程分配的内存。而后子统计模块将统计数据汇总到内核层的内存统计模块(也称为总统计模块)处,由内核层的统计模块根据统计到的各个进程的各类内存进行分析,以确定查杀的目标进程。或者,在另一些实施例中,电子设备仅在例如mmap分配器、C++分配器、流媒体内存分配器、内核分配器等处设置子统计模块,不设置总统计模块。那么,子统计模块将各自统计的数据直接传递给进程查杀模块,由进程查杀模块根据统计到的各个进程的各类内存进行分析,以确定查杀的目标进程。本申请实施例对此不做具体限定。All in all, the above memory statistics module can obtain various types of memory occupied by each process from the mmap allocator, C++ allocator, streaming media memory allocator and kernel allocator. It should be noted that in some other embodiments, the electronic device may also include multiple sub-statistical modules, for example, different sub-statistical modules are respectively provided at mmap allocator, C++ allocator, streaming media memory allocator, etc., for Count the memory allocated by each allocator for the process. Then the sub-statistics module summarizes the statistical data to the memory statistics module of the kernel layer (also called the total statistics module). The statistics module of the kernel layer analyzes the various types of memory of each process to determine the target of killing. process. Or, in other embodiments, the electronic device only sets sub-statistics modules at, for example, mmap allocator, C++ allocator, streaming media memory allocator, kernel allocator, etc., and does not set a total statistics module. Then, the sub-statistical modules directly pass their respective statistical data to the process killing module, and the process killing module analyzes the various types of memory of each process to determine the target process for killing. The embodiments of this application do not specifically limit this.
如图2A所示,上述进程查杀模块,用于检测进程查杀流程的触发事件,以及根据上述内存统计模块检测到的各个进程占用的各类内存情况选择要查杀的进程(即目标进程),对选择的目标进程执行查杀等。As shown in Figure 2A, the above-mentioned process killing module is used to detect the triggering events of the process killing process, and select the process to be killed (i.e. the target process) based on the various types of memory occupied by each process detected by the above-mentioned memory statistics module. ), perform scanning and killing on the selected target process, etc.
以下实施例中所涉及的技术方案均可以在具有上述硬件架构和软件架构的电子设备100中实现。The technical solutions involved in the following embodiments can be implemented in the electronic device 100 with the above hardware architecture and software architecture.
在一种技术方案中,电子设备可以采用基于剩余内存量的水线触发机制来查杀进程。具体的,电子设备可以监测电子设备的剩余内存量,当监测到剩余内存量小于或等于阈值1时,电子设备启动进程查杀流程。其中,剩余内存是指可用内存,可以包括系统中空闲的内存,以及文件类占用内存(包括文件页、核心库文件和缓存数据占用的内存)。需要说明的是,由于多数的文件页、核心库文件以及缓存数据在电子设备的存储器件中(如Flash器件)都有备份,在内存回收过程中,电子设备可以直接清理这部分数据占用的内存,并不需要先对这部分数据进行某些需要系统开销的操作(例如备份)后再清理这部分数据占用的内存。也就是说,这部分数据占用的内存属于低开销的可回收的内存。因此,这部分数据占用的内存属于可用内存。In one technical solution, the electronic device can use a waterline triggering mechanism based on the amount of remaining memory to kill the process. Specifically, the electronic device can monitor the remaining memory amount of the electronic device. When it is detected that the remaining memory amount is less than or equal to the threshold 1, the electronic device starts the process killing process. Among them, the remaining memory refers to the available memory, which can include the free memory in the system and the memory occupied by files (including the memory occupied by file pages, core library files and cached data). It should be noted that since most file pages, core library files and cache data are backed up in the storage devices of electronic devices (such as Flash devices), during the memory recycling process, the electronic device can directly clean up the memory occupied by this part of the data. , there is no need to first perform some operations that require system overhead (such as backup) on this part of the data and then clean up the memory occupied by this part of the data. In other words, the memory occupied by this part of the data is low-overhead recyclable memory. Therefore, the memory occupied by this part of the data belongs to available memory.
在电子设备启动进程查杀流程后,电子设备可以采用进程的使用频率与进程占用的内存量相结合的方式确定查杀的目标进程。例如,当电子设备启动查杀流程后,电子设备先采用例如最近最少使用(Least Recently Used,LRU)算法筛选出使用频率不高的进程作为候选进程,然后根据各个候选进程的内存占用量,从中选择内存占用量较大的候选进程作为目标进程,而后查杀目标进程,以释放目标进程占用的内存。After the electronic device starts the process checking and killing process, the electronic device can determine the target process for checking and killing by combining the usage frequency of the process and the amount of memory occupied by the process. For example, when an electronic device starts the killing process, the electronic device first uses the least recently used (Least Recently Used, LRU) algorithm to filter out processes that are not frequently used as candidate processes, and then selects processes based on the memory usage of each candidate process. Select the candidate process that occupies a large amount of memory as the target process, and then kill the target process to release the memory occupied by the target process.
需要说明的是,现有技术中,Linux内核中已提供多种工具用于获取各个进程的内存占用量。例如,电子设备可以采用top命令、ps命令以及其他命令等,或者采用其中任几个命令相结合的方法获取各个候选进程的内存占用量。需要说明的是,现有技术在获取各个进程的内存占用量时,仅统计了进程在用户态占用的内存(记为第一类内存),而并未统计进程在内核态占用的内存(记为第二类内存)。其中,第一类内存可以包括文件类占用内存和用户态匿名页占用内存。本申请实施例将现有技术中没有统计到的进程运行过程中占用的内存,记为第二类内存。第二类内存可以包括流媒体占用内存和内核占用内存。可以理解的,第一类内存可以是进程使用内存分配器 (例如mmap分配器),或者通过框架层使用内存分配器(例如C++分配器)分配的内存。第二类内存可以是进程通过系统库使用专用的流媒体分配器,或者通过内核层的内核分配器分配的内存。It should be noted that in the existing technology, a variety of tools have been provided in the Linux kernel to obtain the memory usage of each process. For example, the electronic device can use the top command, the ps command, and other commands, or a combination of any of these commands to obtain the memory usage of each candidate process. It should be noted that when obtaining the memory usage of each process, the existing technology only counts the memory occupied by the process in the user mode (recorded as the first type of memory), but does not count the memory occupied by the process in the kernel state (recorded as the first type of memory). is the second type of memory). Among them, the first type of memory can include memory occupied by files and memory occupied by user-mode anonymous pages. In the embodiment of this application, the memory occupied during the running of the process that is not counted in the prior art is recorded as the second type of memory. The second type of memory can include memory occupied by streaming media and memory occupied by the kernel. It is understandable that the first type of memory can be a process using a memory allocator (such as the mmap allocator), or memory allocated through the framework layer using a memory allocator (such as the C++ allocator). The second type of memory can be memory allocated by the process through the system library using a dedicated streaming allocator, or through the kernel allocator at the kernel level.
可以理解的是,由于现有技术中仅统计了进程运行过程中占用的第一类内存,那么当电子设备根据各个候选进程的第一类内存的占用量来确定目标进程时,电子设备选择第一类内存的占用量较大的候选进程为目标进程。那么,电子设备在杀死目标进程后,会回收该目标进程占用的第一类内存。可以理解的,在实际的使用场景中,进程占用的第一类内存在整机内存中的占比可能并不高,因此杀死基于第一类内存占用量确定的目标进程的收益较小,不利于使得电子设备的可用内存维持在一个较高的数值上,那么电子设备可能需要频繁地触发进程查杀行为,易造成系统崩溃。It can be understood that since the prior art only counts the first type of memory occupied during the running process of the process, when the electronic device determines the target process based on the occupation of the first type of memory of each candidate process, the electronic device selects the third type of memory. One type of candidate process that occupies a large amount of memory is the target process. Then, after killing the target process, the electronic device will reclaim the first type of memory occupied by the target process. It is understandable that in actual usage scenarios, the proportion of the first type of memory occupied by the process in the whole machine memory may not be high, so the benefit of killing the target process determined based on the first type of memory usage is small. If it is not conducive to maintaining the available memory of the electronic device at a high value, the electronic device may need to frequently trigger process killing behaviors, which may easily cause the system to crash.
为此,本申请实施例提供的一种方法,在统计进程运行过程中占用的内存时,一并统计进程运行过程中占用的第一类内存和第二类内存,即统计第一类内存和第二类内存的总占用量。那么,电子设备在执行进程查杀时,会根据各个候选进程的第一类内存和第二类内存的总占用量来确定目标进程。并且,电子设备在杀死目标进程后,会回收这些目标进程占用的第一类内存和第二类内存。由于通过该方法回收的第一类内存和第二类内存在整机内存的占比较高,有利于使得电子设备的可用内存维持在一个较高的数值上,能够避免电子设备频繁地触发进程查杀行为,有利于提升电子设备运行的流畅度和稳定性。To this end, an embodiment of the present application provides a method. When counting the memory occupied during the running of a process, the first type of memory and the second type of memory occupied during the running of the process are also counted. That is, the first type of memory and the second type of memory are counted. The total amount of memory occupied by the second type of memory. Then, when the electronic device performs process killing, it will determine the target process based on the total occupation of the first type of memory and the second type of memory of each candidate process. Moreover, after killing the target processes, the electronic device will reclaim the first type of memory and the second type of memory occupied by these target processes. Since the first type of memory and the second type of memory recovered through this method account for a high proportion of the entire machine memory, it is conducive to maintaining the available memory of the electronic device at a higher value and preventing the electronic device from frequently triggering process checks. Killing behavior is conducive to improving the smoothness and stability of the operation of electronic devices.
以下结合附图对本申请实施例提供的技术方案进行详细说明。The technical solutions provided by the embodiments of the present application will be described in detail below with reference to the accompanying drawings.
如图3所示,为本申请实施例提供的一种应用程序进程的查杀方法的流程示意图,该流程包括:As shown in Figure 3, it is a schematic flow chart of a method for checking and killing application processes provided by the embodiment of the present application. The process includes:
S301、电子设备运行一个或多个APP。S301. The electronic device runs one or more APPs.
以电子设备运行APP1为例进行说明。电子设备运行APP1的过程中,APP1可以启动多个进程,例如前台进程和后台进程。其中,前台进程可以用于呈现APP1的用户界面,可以和用户进行交互。在一个示例中,APP1先启动前台进程,该前台进程可以拉起一个或多个后台进程,后台进程不需要和用户交互。该一个或多个后台进程可以包括APP1的后台服务进程,也可以包括电子设备的系统服务进程。再进一步地,这一个或多个后台进程还可以再次拉起其他的后台进程。总而言之,一个APP可能启动多个进程,这些进程在运行过程中会申请电子设备中相应的内存等系统资源。当然,一个APP也可能仅启动一个进程,或者在某些场景下该APP仅启动一个进程,在其他场景下启动多个进程。Take the electronic device running APP1 as an example for explanation. When the electronic device runs APP1, APP1 can start multiple processes, such as a foreground process and a background process. Among them, the foreground process can be used to present the user interface of APP1 and interact with the user. In one example, APP1 first starts a foreground process, which can launch one or more background processes. The background processes do not need to interact with the user. The one or more background processes may include a background service process of APP1 or a system service process of the electronic device. Furthermore, this one or more background processes can also start other background processes again. All in all, an APP may start multiple processes, and these processes will apply for corresponding memory and other system resources in the electronic device during operation. Of course, an APP may only start one process, or the APP may only start one process in some scenarios and multiple processes in other scenarios.
S302、电子设备统计该一个或多个APP启动的各个进程占用的第一类内存和第二类内存。S302. The electronic device counts the first type of memory and the second type of memory occupied by each process started by the one or more APPs.
在一些实施例中,电子设备可以在各个内存分配器处插桩,统计各个进程向各个内存分配器申请的各类的内存,包括第一类内存和第二类内存。其中,插桩,是指在保证各个内存分配器原有逻辑完整性的基础上在程序中插入一些探针(又称为“探测仪”,本质上就是进行信息采集的代码段,可以是赋值语句或采集覆盖信息的函数调用),通过探针的执行采集各个进程通过各个内存分配器申请的分类内存。In some embodiments, the electronic device can instrument each memory allocator and count the types of memory requested by each process from each memory allocator, including the first type of memory and the second type of memory. Among them, instrumentation refers to inserting some probes (also called "probes") into the program on the basis of ensuring the original logical integrity of each memory allocator. They are essentially code segments for information collection, which can be assignments. statement or function call to collect coverage information), and through the execution of the probe, the classified memory requested by each process through each memory allocator is collected.
这里以统计进程占用的第二类内存为例进行说明。前文已说明,进程占用的第二 类内存可包括流媒体分配器(例如ION内存分配器)分配的内存和内核分配器分配的内存。其中,内核分配器分配的内存包括Vmalloc、Slab等内核运行的内存消耗,用于页表转换的PTE(Page Table Entries)内存,维护应用程序的进程信息的Kernel Stack、用于存放Zram压缩数据占用内存、以及用于实现多个进程间的高效通信的共享内存(例如Shmem)等。Here we take the second type of memory occupied by statistical processes as an example for explanation. As mentioned above, the process occupies the second Class memory can include memory allocated by streaming allocators (such as the ION memory allocator) and memory allocated by kernel allocators. Among them, the memory allocated by the kernel allocator includes the memory consumption of kernel operations such as Vmalloc and Slab, PTE (Page Table Entries) memory for page table conversion, Kernel Stack for maintaining application process information, and Zram compressed data storage. memory, and shared memory (such as Shmem) for efficient communication between multiple processes.
在具体实现中,可以在流媒体分配器(例如ION内存分配器)的EGL Track接口处插桩实现监听,以统计流媒体分配器向进程分配的内存。可以在内核zsalloc内存分配接口处插桩实现监听,以统计Zram压缩数据占用内存。可以在内核Shmem内存分配接口处插桩实现监听,以统计进程申请的共享内存。内核中的其他分配器,如PTE,Kernel Stack,Slab,Slab Large,Vmalloc等也提供了相应的内存统计接口,均可以在相应的统计接口处插桩实现监听,以统计进程申请的各类内存,这里不再一一赘述。In a specific implementation, monitoring can be implemented at the EGL Track interface of the streaming media allocator (such as the ION memory allocator) to count the memory allocated by the streaming media allocator to the process. Monitoring can be implemented by instrumenting the kernel zsalloc memory allocation interface to count the memory occupied by Zram compressed data. Monitoring can be implemented by instrumenting the kernel Shmem memory allocation interface to count the shared memory requested by the process. Other allocators in the kernel, such as PTE, Kernel Stack, Slab, Slab Large, Vmalloc, etc., also provide corresponding memory statistics interfaces. They can be installed at the corresponding statistics interfaces to implement monitoring to count various types of memory requested by the process. , I won’t go into details here.
需要说明的是,部分进程可能需要与其他进程进行联动共同完成相关任务。例如,一个APP启动的进程(例如进程1)可能拉起另一个或多个进程(例如进程2)。这一个或多个进程中也可能申请内存,如第一类内存,和/或第二类内存)。在现有技术中,如果进程2申请了第一类内存,那么进程2申请的第一类内存可能被统计为进程2占用的内存,不会被统计到进程1占用的内存。那么,后续当确定进程1是目标进程,则查杀进程1时不会回收进程2占用的内存。可以理解的是,进程2这里申请的内存是为支持进程1的运行,如果进程1被查杀,进程2这里申请的内存也没有作用了,这样造成了内存的浪费。或者,如果进程2申请了第二类内存,那么现有技术不能统计到进程2申请的第二类内存,仍然会造成进程查杀后的收益不高的问题。It should be noted that some processes may need to be linked with other processes to jointly complete related tasks. For example, a process started by an APP (such as process 1) may start another or multiple processes (such as process 2). This one or more processes may also apply for memory, such as first-class memory, and/or second-class memory). In the existing technology, if process 2 applies for the first type of memory, the first type of memory applied by process 2 may be counted as the memory occupied by process 2, and will not be counted as the memory occupied by process 1. Then, when it is determined that process 1 is the target process, the memory occupied by process 2 will not be reclaimed when killing process 1. It is understandable that the memory requested by process 2 is to support the operation of process 1. If process 1 is killed, the memory requested by process 2 will have no effect, which causes a waste of memory. Or, if process 2 applies for the second type of memory, the existing technology cannot count the second type of memory applied by process 2, which will still cause the problem of low profits after the process is killed.
为此,在本申请的另一些实施例中,电子设备在统计各个进程的内存时,会根据进程之间的联动关系(也称为拉起关系、调用关系等),将各个进程申请的内存分配到源头进程上。这样,后续电子设备在选择查杀的目标进程时,可以准确地确定出占用系统的第一类内存和第二类内存总量最大的目标进程,并且在查杀目标进程时,能够回收更多的第一类内存和第二类内存,从而提升进程查杀的收益,提升系统的流畅度和稳定性。For this reason, in other embodiments of the present application, when counting the memory of each process, the electronic device will calculate the memory applied for by each process based on the linkage relationship between the processes (also known as the pull-up relationship, calling relationship, etc.) Assigned to the source process. In this way, when the subsequent electronic device selects the target process to be checked and killed, it can accurately determine the target process that occupies the largest amount of the first type of memory and the second type of memory of the system, and can recover more when checking and killing the target process. The first type of memory and the second type of memory, thereby increasing the benefits of process killing and improving the smoothness and stability of the system.
在具体实现中,由于进程间的联动关系需要通过系统中进程间通信服务(例如粘合剂Binder,套接字Socket以及信号Signal),电子设备可以通过监听进程间通信服务,统计出各个进程的联动关系。在一些示例中,电子设备可以维护进程间的联动关系链表(如图4示出了一种进程间的联动关系链表的示例),来统计不同进程之间的联动关系。其中电子设备具体可以采用红黑树或哈希表等方式进行统计。然后,根据各个进程的联动关系,将各个进程申请的内存最终统计到源头进程。其中,源头进程是指第一个调用者。例如,进程1调用了进程2,进程2又调用了进程3。那么,进程2和进程3的源头进程均为进程1。In specific implementation, since the linkage relationship between processes requires inter-process communication services in the system (such as Binder, Socket, and Signal), electronic devices can collect statistics on each process by monitoring the inter-process communication services. Linkage relationship. In some examples, the electronic device can maintain a linked list of linkage relationships between processes (Figure 4 shows an example of a linked list of linkage relationships between processes) to collect statistics on linkage relationships between different processes. Among them, the electronic equipment can be counted using methods such as red-black trees or hash tables. Then, based on the linkage relationship of each process, the memory requested by each process is finally counted to the source process. Among them, the source process refers to the first caller. For example, process 1 calls process 2, and process 2 calls process 3. Then, the source process of process 2 and process 3 is process 1.
如图5所示,这里以APP1为例,对APP1的进程间的联动关系以及统计内存的方法进行示例性说明。运行APP1时,会启动APP1的主进程(例如前台进程)。APP1主进程可能会调用框架层,和/或系统库和运行时层的后台服务(每个服务都将对应一个进程),例如主进程调用音视频服务,音视频服务通过图形分配器(Graghic Allocator)申请流媒体的内存(例如ION内存)。那么,电子设备建立APP1的主进程(或者APP1) 与音视频服务的联动关系,将音视频服务申请的内存统计到APP1的主进程(或者APP1)。类似地,当APP1主进程调用图像渲染服务,图像渲染服务通过图形分配器(Graghic Allocator)申请流媒体的内存(例如ION内存)。那么,电子设备建立APP1的主进程(或者APP1)与图像渲染服务的联动关系,将图像渲染服务申请的内存统计到APP1的主进程(或者APP1)。As shown in Figure 5, APP1 is taken as an example to illustrate the linkage relationship between processes of APP1 and the method of counting memory. When running APP1, the main process of APP1 (such as the foreground process) will be started. The main process of APP1 may call the background services of the framework layer, and/or the system library and runtime layer (each service will correspond to a process). For example, the main process calls audio and video services, and the audio and video services pass the graphical allocator (Graghic Allocator). ) applies for streaming media memory (such as ION memory). Then, the electronic device establishes the main process of APP1 (or APP1) The linkage relationship with the audio and video service counts the memory requested by the audio and video service to the main process of APP1 (or APP1). Similarly, when the APP1 main process calls the image rendering service, the image rendering service applies for streaming media memory (such as ION memory) through the graphics allocator (Graghic Allocator). Then, the electronic device establishes a linkage relationship between the main process of APP1 (or APP1) and the image rendering service, and counts the memory requested by the image rendering service to the main process of APP1 (or APP1).
在一些场景中,当系统的内存紧张时,APP1主进程也可能调用内核层的内存管理服务,压缩用户态匿名页数据,并申请用于存放压缩后的数据的内存(例如用于存放Zram压缩数据的内存)。那么,电子设备可以将内存管理服务本次申请的内存统计到APP1主进程(或APP1)。再类似的,APP1主进程也可能调用内核层的进程间通信(例如Binder)模块申请共享内存(例如Ashmem)。那么,电子设备将进程间通信模块本次申请的共享内存统计到APP1的主进程(或者APP1)。再类似的,APP1主进程调用内核层的内存业务模块申请其他内核内存(例如页表PT、Stack、Slab、Vmalloc)。那么,电子设备将内存业务模块本次申请的各种内核内存统计到APP1的主进程(或者APP1)。In some scenarios, when the system's memory is tight, the APP1 main process may also call the kernel layer's memory management service to compress the user-mode anonymous page data and apply for memory to store the compressed data (for example, to store Zram compression data memory). Then, the electronic device can count the memory applied for this time by the memory management service to the APP1 main process (or APP1). Similarly, the APP1 main process may also call the inter-process communication (such as Binder) module of the kernel layer to apply for shared memory (such as Ashmem). Then, the electronic device counts the shared memory applied for this time by the inter-process communication module to the main process of APP1 (or APP1). Similarly, the main process of APP1 calls the memory business module of the kernel layer to apply for other kernel memory (such as page table PT, Stack, Slab, Vmalloc). Then, the electronic device counts the various kernel memories applied for this time by the memory business module to the main process of APP1 (or APP1).
需要说明的是,电子设备这里维护的不同进程间的联动关系,除了这里用于将各个被调用进程申请的内存统计到源头进程外,后续电子设备在执行进程查杀时除了查杀选定的目标进程外,还可以将与目标进程具有联动关系的进程一并查杀,以回收更多的内存,提升系统的运行效率,后文将进行详细说明。It should be noted that the linkage relationship between different processes maintained by the electronic device here is used here to count the memory requested by each called process to the source process. When subsequent electronic devices perform process killing, in addition to killing the selected In addition to the target process, you can also kill processes that are linked to the target process to reclaim more memory and improve the operating efficiency of the system. This will be explained in detail later.
S303、当检测到电子设备的内存满足预设条件时,电子设备从该一个或多个APP启动的进程中确定目标进程。S303. When it is detected that the memory of the electronic device meets the preset conditions, the electronic device determines the target process from the processes started by the one or more APPs.
其中,电子设备的内存满足预设条件,即为电子设备执行进程查杀的触发条件。例如,电子设备的内存满足预设条件包括:电子设备的剩余内存量小于或等于阈值1;或者,电子设备中因内存分配不及时造成进程的阻塞时长大于或等于阈值2;或者,电子设备中第二类内存的总占用量大于或等于阈值3中的任一项。Among them, the memory of the electronic device meets the preset conditions, which is the trigger condition for the electronic device to execute process killing. For example, the memory of the electronic device that meets the preset conditions includes: the remaining memory amount of the electronic device is less than or equal to the threshold 1; or the blocking duration of the process in the electronic device due to untimely memory allocation is greater than or equal to the threshold 2; or the electronic device The total occupancy of the second type of memory is greater than or equal to any of threshold 3.
在一些实施例中,电子设备可以采用基于剩余内存量的水线触发机制来查杀进程。具体的,电子设备可以监测电子设备的剩余内存量,其中剩余内存是指可用内存,可以包括系统中空闲的内存,以及文件页、核心库文件和缓存数据占用的内存。当监测到剩余内存量小于或等于阈值1时,电子设备启动进程查杀流程。In some embodiments, the electronic device may use a waterline triggering mechanism based on the amount of remaining memory to kill processes. Specifically, the electronic device can monitor the amount of remaining memory of the electronic device, where the remaining memory refers to available memory, which can include free memory in the system, as well as memory occupied by file pages, core library files, and cached data. When it is detected that the remaining memory amount is less than or equal to the threshold 1, the electronic device starts the process killing process.
在电子设备启动进程查杀流程后,电子设备可以采用进程的使用频率与进程占用的内存量相结合的方式确定查杀的目标进程。例如,当电子设备启动查杀流程后,电子设备先采用例如LRU算法筛选出使用频率不高的进程作为候选进程,然后根据各个候选进程的内存占用量,从中选择内存占用量较大的候选进程作为目标进程,而后查杀目标进程,以释放目标进程占用的内存。After the electronic device starts the process checking and killing process, the electronic device can determine the target process for checking and killing by combining the usage frequency of the process and the amount of memory occupied by the process. For example, when the electronic device starts the killing process, the electronic device first uses, for example, the LRU algorithm to filter out processes that are not frequently used as candidate processes, and then selects the candidate process with a larger memory footprint based on the memory usage of each candidate process. As the target process, then kill the target process to release the memory occupied by the target process.
需要注意的是,各个候选进程的内存占用量包括第一类内存占用量和第二类内存占用量,也就是说,电子设备是基于各个候选进程占用的第一类内存和第二类内存的总占用量来确定目标进程的。It should be noted that the memory usage of each candidate process includes the first type of memory usage and the second type of memory usage. That is to say, the electronic device is based on the first type of memory and the second type of memory occupied by each candidate process. The total usage is used to determine the target process.
可选的,在电子设备运行的多个进程之间存在联动关联的场景中,这里各个候选进程的内存占用量还可以包括各个候选进程调用的其他进程申请的内存(也包括第一类内存和第二类内存)。进一步的,电子设备还可以根据目标进程,以及电子设备维 护的不同进程间的联动关系来确定目标进程调用的其他进程,并确定这些其他进程也为需要查杀的进程,即也为目标进程。可以理解的是,当目标进程被查杀后,如果目标进程调用的其他进程仅被目标进程所调用,那么这些其他进程也可以被查杀,这些其他进程占用的内存也可以被回收。这样,有利于进一步提升内存的利用率,提升系统的运行速率。当然,如果目标进程调用的其他进程还被其他非目标进程调用,则这些其他进程不能被查杀,以保证其他非目标进程的正常运行。Optionally, in a scenario where there is a linkage between multiple processes running on an electronic device, the memory usage of each candidate process may also include the memory requested by other processes called by each candidate process (also including the first type of memory and Type II memory). Furthermore, the electronic device can also be configured according to the target process and the electronic device maintenance Use the linkage relationship between different processes protected to determine other processes called by the target process, and determine that these other processes are also processes that need to be killed, that is, they are also target processes. It is understandable that after the target process is checked and killed, if other processes called by the target process are only called by the target process, then these other processes can also be checked and killed, and the memory occupied by these other processes can also be recycled. This will help further improve memory utilization and improve the system's operating speed. Of course, if other processes called by the target process are also called by other non-target processes, these other processes cannot be killed to ensure the normal operation of other non-target processes.
例如,请继续参考图5,若确定APP1的主进程为目标进程后,除了查杀APP1的主进程回收APP1的主进程申请的内存外,若APP1调用的音视频服务以及图像渲染服务均没有被其他应用的进程调用,那么也可以确定音视频服务以及图像渲染服务也为目标进程。那么,电子设备也查杀音视频服务以及图像渲染服务,回收音视频服务以及图像渲染服务占用的流媒体内存(如ION内存)。可以理解的,通常流媒体内存的占用量较大。那么,查杀音视频服务以及图像渲染服务,将回收这部分流媒体内存,更有利于提高进程查杀的收益,维持系统运行的稳定性和流畅性。For example, please continue to refer to Figure 5. If the main process of APP1 is determined to be the target process, in addition to killing the main process of APP1 and reclaiming the memory requested by the main process of APP1, if the audio and video services and image rendering services called by APP1 have not been If the process calls of other applications, it can also be determined that the audio and video service and image rendering service are also target processes. Then, the electronic device also kills the audio and video services and image rendering services, and recovers the streaming media memory (such as ION memory) occupied by the audio and video services and image rendering services. It is understandable that streaming media usually takes up a large amount of memory. Then, the audio and video killing service and image rendering service will recycle this part of the streaming media memory, which is more conducive to increasing the benefits of process killing and maintaining the stability and smoothness of system operation.
在另一些实施例中,电子设备也可以采用基于压力阻塞信息(Pressure Stall Information,PSI)的触发机制来查杀进程。具体的,电子设备可以监测电子设备上各个进程运行时因内存分配不及时造成的阻塞时长,即进程等待分配内存的时长。当监测到进程的阻塞时长大于或等于阈值2时,启动进程查杀流程。需要说明的是,该实施例与上一个实施例的区别在于启动进程查杀流程的触发条件不同,电子设备具体执行进程查杀方法与上一个实施例相同,这里不再赘述。In other embodiments, the electronic device may also use a triggering mechanism based on Pressure Stall Information (PSI) to kill the process. Specifically, the electronic device can monitor the blocking time caused by untimely memory allocation when each process on the electronic device is running, that is, the time the process waits for memory allocation. When it is detected that the blocking time of the process is greater than or equal to the threshold 2, the process killing process is started. It should be noted that the difference between this embodiment and the previous embodiment is that the triggering conditions for initiating the process checking and killing process are different. The specific method for the electronic device to perform process checking and killing is the same as the previous embodiment, and will not be described again here.
在又一些实施例中,电子设备还可以采用基于第二类内存占用量的水线触发机制来查杀进程。具体的,电子设备可以监测电子设备中第二类内存的总占用量。当监测到第二类内存的总占用量大于或等于阈值3时,电子设备启动进程查杀流程。需要说明的是,该实施例与上述实施例的区别在于启动进程查杀流程的触发条件不同,电子设备具体执行进程查杀方法与上述实施例相同,这里不再赘述。In some embodiments, the electronic device can also use a waterline triggering mechanism based on the second type of memory usage to kill the process. Specifically, the electronic device can monitor the total occupied amount of the second type of memory in the electronic device. When it is detected that the total occupied amount of the second type of memory is greater than or equal to the threshold 3, the electronic device starts the process killing process. It should be noted that the difference between this embodiment and the above-mentioned embodiment is that the triggering conditions for initiating the process checking and killing process are different. The specific method of executing process checking and killing by the electronic device is the same as that in the above-mentioned embodiment, and will not be described again here.
此外,该实施例提供了一种从监测第二类内存占用量的角度监测电子设备的内存占用情况的方法。在电子设备真实的使用过程中,第二类内存占用量通常较大,是造成电子设备内存紧张的主要原因之一,因此,从监测第二类内存占用量的角度确定启动进程查杀流程,能够更准确地监测电子设备的内存占用情况,更有利于从根本上解决电子设备因第二类内存占用量高造成内存压力大、系统运行缓慢等的问题。另外,由于本实施例实现了回收第二类内存的功能,有效地减少了第二类内存的占用量,有利于系统的可用内存长时间处于一个较高的阈值,保证系统运行稳定和流畅性。In addition, this embodiment provides a method for monitoring the memory usage of an electronic device from the perspective of monitoring the second type of memory usage. In the actual use of electronic devices, the second type of memory occupancy is usually large, which is one of the main reasons for the memory shortage of electronic devices. Therefore, the startup process killing process is determined from the perspective of monitoring the second type of memory occupancy. Being able to more accurately monitor the memory usage of electronic devices is more conducive to fundamentally solving the problems of high memory pressure and slow system operation caused by high second-type memory usage of electronic devices. In addition, since this embodiment realizes the function of recycling the second type of memory, it effectively reduces the occupation of the second type of memory, which helps the system's available memory to stay at a higher threshold for a long time, ensuring the stability and smoothness of the system operation. .
还需要说明的是,上述各个实施例提供的方法在方案本身不矛盾的情况下可以组合使用,或者将上述实施例提供的方法与现有技术组合使用。例如,电子设备可以同时采用基于剩余内存量的水线触发机制和基于第二类内存占用量的水线触发机制。当监测到电子设备的剩余内存量小于或等于阈值1时,启动进程的查杀流程。这里的进程查杀方法可以采用现有技术,也可以采用本申请实施例提供的进程查杀方法。当监测到电子设备的第二类内存的占用量大于或等于阈值3时,也启动进程的查杀流程。可以理解的是,由于电子设备采用基于第二类内存占用量水线的触发机制,并且电子设备在执行进程的查杀流程时,回收了更多的第二类内存,有利于电子设备的剩余内 存量长时间处于一个较高的阈值,那么也降低了电子设备采用基于电子设备剩余内存量水线的触发机制触发的进程查杀的频率,降低了因电子设备执行进程查杀流程所消耗的系统资源,如CPU资源,内存资源等。It should also be noted that the methods provided by the above embodiments can be used in combination if the solutions themselves are not inconsistent, or the methods provided by the above embodiments can be used in combination with existing technologies. For example, the electronic device may simultaneously adopt a watermark triggering mechanism based on the amount of remaining memory and a watermark triggering mechanism based on the second type of memory usage. When it is detected that the remaining memory of the electronic device is less than or equal to the threshold 1, the process of killing the process is started. The process checking and killing method here may adopt existing technology, or may adopt the process checking and killing method provided by the embodiments of this application. When it is detected that the occupation of the second type of memory of the electronic device is greater than or equal to the threshold 3, the process of killing the process is also started. It is understandable that since the electronic device adopts a trigger mechanism based on the second-type memory usage waterline, and the electronic device recycles more second-class memory when executing the scanning and killing process of the process, it is conducive to the remaining memory of the electronic device. Inside If the inventory is at a high threshold for a long time, it also reduces the frequency of process killing triggered by electronic devices using a trigger mechanism based on the remaining memory waterline of the electronic device, and reduces the system consumption of electronic devices executing the process killing process. Resources, such as CPU resources, memory resources, etc.
S304、电子设备查杀目标进程。S304. Check and kill the target process of the electronic device.
电子设备针对确定好的目标进程进行查杀,回收目标进程占用的第一类内存和第二类内存。更具体的,电子设备的内核层查杀目标进程后,向上层通知已查杀目标进程,框架层在接收该通知信息后,进一步清理目标进程关联的组件,进一步释放组件所占用的内存。The electronic device scans and kills the determined target process, and reclaims the first type of memory and the second type of memory occupied by the target process. More specifically, after the kernel layer of the electronic device kills the target process, it notifies the upper layer that the target process has been killed. After receiving the notification information, the framework layer further cleans up the components associated with the target process and further releases the memory occupied by the components.
综上,由于通过该方法回收的第一类内存和第二类内存在整机内存的占比较高,有利于使得电子设备的可用内存维持在一个较高的数值上,有利于提升电子设备运行的流畅度和稳定性。In summary, since the first type of memory and the second type of memory recovered through this method account for a high proportion of the entire machine's memory, it is conducive to maintaining the available memory of the electronic device at a higher value, which is conducive to improving the operation of the electronic device. fluency and stability.
另外,由于本申请实施例提供的进程查杀方法的收益更大,有利于使得电子设备的可用内存维持在一个较高的数值上,降低了电子设备执行进程查杀流程的频率,降低了因电子设备执行进程查杀流程所消耗的系统资源,如CPU资源,内存资源等。In addition, because the process checking and killing method provided by the embodiment of the present application has greater benefits, it is conducive to maintaining the available memory of the electronic device at a higher value, reducing the frequency of the electronic device executing the process checking and killing process, and reducing the cost of the process. The system resources consumed by electronic devices when executing process killing processes, such as CPU resources, memory resources, etc.
在另外一些实施例中,考虑到上述方法在选择目标进程时,可能将一些优先级较高或系统级的进程确定为目标进程。为了保证系统运行的稳定性,或者保证用户的使用体验,在查杀目标进程的过程中,识别目标进程中的关键组件(即关键组件中的信息影响系统的稳定性或者影响用户的使用体验),并保留目标进程中的关键组件。后续在重新启动目标进程(或者重启目标进程对应的APP)时,可以直接利用保留的关键组件恢复目标进程,保证系统运行的稳定性或者保证用户的使用体验。In some other embodiments, when considering the above method when selecting a target process, some processes with higher priority or system level may be determined as the target process. In order to ensure the stability of the system operation or ensure the user experience, during the process of killing the target process, the key components in the target process are identified (that is, the information in the key components affects the stability of the system or the user experience) , and preserve key components in the target process. Later, when the target process is restarted (or the APP corresponding to the target process is restarted), the retained key components can be directly used to restore the target process to ensure the stability of the system operation or the user experience.
如图6所示,为本申请实施例提供的又一种应用程序的进程查杀方法的流程示意图,该流程包括:As shown in Figure 6, it is a schematic flowchart of another method for detecting and killing an application process provided by an embodiment of the present application. The process includes:
S601、监测电子设备的第二类内存的占用量是否大于或等于阈值3。若监测到电子设备的第二类内存的占用量大于或等于阈值3,执行步骤S602。S601. Monitor whether the occupancy of the second type of memory of the electronic device is greater than or equal to threshold 3. If it is detected that the occupancy of the second type of memory of the electronic device is greater than or equal to threshold 3, step S602 is executed.
可以理解的是,这里以电子设备的第二类内存的占用量大于或等于阈值3作为电子设备执行进程查杀的触发条件为例进行说明的,在其他一些实施例中,电子设备也可以采用其他的触发条件,这里不再一一赘述。It can be understood that here, the occupancy of the second type of memory of the electronic device is greater than or equal to the threshold 3 as the trigger condition for the electronic device to execute process killing. In some other embodiments, the electronic device may also adopt Other triggering conditions will not be described here.
在一个具体的实现中,内核层(例如更具体的为内核层的内存统计模块)监测电子设备的第二类内存的占用量是否大于或等于阈值3。In a specific implementation, the kernel layer (for example, more specifically, the memory statistics module of the kernel layer) monitors whether the occupation amount of the second type of memory of the electronic device is greater than or equal to the threshold 3.
S602、统计各个进程的内存占用量,各个进程的内存占用量包括第一类内存和第二类内存的总占用量。S602. Count the memory usage of each process. The memory usage of each process includes the total usage of the first type of memory and the second type of memory.
可以理解的,在其他一些实施例中,电子设备也可以在执行步骤S601的同时或者执行步骤S601之前,就开始实时统计各个进程的内存占用量。在一个具体的实现中,内核层(例如更具体的为内核层的内存统计模块)用于统计各个进程的内存占用量。It can be understood that in some other embodiments, the electronic device may also start to count the memory usage of each process in real time while executing step S601 or before executing step S601. In a specific implementation, the kernel layer (for example, more specifically, the memory statistics module of the kernel layer) is used to count the memory usage of each process.
本步骤的其他内容可以参考上述步骤S302中的相关内容,这里不再赘述。For other contents of this step, please refer to the relevant contents in the above-mentioned step S302, which will not be described again here.
S603、选择目标进程。S603. Select the target process.
在一些实施例中,电子设备可以采用进程的使用频率与进程占用的内存量相结合的方式确定查杀的目标进程。具体选择目标进程的方法可以参考上述步骤S302中的相关内容,这里不再赘述。在一个具体的实现中,内核层(例如更具体的为内核层的内 存统计模块)用于根据统计的各个进程的内存占用量,选择目标进程。In some embodiments, the electronic device may determine the target process for scanning and killing by combining the usage frequency of the process and the amount of memory occupied by the process. For the specific method of selecting the target process, please refer to the relevant content in the above step S302, which will not be described again here. In a specific implementation, the kernel layer (for example, more specifically, the inner layer of the kernel layer The memory statistics module) is used to select the target process based on the statistical memory usage of each process.
S604、查杀目标进程。S604. Check and kill the target process.
在一个具体的实现中,内核层(例如更具体的为内核层的进程查杀模块)用于查杀目标进程。In a specific implementation, the kernel layer (for example, more specifically, the process killing module of the kernel layer) is used to kill the target process.
S605、判断目标进程关联的组件是否为关键组件。如果是关键组件,则执行步骤S606。如果不是关键组件,则执行步骤S607。S605. Determine whether the component associated with the target process is a critical component. If it is a key component, perform step S606. If it is not a critical component, perform step S607.
其中,关键组件是指包含关键信息的组件。其中关键信息包括目标进程运行时会影响系统运行稳定性,或者影响到用户的使用体验的信息。可以理解的是,目标进程运行时的一些临时数据会存储在组件中。如果在查杀目标进程后,将目标进程关联的组件直接清理,那么会丢失这部分临时数据。如果临时数据中包含关键信息,那么势必会影响再次启动目标进程,目标进程运行的稳定性或者影响用户的使用体验。例如,关键组件可以包括系统运行时一些常驻功能的信息,如电子设备负一屏的信息,杂志锁屏的信息,息屏显示的信息,天气widget的信息等。又例如,关键组件可以包括电子文档的阅读进度信息,而电子文档的阅读进度信息会影响到用户阅读电子文档时的使用体验。Among them, key components refer to components that contain key information. The key information includes information that will affect the stability of the system when the target process is running, or affect the user experience. It is understandable that some temporary data while the target process is running will be stored in the component. If you clean up the components associated with the target process directly after killing the target process, this part of the temporary data will be lost. If the temporary data contains critical information, it will inevitably affect the restart of the target process, the stability of the target process, or the user experience. For example, key components may include information about some permanent functions when the system is running, such as information about the electronic device's negative screen, magazine lock screen information, information displayed on the active screen, weather widget information, etc. For another example, the key component may include the reading progress information of the electronic document, and the reading progress information of the electronic document will affect the user's experience when reading the electronic document.
因此,电子设备在清理目标进程关联的组件时,会首先判断目标进程关联的组件中是否包含关键组件。针对关键组件,保留关键组件的信息,或者保留关键组件中的关键信息,即执行步骤S606。针对非关键组件,清理非关联组件,即执行步骤S607。Therefore, when the electronic device cleans the components associated with the target process, it will first determine whether the components associated with the target process contain key components. For key components, retain the information of the key components, or retain the key information in the key components, that is, perform step S606. For non-critical components, clean up non-associated components, that is, perform step S607.
在一个具体的实现中,内核层(例如更具体的为内核层的进程查杀模块)查杀目标进程后,向上层通知已查杀目标进程。框架层(例如更具体的为框架层的组件清理模块)判断目标进程关联的组件是否为关键组件,并进一步保留关键组件,清理非关键组件。In a specific implementation, after the kernel layer (for example, the process killing module of the kernel layer) kills the target process, it notifies the upper layer that the target process has been killed. The framework layer (for example, more specifically, the component cleaning module of the framework layer) determines whether the components associated with the target process are critical components, and further retains the critical components and cleans the non-critical components.
S606、保存关键组件的信息。S606. Save the information of key components.
在清理目标进程关联的组件前,解耦关键组件与目标进程,修改关键组件的运行状态,以实现保存关键组件的信息。Before cleaning up the components associated with the target process, decouple the key components from the target process and modify the running status of the key components to save the information of the key components.
在其他一些实施例中,电子设备还可以修改关键组件的生命周期,以实现保留关键组件的信息。In some other embodiments, the electronic device can also modify the life cycle of key components to retain information about key components.
S607、清理非关键组件。S607. Clean up non-critical components.
由此,实现保留目标进程关联的关键组件的信息,以便电子设备后续可以恢复关键组件的信息,维持系统运行的稳定性,以及提供用户的使用体验。As a result, the information of key components associated with the target process is retained, so that the electronic device can subsequently restore the information of key components, maintain the stability of system operation, and provide user experience.
如图7所示,为本申请实施例提供的一种恢复目标进程的方法的流程示意图,该流程包括:As shown in Figure 7, it is a schematic flowchart of a method for restoring a target process provided by an embodiment of the present application. The process includes:
S701、调用组件。S701. Call the component.
示例性的,APP重新启动后,APP的主进程(或者其他进程,例如主进程调用的其他进程)可以调用框架层中的组件,以实现相应功能。或者,APP未退出,APP的主进程(或者其他进程,例如主进程调用的其他进程)需要再次调用框架层中的组件,以实现相应功能。For example, after the APP is restarted, the main process of the APP (or other processes, such as other processes called by the main process) can call components in the framework layer to implement corresponding functions. Or, the APP does not exit, and the APP's main process (or other processes, such as other processes called by the main process) needs to call the components in the framework layer again to implement the corresponding functions.
S702、判断调用的组件是否为可恢复的关键组件。如是,执行步骤S703,如否,执行步骤S706。 S702. Determine whether the called component is a recoverable key component. If yes, execute step S703; if not, execute step S706.
示例性的,APP的主进程(或者其他进程,例如主进程调用的其他进程)可以查询组件的记录,判断待调用的组件是否为可恢复的关键组件。即,电子设备是否保存有待调用的组件的信息。如果确定待调用的组件为可恢复的关键组件,则可以使用电子设备保留的关键组件的信息恢复该组件,即执行步骤S703-步骤S705。如果确定待调用的组件不是可恢复的关键组件,则采用系统原生流程,即执行步骤S706-步骤S709。For example, the main process of the APP (or other processes, such as other processes called by the main process) can query the component records to determine whether the component to be called is a recoverable key component. That is, whether the electronic device saves information about the component to be called. If it is determined that the component to be called is a recoverable key component, the component can be recovered using the information of the key component retained by the electronic device, that is, steps S703 to S705 are performed. If it is determined that the component to be called is not a recoverable critical component, the system's native process is adopted, that is, steps S706 to S709 are executed.
S703、创建进程。S703. Create a process.
由于组件的运行需要依托进程才能运行,因此电子设备创建一个新的进程,用于运行该组件。Since the component needs to rely on a process to run, the electronic device creates a new process for running the component.
S704、建立进程和组件的关联关系。S704. Establish an association between processes and components.
S705、运行组件。S705. Run the component.
本流程结束。This process ends.
S706、判断是否需要创建组件。如否,执行步骤S707。如是,执行步骤S708,S706. Determine whether a component needs to be created. If not, execute step S707. If so, execute step S708,
示例性的,在调用之前查询电子设备是否运行有该组件。如果电子设备没有运行该组件,则需要创建该组件,即执行步骤S707。如果电子设备有运行该组件,则无需再次创建组件,即执行步骤S708。For example, before calling, query whether the electronic device runs the component. If the electronic device does not run the component, the component needs to be created, that is, step S707 is performed. If the electronic device runs the component, there is no need to create the component again, and step S708 is executed.
S707、判断是否需要创建新进程。如是,执行步骤S703。S707. Determine whether a new process needs to be created. If so, execute step S703.
S708、创建组件。S708. Create a component.
S709、判断是否有现有进程可以承接创建的组件。如有,则执行步骤S704。如果没有,则执行步骤S703。S709. Determine whether there is an existing process that can take over the created component. If yes, execute step S704. If not, execute step S703.
本申请实施例还提供一种芯片系统,如图8所示,该芯片系统包括至少一个处理器1101和至少一个接口电路1102。处理器1101和接口电路1102可通过线路互联。例如,接口电路1102可用于从其它装置(例如电子设备100的存储器)接收信号。又例如,接口电路1102可用于向其它装置(例如处理器1101)发送信号。示例性的,接口电路1102可读取存储器中存储的指令,并将该指令发送给处理器1101。当所述指令被处理器1101执行时,可使得电子设备执行上述实施例中的电子设备100(比如,手机)执行的各个步骤。当然,该芯片系统还可以包含其他分立器件,本申请实施例对此不作具体限定。An embodiment of the present application also provides a chip system. As shown in FIG. 8 , the chip system includes at least one processor 1101 and at least one interface circuit 1102 . The processor 1101 and the interface circuit 1102 may be interconnected by wires. For example, interface circuitry 1102 may be used to receive signals from other devices, such as the memory of electronic device 100 . As another example, interface circuit 1102 may be used to send signals to other devices (eg, processor 1101). For example, the interface circuit 1102 can read instructions stored in the memory and send the instructions to the processor 1101. When the instructions are executed by the processor 1101, the electronic device can be caused to perform various steps performed by the electronic device 100 (such as a mobile phone) in the above embodiments. Of course, the chip system may also include other discrete devices, which are not specifically limited in the embodiments of this application.
本申请实施例还提供一种装置,该装置包含在电子设备中,该装置具有实现上述实施例中任一方法中电子设备行为的功能。该功能可以通过硬件实现,也可以通过硬件执行相应的软件实现。硬件或软件包括至少一个与上述功能相对应的模块或单元。例如,检测模块或单元、统计模块或单元、确定模块或单元、以及查杀模块或单元等。An embodiment of the present application also provides a device, which is included in an electronic device and has the function of realizing the behavior of the electronic device in any of the methods in the above embodiments. This function can be implemented by hardware, or it can be implemented by hardware executing corresponding software. The hardware or software includes at least one module or unit corresponding to the above functions. For example, detection module or unit, statistical module or unit, determination module or unit, and killing module or unit, etc.
本申请实施例还提供一种计算机存储介质,包括计算机指令,当计算机指令在电子设备上运行时,使得电子设备执行如上述实施例中任一方法。Embodiments of the present application also provide a computer storage medium that includes computer instructions. When the computer instructions are run on an electronic device, the electronic device causes the electronic device to perform any of the methods in the above embodiments.
本申请实施例还提供一种计算机程序产品,当计算机程序产品在计算机上运行时,使得计算机执行如上述实施例中任一方法。Embodiments of the present application also provide a computer program product. When the computer program product is run on a computer, it causes the computer to perform any of the methods in the above embodiments.
可以理解的是,上述电子设备等为了实现上述功能,其包含了执行各个功能相应的硬件结构和/或软件模块。本领域技术人员应该很容易意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,本申请实施例能够以硬件或硬件和计算机软件的结合形式来实现。某个功能究竟以硬件还是计算机软件驱动硬件的方式来执行, 取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本发明实施例的范围。It can be understood that, in order to implement the above functions, the above-mentioned electronic devices include hardware structures and/or software modules corresponding to each function. Persons skilled in the art should easily realize that, in conjunction with the units and algorithm steps of each example described in the embodiments disclosed herein, the embodiments of the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a certain function is executed by hardware or by computer software driving the hardware? Depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementations should not be considered to be beyond the scope of the embodiments of the present invention.
本申请实施例可以根据上述方法示例对上述电子设备等进行功能模块的划分,例如,可以对应各个功能划分各个功能模块,也可以将两个或两个以上的功能集成在一个处理模块中。上述集成的模块既可以采用硬件的形式实现,也可以采用软件功能模块的形式实现。需要说明的是,本发明实施例中对模块的划分是示意性的,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式。Embodiments of the present application can divide the above-mentioned electronic equipment into functional modules according to the above-mentioned method examples. For example, each functional module can be divided corresponding to each function, or two or more functions can be integrated into one processing module. The above integrated modules can be implemented in the form of hardware or software function modules. It should be noted that the division of modules in the embodiment of the present invention is schematic and is only a logical function division. In actual implementation, there may be other division methods.
通过以上的实施方式的描述,所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,仅以上述各功能模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能模块完成,即将装置的内部结构划分成不同的功能模块,以完成以上描述的全部或者部分功能。上述描述的系统,装置和单元的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。Through the above description of the embodiments, those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above functional modules is used as an example. In actual applications, the above functions can be allocated as needed. It is completed by different functional modules, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. For the specific working processes of the systems, devices and units described above, reference can be made to the corresponding processes in the foregoing method embodiments, which will not be described again here.
在本申请实施例各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。Each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically alone, or two or more units may be integrated into one unit. The above integrated units can be implemented in the form of hardware or software functional units.
所述集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请实施例的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)或处理器执行本申请各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:快闪存储器、移动硬盘、只读存储器、随机存取存储器、磁碟或者光盘等各种可以存储程序代码的介质。If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it may be stored in a computer-readable storage medium. Based on this understanding, the technical solutions of the embodiments of the present application are essentially or contribute to the existing technology, or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage device. The medium includes several instructions to cause a computer device (which may be a personal computer, a server, or a network device, etc.) or a processor to execute all or part of the steps of the methods described in various embodiments of this application. The aforementioned storage media include: flash memory, mobile hard disk, read-only memory, random access memory, magnetic disk or optical disk and other media that can store program codes.
以上所述,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何在本申请揭露的技术范围内的变化或替换,都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应以所述权利要求的保护范围为准。 The above are only specific embodiments of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions within the technical scope disclosed in the present application shall be covered by the protection scope of the present application. . Therefore, the protection scope of this application should be subject to the protection scope of the claims.

Claims (11)

  1. 一种应用程序的进程查杀方法,其特征在于,所述方法包括:A method for checking and killing application processes, characterized in that the method includes:
    电子设备运行一个或多个应用APP;The electronic device runs one or more applications;
    所述电子设备统计所述一个或多个APP启动的各个进程占用的第一类内存和第二类内存,其中所述第一类内存包括文件页占用内存,核心库文件占用内存,缓存数据占用内存,以及用户态匿名页占用内存中一项或多项;第二类内存包括流媒体占用内存以及内核占用内存中一项或多项;The electronic device counts the first type of memory and the second type of memory occupied by each process started by the one or more APPs, wherein the first type of memory includes the memory occupied by file pages, the memory occupied by core library files, and the memory occupied by cached data. Memory, and one or more items in the memory occupied by user-mode anonymous pages; the second type of memory includes one or more items in the memory occupied by streaming media and the memory occupied by the kernel;
    当检测到所述电子设备的内存满足预设条件时,所述电子设备根据所述各个进程占用的所述第一类内存和所述第二类内存,从所述一个或多个APP启动的进程中确定目标进程;When it is detected that the memory of the electronic device meets the preset conditions, the electronic device starts from the one or more APPs according to the first type of memory and the second type of memory occupied by the respective processes. Determine the target process in the process;
    所述电子设备查杀所述目标进程。The electronic device checks and kills the target process.
  2. 根据权利要求1所述的方法,其特征在于,The method according to claim 1, characterized in that:
    所述电子设备的内存满足预设条件包括:所述电子设备的剩余内存量小于或等于第一阈值,所述电子设备中因内存分配不及时造成进程的阻塞时长大于或等于第二阈值,所述电子设备中所述第二类内存的总占用量大于或等于第三阈值中的任一项。The memory of the electronic device meeting the preset conditions includes: the remaining memory amount of the electronic device is less than or equal to the first threshold, and the blocking duration of the process in the electronic device due to untimely memory allocation is greater than or equal to the second threshold, so The total occupied amount of the second type of memory in the electronic device is greater than or equal to any one of the third thresholds.
  3. 根据权利要求1或2所述的方法,其特征在于,The method according to claim 1 or 2, characterized in that,
    第一进程占用的第一类内存和第二类内存包括所述第一进程所调用的第二进程占用的第一类内存和/或第二类内存;其中所述第一进程为所述一个或多个APP启动的进程中的任一个,且所述第二进程不被除所述第一进程之外的其他进程所调用。The first type of memory and the second type of memory occupied by the first process include the first type of memory and/or the second type of memory occupied by the second process called by the first process; wherein the first process is the one or any one of the processes started by multiple APPs, and the second process is not called by other processes except the first process.
  4. 根据权利要求3所述的方法,其特征在于,The method according to claim 3, characterized in that:
    所述电子设备根据所述各个进程占用的所述第一类内存和所述第二类内存,从所述一个或多个APP启动的进程中确定目标进程,包括:所述电子设备确定所述第一进程为所述目标进程后,确定所述第二进程也为所述目标进程。The electronic device determines a target process from the processes started by the one or more APPs according to the first type of memory and the second type of memory occupied by each process, including: the electronic device determines the After the first process is the target process, it is determined that the second process is also the target process.
  5. 根据权利要求1-4任一项所述的方法,其特征在于,在所述电子设备查杀所述目标进程之后,所述方法还包括:The method according to any one of claims 1 to 4, characterized in that, after the electronic device kills the target process, the method further includes:
    所述电子设备确定所述目标进程关联的第一组件是否为关键组件;其中所述关键组件为包含关键信息的组件,所述关键信息包括所述目标进程运行时会影响系统运行稳定性或者影响到用户的使用体验的信息;The electronic device determines whether the first component associated with the target process is a key component; wherein the key component is a component that contains key information, and the key information includes whether the target process will affect system operation stability or affect system operation stability when running. Information about the user’s experience;
    若确定所述第一组件为所述关键组件,则所述电子设备保留所述第一组件的信息;若确定所述第一组件不为所述关键组件,则所述电子设备清理所述第一组件的信息。If it is determined that the first component is the critical component, the electronic device retains the information of the first component; if it is determined that the first component is not the critical component, the electronic device clears the third component. Information about a component.
  6. 根据权利要求5所述的方法,其特征在于,所述关键信息包括负一屏的信息,杂志锁屏的信息,息屏显示的信息,天气widget的信息,电子文档的阅读进度信息中一项或多项。The method according to claim 5, wherein the key information includes one of negative screen information, magazine lock screen information, interest screen display information, weather widget information, and electronic document reading progress information. or multiple items.
  7. 根据权利要求5或6所述的方法,其特征在于,在所述电子设备查杀所述目标进程后,在所述电子设备保留所述第一组件的信息之后,所述方法还包括:The method according to claim 5 or 6, characterized in that, after the electronic device kills the target process and after the electronic device retains the information of the first component, the method further includes:
    所述电子设备调用所述第一组件;The electronic device calls the first component;
    当查询到所述电子设备保留有所述第一组件的信息后,所述电子设备启动第三进程;After querying that the electronic device retains information about the first component, the electronic device starts a third process;
    所述电子设备根据保留的所述第一组件的信息,建立所述第三进程和所述第一组 件关联关系。The electronic device establishes the third process and the first group according to the retained information of the first component. Piece relationships.
  8. 一种电子设备,其特征在于,包括:处理器和存储器,所述存储器与所述处理器耦合,所述存储器用于存储计算机程序代码,所述计算机程序代码包括计算机指令,所述处理器从所述存储器中读取所述计算机指令,以使得所述电子设备执行如权利要求1-7中任一项所述的应用程序的进程查杀方法。An electronic device, characterized by comprising: a processor and a memory, the memory being coupled to the processor, the memory being used to store computer program code, the computer program code including computer instructions, the processor from The computer instructions are read from the memory to cause the electronic device to execute the process checking and killing method of an application program according to any one of claims 1-7.
  9. 一种计算机可读存储介质,其特征在于,包括计算机指令,当所述计算机指令在电子设备上运行时,使得所述电子设备执行如权利要求1-7中任一项所述的应用程序的进程查杀方法。A computer-readable storage medium, characterized in that it includes computer instructions that, when the computer instructions are run on an electronic device, cause the electronic device to execute the application program according to any one of claims 1-7. Process killing method.
  10. 一种芯片系统,其特征在于,包括一个或多个处理器,当所述一个或多个处理器执行指令时,所述一个或多个处理器执行如权利要求1-7中任一项所述的应用程序的进程查杀方法。A chip system, characterized in that it includes one or more processors. When the one or more processors execute instructions, the one or more processors execute the method according to any one of claims 1-7. The process killing method of the application mentioned above.
  11. 一种计算机程序产品,其特征在于,当所述计算机程序产品在电子设备上运行时,使得所述电子设备执行如权利要求1-7中任一项所述的应用程序的进程查杀方法。 A computer program product, characterized in that, when the computer program product is run on an electronic device, it causes the electronic device to execute the process checking and killing method of an application program according to any one of claims 1-7.
PCT/CN2023/083751 2022-04-01 2023-03-24 Process killing method for application, and electronic device WO2023185684A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202210339419.4A CN116933254A (en) 2022-04-01 2022-04-01 Process checking and killing method of application program and electronic equipment
CN202210339419.4 2022-04-01

Publications (1)

Publication Number Publication Date
WO2023185684A1 true WO2023185684A1 (en) 2023-10-05

Family

ID=88199335

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2023/083751 WO2023185684A1 (en) 2022-04-01 2023-03-24 Process killing method for application, and electronic device

Country Status (2)

Country Link
CN (1) CN116933254A (en)
WO (1) WO2023185684A1 (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104866548A (en) * 2015-05-08 2015-08-26 深圳市金立通信设备有限公司 Memory management method
US20160378587A1 (en) * 2015-06-25 2016-12-29 Emc Corporation Detecting unresponsiveness of a process
CN109857555A (en) * 2019-01-15 2019-06-07 Oppo广东移动通信有限公司 Method for recovering internal storage and device, storage medium and electronic equipment
CN111611020A (en) * 2020-04-14 2020-09-01 上海卓易科技股份有限公司 Application process searching and killing method and device for application program
CN111831441A (en) * 2020-07-01 2020-10-27 Oppo广东移动通信有限公司 Memory recovery method and device, storage medium and electronic equipment

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104866548A (en) * 2015-05-08 2015-08-26 深圳市金立通信设备有限公司 Memory management method
US20160378587A1 (en) * 2015-06-25 2016-12-29 Emc Corporation Detecting unresponsiveness of a process
CN109857555A (en) * 2019-01-15 2019-06-07 Oppo广东移动通信有限公司 Method for recovering internal storage and device, storage medium and electronic equipment
CN111611020A (en) * 2020-04-14 2020-09-01 上海卓易科技股份有限公司 Application process searching and killing method and device for application program
CN111831441A (en) * 2020-07-01 2020-10-27 Oppo广东移动通信有限公司 Memory recovery method and device, storage medium and electronic equipment

Also Published As

Publication number Publication date
CN116933254A (en) 2023-10-24

Similar Documents

Publication Publication Date Title
CN111966492B (en) Memory recycling method and device, electronic equipment and computer readable storage medium
WO2022257748A1 (en) Virtual memory management method and electronic device
WO2023202429A1 (en) Garbage recycling method and electronic device
WO2021093626A1 (en) Memory management method and electronic device
CN115292199B (en) Video memory leakage processing method and related device
US20230385112A1 (en) Memory Management Method, Electronic Device, and Computer-Readable Storage Medium
WO2021185352A1 (en) Version upgrade method and related apparatus
CN114185494A (en) Memory anonymous page processing method, electronic device and readable storage medium
CN115016631B (en) Process scheduling method and terminal equipment
EP4095723A1 (en) Permission reuse method, permission reuse-based resource access method, and related device
CN111381996B (en) Memory exception handling method and device
WO2023185684A1 (en) Process killing method for application, and electronic device
WO2019128542A1 (en) Application processing method, electronic device, computer readable storage medium
CN114253737B (en) Electronic device, memory recovery method thereof and medium
WO2021218370A1 (en) Memory management method and terminal device
CN117130824A (en) Method for processing exception, electronic equipment and storage medium
CN114461589B (en) Method for reading compressed file, file system and electronic equipment
CN112783418B (en) Method for storing application program data and mobile terminal
WO2020147859A1 (en) Decentralized fat lock deflation
CN116126744B (en) Memory recycling method and device and terminal equipment
WO2023202406A1 (en) Display method and electronic device
WO2023231900A1 (en) Memory management method and related apparatus
CN115934302A (en) Memory leak processing method and electronic equipment
CN117130947A (en) Memory management method and electronic equipment
CN115981573A (en) Data management method, electronic device and computer readable and writable storage medium

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 23778052

Country of ref document: EP

Kind code of ref document: A1