Memory leak detection method and electronic device

By detecting memory leaks in DSP processes in electronic devices and performing corresponding operations, the problem of reduced efficiency and increased power consumption caused by memory leaks is solved, efficient detection and processing is achieved, and the risk of device crash is reduced.

CN117687820BActive Publication Date: 2024-10-15HONOR DEVICE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310734426.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-06-20
Publication Date
2024-10-15
Estimated Expiration
2043-06-20

AI Technical Summary

Technical Problem

In electronic devices, memory leaks reduce the efficiency of processing tasks, affect the computing efficiency of application processors, and may even cause device crashes. It is difficult for existing technologies to efficiently detect and handle memory leaks in DSPs, and frequent calls to memory query interfaces increase power consumption. .

Method used

By introducing a memory leak detection method into electronic devices, the application processor is used to send memory leak detection instructions to the digital signal processor to obtain the memory occupation information of the process, determine the memory leak and perform corresponding operations, such as restarting the process or grabbing memory application information. Log, reducing power consumption while providing diversified processing methods.

Benefits of technology

It achieves efficient detection and processing of process memory leaks in DSP, reduces the power consumption of electronic devices, and avoids the risk of memory waste and device performance degradation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117687820B_ABST
    Figure CN117687820B_ABST
Patent Text Reader

Abstract

The present application provides a memory leak detection method and an electronic device, the method comprising: a DSP in an electronic device runs one or more processes, wherein the one or more processes include a first process. An AP in the electronic device sends a memory leak detection instruction to the DSP. When the DSP receives the memory leak detection instruction, the DSP obtains the memory occupancy information of the first process. When the DSP determines that a memory leak occurs in the first process based on the memory occupancy information of the first process, the DSP sends a first indication message to the AP, or the DSP performs a first operation. When the AP receives the first indication message, the AP performs the first operation. The first indication message is used to indicate that a memory leak occurs in the first process, and the first operation includes one or more of the following: restarting the first process, restarting the DSP, and triggering the DSP to capture the memory application information log of the first process from the DSP.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of terminals, and in particular to a memory leakage detection method and an electronic device. Background Art

[0002] In the terminal field, memory is one of the important components of electronic devices. All programs in electronic devices run based on memory. Memory can also be called random access memory (RAM), which is used to store calculation data in the processor (for example, application processor / digital signal processor) and data exchanged with external storage such as hard disk.

[0003] Memory leak refers to the phenomenon that the memory that is no longer in use is not released in time due to errors in the program running logic, which leads to a continuous backlog of occupied memory. Memory leaks will reduce the efficiency of electronic devices in processing tasks. In particular, when a program running in a digital signal processor has a memory leak, it will not only cause a waste of memory and affect the computing efficiency of the application processor, but also make the program in the digital signal processor unable to run normally, causing serious consequences such as slowing down, freezing, and even crashing the electronic device. Summary of the invention

[0004] The present application provides a memory leak detection method and electronic device, which can more efficiently and conveniently detect whether a process in a DSP has a memory leak, has a more diversified processing method for the memory leak result of the process, and can also reduce the power consumption of the electronic device.

[0005] In a first aspect, the present application provides a memory leak detection method, which is applied to an electronic device including an application processor AP and a digital signal processor DSP, and the method includes: the DSP runs one or more processes, wherein the one or more processes include a first process. The AP sends a memory leak detection instruction to the DSP. When the DSP receives the memory leak detection instruction, the DSP obtains the memory occupancy information of the first process. The memory occupancy information of the first process includes one or more of the following: the memory occupancy size of the first process, the memory occupancy duration of the first process, and the time information of the first process applying for memory occupancy. When the DSP determines that the first process has a memory leak based on the memory occupancy information of the first process, the DSP sends a first indication information to the AP, or the DSP performs a first operation. When the AP receives the first indication information, the AP performs the first operation. The first indication information is used to indicate that the first process has a memory leak, and the first operation includes one or more of the following: restarting the first process, restarting the DSP, and triggering the DSP to capture the memory application information log of the first process from the DSP.

[0006] In one possible implementation, the memory application information log of the first process includes one or more of the following: an identifier of the first process, a memory size occupied by each code module in the first process, a memory application time of each code module in the first process, and a memory occupation duration of each code module in the first process.

[0007] In a possible implementation, the method further includes: when the AP receives the memory application information log of the first process sent by the DSP, the AP sends the memory application information log of the first process to a server connected to the electronic device. The memory application information log of the first process is used by the server to determine the cause of the memory leak of the first process.

[0008] In a possible implementation, the electronic device determines whether a memory leak occurs in the first process based on the memory occupancy information of the first process through the DSP, specifically including: the DSP in the electronic device determines the memory occupancy growth slope of the first process based on the memory occupancy information of the first process. The memory occupancy growth slope of the first process is used to indicate the growth rate of the memory size occupied by the first process. When the memory occupancy growth slope of the first process is greater than a first preset threshold value within a first preset time period, the DSP determines that a memory leak occurs in the first process. Alternatively, when the memory occupancy growth slope of the first process is greater than a second preset threshold value for N consecutive times within a second preset time period, the DSP determines that a memory leak occurs in the first process.

[0009] In one possible implementation, the electronic device determines whether a memory leak occurs in the first process based on the memory occupancy information of the first process through the DSP, specifically including: when the absolute value of the memory occupancy size of the first process is greater than a third preset threshold within the third preset time period, the DSP determines that a memory leak occurs in the first process.

[0010] In a possible implementation, before the AP in the electronic device sends the memory leak detection instruction to the DSP, the method further includes: the AP in the electronic device sends the identifier of the first process to the DSP. When the DSP receives the memory leak detection instruction, the DSP obtains the memory occupancy information of the first process, specifically including: when the DSP receives the memory leak detection instruction and the identifier of the first process, the DSP obtains the memory occupancy information of the first process.

[0011] In a possible implementation, the method further includes: when the DSP executes the first operation, the DSP sends second indication information and a memory application information log of the first process to the AP, wherein the second indication information is used to indicate that a memory leak occurs in the first process.

[0012] In a second aspect, the present application provides an electronic device, which includes an application processor AP and a digital signal processor DSP, the AP includes a fault information processing module, the DSP includes a cross-core memory monitoring interface, one or more processes are run on the DSP, the one or more processes include a first process, and the first process includes a first memory detection thread, wherein: the fault information processing module is used to send a memory leak detection instruction to the DSP. The first memory detection thread is used to obtain the memory occupancy information of the first process when the DSP receives the memory leak detection instruction. The memory occupancy information of the first process includes one or more of the following: the memory occupancy size of the first process, the memory occupancy duration of the first process, and the time information of the first process applying for memory occupancy. The first memory detection thread is also used to send a first indication information to the fault information processing module or trigger the DSP to perform a first operation when it is determined that the first process has a memory leak based on the memory occupancy information of the first process. The fault information processing module is also used to perform the first operation when the first indication information is received. The first indication information is used to indicate that a memory leak occurs in the first process, and the first operation includes one or more of the following: restarting the first process, restarting the DSP, and triggering the DSP to capture the memory application information log of the first process from the DSP.

[0013] In one possible implementation, the memory application information log of the first process includes one or more of the following: an identifier of the first process, a memory size occupied by each code module in the first process, a memory application time of each code module in the first process, and a memory occupation duration of each code module in the first process.

[0014] In a possible implementation, the fault information processing module is further used to, when receiving the memory application information log of the first process, send the memory application information log of the first process to a server connected to the electronic device. The memory application information log of the first process is used by the server to determine the cause of the memory leak of the first process.

[0015] In a possible implementation, the first memory detection thread is specifically used to: determine the memory occupancy growth slope of the first process based on the memory occupancy information of the first process. The memory occupancy growth slope of the first process is used to indicate the growth rate of the memory size occupied by the first process. When the memory occupancy growth slope of the first process is greater than a first preset threshold value within a first preset time period, it is determined that a memory leak occurs in the first process. Alternatively, when the memory occupancy growth slope of the first process is greater than a second preset threshold value for N consecutive times within a second preset time period, it is determined that a memory leak occurs in the first process.

[0016] In a possible implementation, the first memory detection thread is specifically used to: determine that a memory leak occurs in the first process when an absolute value of the memory usage of the first process is greater than a third preset threshold within the third preset time period.

[0017] In a possible implementation, the fault information processing module is further used to send the identifier of the first process to the DSP. The first memory detection thread is specifically used to obtain the memory usage information of the first process when the DSP receives the memory leak detection instruction and the identifier of the first process.

[0018] In a third aspect, the present application provides an electronic device, which includes an application processor AP and a digital signal processor DSP, the AP includes a fault information processing module, the DSP includes a user layer and a kernel layer, the user layer includes a memory monitoring process and one or more detected processes, the one or more detected processes include a first process, and the kernel layer includes a memory occupancy information acquisition interface, wherein: the fault information processing module is used to send a memory leak detection instruction to the DSP. The memory occupancy information acquisition interface is used to obtain the memory occupancy information of the first process when the DSP receives the memory leak detection instruction. The memory occupancy information of the first process includes one or more of the following: the memory occupancy size of the first process, the memory occupancy duration of the first process, and the time information of the first process applying for memory occupancy. The memory monitoring process is used to send a first indication information to the fault information processing module or trigger the DSP to perform a first operation when the memory occupancy information of the first process is obtained based on the memory occupancy information acquisition interface to determine that the first process has a memory leak. The fault information processing module is also used to perform the first operation when the first indication information is received. The first indication information is used to indicate that a memory leak occurs in the first process, and the first operation includes one or more of the following: restarting the first process, restarting the DSP, and triggering the DSP to capture the memory application information log of the first process from the DSP.

[0019] In one possible implementation, the memory application information log of the first process includes one or more of the following: an identifier of the first process, a memory size occupied by each code module in the first process, a memory application time of each code module in the first process, and a memory occupation duration of each code module in the first process.

[0020] In a possible implementation, the memory monitoring process is specifically used to: determine the memory occupancy growth slope of the first process based on the memory occupancy information of the first process. The memory occupancy growth slope of the first process is used to indicate the growth rate of the memory size occupied by the first process. When the memory occupancy growth slope of the first process is greater than a first preset threshold value within a first preset time period, it is determined that a memory leak occurs in the first process. Alternatively, when the memory occupancy growth slope of the first process is greater than a second preset threshold value for N consecutive times within a second preset time period, it is determined that a memory leak occurs in the first process.

[0021] In a possible implementation, the memory monitoring process is specifically used to: determine that a memory leak occurs in the first process when an absolute value of the memory usage of the first process is greater than a third preset threshold within the third preset time period.

[0022] In a possible implementation, the fault information processing module is further used to, when receiving the memory application information log of the first process, send the memory application information log of the first process to a server connected to the electronic device. The memory application information log of the first process is used by the server to determine the cause of the memory leak of the first process.

[0023] In a possible implementation, the fault information processing module is further used to send the identifier of the first process to the DSP. The memory occupancy information acquisition interface is specifically used to acquire the memory occupancy information of the first process when the DSP receives the memory leak detection instruction and the identifier of the first process.

[0024] In a fourth aspect, the present application provides an electronic device, comprising: multiple processors, one or more memories, wherein the multiple processors include an AP and a DSP. The one or more memories are coupled to the multiple processors, and the one or more memories are used to store computer program codes, and when the one or more processors execute the computer program codes, the electronic device executes the method in any possible implementation of the first aspect.

[0025] In a fifth aspect, the present application provides a chip comprising multiple processors and an interface circuit, the multiple processors including an AP and a DSP, the interface circuit being used to receive code instructions and transmit them to the multiple processors, the multiple processors being used to run the code instructions so that the chip executes the method in any possible implementation of the above-mentioned first aspect.

[0026] In a sixth aspect, the present application provides a computer-readable storage medium, comprising computer instructions, which, when executed on an electronic device, enables the electronic device to execute a method in any possible implementation of the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS

[0027] Figure 1 A schematic diagram of a device architecture of an electronic device provided in an embodiment of the present application;

[0028] Figure 2 A schematic diagram of the device architecture of another electronic device provided in an embodiment of the present application;

[0029] Figure 3 A schematic diagram of a specific process of a memory leak detection method provided in an embodiment of the present application;

[0030] Figure 4 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0031] The terms used in the following embodiments of the present application are only for the purpose of describing specific embodiments, and are not intended to be used as limitations on the present application. As used in the specification and the attached claims of the present application, the singular expressions "one", "a kind of", "said", "above", "the" and "this" are intended to also include plural expressions, unless there is a clear contrary indication in the context. It should also be understood that the term "and / or" used in the present application refers to any or all possible combinations including one or more of the listed striking ones. In the embodiments of the present application, the terms "first" and "second" are only used for descriptive purposes, and cannot be understood as implying relative importance or implicitly indicating the number of indicated technical features. Thus, the features defined as "first" and "second" can expressly or implicitly include one or more of the features. In the description of the embodiments of the present application, unless otherwise specified, the meaning of "multiple" is two or more.

[0032] An electronic device may be configured with multiple processors to run programs (e.g., processes, threads, handles, etc., which will be described below using processes as an example). For example, an electronic device may be configured with an application processor (AP) for running a user interface and application programs, and a digital signal processor (DSP) for high-speed real-time processing of digital signals such as images and voices.

[0033] In the embodiment of the present application, the electronic device may be a mobile phone, a tablet computer, a PC, an ultra-mobile personal computer (UMPC), a netbook, a personal digital assistant (PDA), etc. The embodiment of the present application does not impose any limitation on the specific type of the electronic device.

[0034] During the operation of the DSP, if a memory leak occurs in the program in the DSP, a large amount of memory resources will be wasted. As the program in the DSP runs, memory leaks accumulate, resulting in less and less available memory. Since both the DSP and the AP run programs based on memory, for example, the memory will store the calculation data of the AP and the DSP, therefore, when a memory leak occurs in the DSP, it will not only cause a waste of memory and affect the calculation efficiency of the AP, but also make the program in the DSP unable to run normally, causing serious consequences such as slowing down, freezing, and even crashing of electronic equipment.

[0035] Memory refers to random access memory (RAM), which is used to store the operation data in the processor (for example, AP, DSP, etc.) and the data exchanged with external storage such as hard disk. Memory leak refers to the phenomenon that the memory that is no longer used is not released in time due to errors in the program running logic, resulting in the continuous accumulation of occupied memory.

[0036] Therefore, in order to detect the memory leak of the process in the DSP, the embodiment of the present application provides the following two methods:

[0037] 1). A memory leak detection program is separately integrated in the DSP, and the DSP independently detects the memory usage information (e.g., memory usage size, memory usage duration, etc.) of each process based on the memory leak detection program. The DSP can determine whether a memory leak occurs in each process based on the memory usage information of each process detected.

[0038] However, DSP has limited functions. For example, DSP has no communication function and cannot communicate with other communication devices. Therefore, DSP cannot send the memory leak results of the process to other communication devices. DSP also has no file system. Therefore, DSP cannot save the memory leak detection results of the process and related information of the process memory leak, nor can it display related information of the process memory leak.

[0039] 2) AP obtains the memory usage information (e.g., memory usage size, memory usage duration, etc.) of the processes in DSP by calling the memory query interface provided by DSP. AP can determine whether each process has a memory leak based on the memory usage information obtained for each process.

[0040] However, this method requires the AP to frequently call the memory query interface provided by the DSP, which makes the AP in operation for a long time, prevents the AP from sleeping, and then causes the problem of high power consumption of electronic equipment.

[0041] Therefore, the present application provides a memory leak detection method. The method may include: when the electronic device is turned on, the AP may trigger the DSP to detect the memory occupancy information of one or more processes running in the DSP. Among them, the one or more processes may include a first process. The memory occupancy information of each process may include one or more of the following: the memory occupancy size of each process, the memory occupancy duration of each process, the time information of each process applying for memory occupancy, etc. The DSP may determine whether a memory leak occurs in each process based on the memory occupancy information of the above processes. When the DSP determines that a memory leak occurs in the first process based on the memory occupancy information of the first process, the DSP may send a first indication information indicating that a memory leak occurs in the first process to the AP.

[0042] When the AP obtains the first indication information, the AP may trigger the DSP to perform a first operation on the first process. The first operation may be: restarting the first process, restarting the DSP, or triggering the DSP to capture the memory application information log of the first process in the DSP to determine the cause of the memory leak in the first process.

[0043] When the AP obtains the memory request information log of the first process sent by the DSP, the AP may perform one or more of the following operations: 1). Store and display the memory request information log of the first process. 2). Send the indication information indicating that a memory leak has occurred in the first process and / or the memory request information log of the first process to other communication devices (e.g., a server connected to the electronic device, etc.) to determine the cause of the memory leak in the first process. The memory request information log of the first process may include one or more of the following: the identifier of the first process, the memory size occupied by each code module in the first process, the memory request time of each code module in the first process, and the memory occupancy time of each code module in the first process, etc.

[0044] It can be seen that the memory leak detection method provided in the present application can more efficiently and conveniently detect whether a process in the DSP has a memory leak, has a more diversified processing method for the memory leak result of the process, and can also reduce the power consumption of the electronic device.

[0045] Figure 1 The device architecture of an electronic device provided by an embodiment of the present application is exemplified.

[0046] like Figure 1 As shown, the electronic device may include an AP and a DSP.

[0047] The AP can run an operating system. In the embodiment of the present application, the operating system can be an Android system. The Android system can be divided into four layers, which are, from top to bottom, an application layer ( Figure 1 Not shown), application framework layer ( Figure 1 not shown), system library layer, hardware abstraction layer ( Figure 1 The system library layer may include a native layer. The Native layer may include a fault information processing module. The fault information processing module may include: a fault information processing layer and an interface call layer. The kernel layer may include an inter-core communication channel. In other implementations, the fault information processing module may also be set in the application layer or the kernel layer, which is not limited in this application.

[0048] Among them, the fault information processing module can send a memory leak detection instruction to the DSP through the inter-core communication channel to trigger the DSP to obtain the memory occupancy information of one or more processes (that is, the detected processes) running in the DSP, and enable the DSP to determine whether a memory leak occurs in the process based on the acquired memory occupancy information. The fault information processing module can call the cross-core memory monitoring interface provided by the DSP through the interface call layer, and obtain the indication information (for example, the first indication information, etc.) reported in the DSP to indicate that a certain process (for example, the first process, etc.) has a memory leak and / or the memory application information log of the specified process (for example, the first process, etc.) from the inter-core communication channel. When the fault information processing module obtains the above indication information, the fault information processing module can perform corresponding fault processing operations (for example, the first operation, etc.) for the process with memory leak through the fault information processing layer; when the fault information processing module obtains the memory application information log of the specified process, the fault information processing module can store and display the memory application information log of the first process, and / or send the memory application information log of the specified process to other communication devices.

[0049] One or more processes can be run in the DSP. When the DSP receives a memory leak detection instruction sent by the AP, the DSP can create a memory detection thread in each of the one or more running processes. The memory detection thread may include: a memory leak monitoring interface layer and a memory monitoring implementation layer. Among them, the memory monitoring implementation layer can be used to obtain the memory occupancy information of the process corresponding to the thread, and determine whether the process has a memory leak based on the acquired memory occupancy information. The memory leak monitoring interface layer can provide a cross-core memory monitoring interface, which can be used to report the indication information indicating that a memory leak has occurred in a process, and / or the memory application information log and other data information of the process corresponding to the thread to the fault information processing module in the AP through the inter-core communication channel.

[0050] For example, if one or more processes running on the DSP include the first process, take the DSP detecting whether a memory leak occurs in the first process as an example. When the DSP receives the memory leak detection instruction sent by the AP, the DSP can create a memory detection thread A1 (which can be called the first memory detection thread) in the first process. The memory detection thread A1 may include: a memory leak monitoring interface layer A2 and a memory monitoring implementation layer A3. Among them, the memory monitoring implementation layer A3 can be used to obtain the memory occupancy information of the first process, and determine whether a memory leak occurs in the first process based on the acquired memory occupancy information of the first process. The memory leak monitoring interface layer A2 can provide a cross-core memory monitoring interface for reporting the first indication information indicating that a memory leak occurs in the first process, and / or the memory application information log and other data information of the first process to the fault information processing module in the AP through the inter-core communication channel.

[0051] Figure 2 The device architecture of another electronic device provided in an embodiment of the present application is exemplified.

[0052] like Figure 2 As shown, the electronic device may include an AP and a DSP.

[0053] For details about AP and the fault information processing module included in AP, please refer to Figure 1 Description of the illustrated embodiment.

[0054] The DSP may include a user layer and a kernel layer. The user layer may include a memory monitoring process and one or more detected processes; the kernel layer may include a memory occupancy information acquisition interface. The memory occupancy information acquisition interface may acquire memory occupancy information of one or more detected processes. The memory monitoring process may determine whether a detected process running in the DSP has a memory leak based on the memory occupancy information sent by the memory occupancy information acquisition interface. The memory monitoring process may include: a memory leak monitoring interface layer and a memory monitoring implementation layer.

[0055] When the DSP receives the memory leak detection instruction sent by the AP, the memory monitoring process in the DSP can obtain the memory occupancy information of one or more detected processes through the memory occupancy information acquisition interface. The memory monitoring implementation layer in the memory monitoring process can determine whether a memory leak occurs in the detected process based on the acquired memory occupancy information. The memory leak monitoring interface layer can provide a cross-core memory monitoring interface for reporting indication information indicating that a memory leak occurs in a process, and / or data information such as the memory application information log of a specified process (for example, the first process, etc.) to the fault information processing module in the AP through the inter-core communication channel.

[0056] Exemplarily, if one or more detected processes in the DSP include a first process, detection of whether a memory leak occurs in the first process is used as an example for explanation. When the DSP receives a memory leak detection instruction sent by the AP, the memory monitoring process in the DSP can obtain the memory occupancy information of the first process through the memory occupancy information acquisition interface. The memory monitoring implementation layer in the memory monitoring process can determine whether a memory leak occurs in the first process based on the acquired memory occupancy information of the first process. The memory leak monitoring interface layer can provide a cross-core memory monitoring interface for reporting the first indication information indicating a memory leak occurs in the first process, and / or the memory application information log and other data information of the first process (for example, the first process, etc.) to the fault information processing module in the AP through the inter-core communication channel.

[0057] Figure 3 The specific process of a memory leak detection method provided in an embodiment of the present application is exemplified.

[0058] like Figure 3 As shown, the specific process of the memory leak detection method can be as follows:

[0059] S301: AP initializes the memory leak detection system.

[0060] Among them, the above Figure 1 The fault information processing module and the memory detection thread in the illustrated embodiment may be collectively referred to as a memory leak detection system. Figure 2 The fault information processing module, memory monitoring process and memory occupancy information acquisition interface in the illustrated embodiment may be collectively referred to as a memory leak detection system.

[0061] After the electronic device is turned on, the AP can initialize the memory leak detection system. The process of the AP initializing the memory leak detection system may include: the AP triggers the AP and the DSP to set the relevant parameter information of the memory leak detection system, the AP triggers the DSP to set a specified time interval for obtaining the memory occupancy information of the process, and the AP triggers the DSP to set a preset threshold for determining whether the process has a memory leak.

[0062] S302: DSP sends initialization completion information to AP.

[0063] The initialization completion information is used to indicate to the AP that the DSP has completed the initialization operation of the memory leak detection system.

[0064] S303: The AP sends a memory leak detection instruction to the DSP.

[0065] After the AP initializes the memory leak detection system, the AP may send a memory leak detection instruction to the DSP.

[0066] In some embodiments, the AP may send a memory leak detection instruction to the DSP through the fault information processing module, triggering the DSP to obtain the memory occupancy information of all running processes in the DSP, so that the DSP determines whether a memory leak occurs in each process based on the obtained memory occupancy information.

[0067] In some embodiments, the AP may send a memory leak detection instruction and the identifiers of one or more specified processes to the DSP through a fault information processing module. After the DSP receives the memory leak detection instruction and the identifiers of one or more specified processes, the DSP may obtain the memory occupancy information of the one or more specified processes, and determine whether a memory leak occurs in the one or more specified processes. For example, the AP may send a memory leak detection instruction, the identifier of process A, and the identifier of process B to the DSP. After the DSP receives the memory leak detection instruction, the identifier of process A, and the identifier of process B, the DSP may obtain the memory occupancy information of process A and process B, and determine whether a memory leak occurs in process A and process B. The DSP does not need to perform memory leak detection on other processes (e.g., process C, etc.) except process A and process B.

[0068] In the embodiment of the present application, the AP may send a memory leak detection instruction to the DSP through the fault information processing module.

[0069] S304: The DSP sends a first response message to the AP, which is used to instruct the DSP to start performing memory leak detection on one or more processes running in the DSP.

[0070] Specifically, after the DSP receives the memory leak detection instruction sent by the AP, the DSP may start to perform memory leak detection on one or more processes in the DSP, and return a first response message to the AP. The first response message may be used to instruct the DSP to start performing memory leak detection on one or more processes running in the DSP, and the memory leak detection refers to: obtaining memory occupancy information of one or more processes in the DSP, and judging whether each process has a memory leak based on the obtained memory occupancy information.

[0071] In a possible implementation, the AP can send a memory leak detection instruction to the DSP through an asynchronous call, triggering the DSP to detect whether a memory leak occurs in a process running in the DSP. Asynchronous call means that when the AP triggers the DSP to detect whether a memory leak occurs in a process, the AP can continue to run the process in the AP without having to stop running the process in the AP to wait for the memory leak detection result reported by the DSP. In this way, the operating efficiency of the electronic device can be improved.

[0072] S305: The DSP obtains memory usage information of one or more processes at every specified time interval T1, wherein the one or more processes may include the first process.

[0073] The memory usage information may include one or more of the following: the memory usage size of the process, the memory usage duration of the process, the time information of the process applying for memory usage, etc.

[0074] In the embodiment of the present application, the DSP may obtain the memory occupancy information of each process through the memory detection thread in each process. For example, the DSP may obtain the memory occupancy information of the first process through the first memory detection thread in the first process.

[0075] In the embodiment of the present application, the DSP can obtain the memory occupancy information of one or more detected processes through the memory occupancy information acquisition interface of the kernel layer.

[0076] S306: Based on the acquired memory usage information, the DSP determines whether a memory leak occurs in each process.

[0077] In the embodiment of the present application, the DSP can determine whether a memory leak occurs in each process based on the memory occupancy information of each process obtained through the memory detection thread in each process. For example, the DSP can determine whether a memory leak occurs in the first process based on the memory occupancy information of the first process obtained through the first memory detection thread in the first process.

[0078] In the embodiment of the present application, the DSP can determine whether a memory leak occurs in each process based on the memory occupancy information of each process (eg, the first process, etc.) acquired by the memory occupancy information acquisition interface through the memory monitoring process.

[0079] In the embodiment of the present application, the DSP may determine whether a memory leak occurs in each process based on the memory usage information of each process as follows:

[0080] (1). DSP determines the memory occupancy growth slope of each process based on the memory occupancy information of each process. The memory occupancy growth slope can indicate the growth rate of the memory size occupied by the process. When the memory occupancy growth slope of the process is greater than the preset threshold M1 (which can be called the first preset threshold) within the preset time period 1 (which can be called the first preset time period), DSP determines that the process has a memory leak.

[0081] (2) Based on the memory usage information of each process, the DSP determines the memory usage growth slope of each process. When the memory usage growth slope of the process is greater than the preset threshold M2 (which can be called the second preset threshold) for N consecutive times within the preset time period 2 (which can be called the second preset time period), the DSP determines that the process has a memory leak.

[0082] (3) When the absolute value of the memory usage of the process is greater than the preset threshold M3 (which may be referred to as the third preset threshold) within the preset time period 3 (which may be referred to as the third preset time period), the DSP determines that a memory leak occurs in the process.

[0083] In a specific implementation, the DSP may also determine whether a memory leak occurs in each process by other means, and this application does not impose any limitation on this.

[0084] S307: When the DSP determines that a memory leak occurs in the first process, the DSP sends first indication information to the AP.

[0085] The first indication information may be used to indicate that a memory leak has occurred in the first process.

[0086] In the embodiment of the present application, when the DSP determines that a memory leak occurs in the first process, the DSP may send first indication information to a fault information processing module in the AP through a first memory detection thread.

[0087] In the embodiment of the present application, when the DSP determines that a memory leak occurs in the first process, the DSP may send first indication information to a fault information processing module in the AP through the memory monitoring process.

[0088] S308: The AP triggers the DSP to perform a first operation based on the first indication information.

[0089] The first operation may be: restarting the first process, restarting the DSP, triggering the DSP to capture the memory application information log of the first process in the DSP to determine the cause of the memory leak in the first process. Restarting the first process may refer to stopping the operation of the first process, and then re-running the first process. The memory application information log of the first process may include one or more of the following: the identifier of the first process, the memory size occupied by each code module in the first process, the memory application time of each code module in the first process, and the memory occupation time of each code module in the first process.

[0090] In the embodiment of the present application, the AP may receive the first indication information through the fault information processing module, and perform the first operation based on the first indication information.

[0091] Furthermore, the AP can determine whether the first process can be restarted or whether the memory application information log of the first process can be captured based on the version information of the electronic device. When the AP determines that the first process can be restarted based on the version information of the electronic device, the AP triggers the DSP to restart the first process; when the AP determines that the memory application information log of the first process can be captured based on the version information of the electronic device, the AP triggers the DSP to capture the memory application information log of the first process in the DSP and send the memory application information log of the first process to the AP.

[0092] In another implementation, when the DSP determines that a memory leak occurs in the first process, the first memory detection thread / memory monitoring process can trigger the DSP to perform a first operation on the first process, which means that the DSP can perform the first operation without being triggered by the AP. In this implementation, the DSP can send the second indication information and / or the memory application information log of the first process to the AP. The second indication information is used to indicate that a memory leak occurs in the first process, but unlike the first indication information, when the AP obtains the second indication information, it does not need to perform the first operation.

[0093] S309: When the AP obtains the memory application information log of the first process, the AP may store and display the memory application information log of the first process, and / or send the memory application information log of the first process to other communication devices.

[0094] In the embodiment of the present application, the AP may receive the memory application information log of the first process through the fault information processing module.

[0095] In some embodiments, the fault information processing module in the AP may also send the memory application information log of the first process to other communication devices to determine the cause of the memory leak in the first process through the communication device (for example, a cloud server connected to the electronic device, etc.).

[0096] In some embodiments, the AP may also determine the cause of the memory leak in the first process based on the memory application information log of the first process, which is not limited in the present application.

[0097] In some embodiments, the AP may also store and display the memory leak detection results reported by the DSP, and / or send the memory leak detection results to other communication devices. For example, when the DSP determines that a memory leak occurs in the first process and sends the first indication information / second indication information to the AP, the AP may store and display the first memory leak detection information based on the first indication information / second indication information, and / or send the first memory leak detection information to other communication devices. The first memory leak detection information may be used to indicate that a memory leak occurs in the first process.

[0098] In an embodiment of the present application, when the DSP determines that a certain process (for example, the second process) has not had a memory leak, the memory occupancy information of the process may be obtained at every specified time interval T2, and based on the memory occupancy information of the process, it may be determined whether a memory leak has occurred in the process. When the DSP determines that a certain process (for example, the first process) has had a memory leak, the memory occupancy information of the process may be obtained at every specified time interval T3, and based on the memory occupancy information of the process, it may be determined whether a memory leak has occurred in the process. Among them, the specified time interval T3<specified time interval T1<specified time interval T2. In this way, the efficiency of memory leak detection can be guaranteed, and the power consumption of the electronic device can be reduced.

[0099] Figure 4 The hardware structure of an electronic device 100 provided in an embodiment of the present application is exemplified.

[0100] Figure 4 The electronic device 100 shown may be the electronic device mentioned above.

[0101] like Figure 4 As shown, the electronic device 100 may include a processor 401, a memory 402, a wireless communication module 403 (optional), a display screen 404 (optional), a camera 405 (optional), an audio module 406 (optional), and a microphone 407 (optional). The processor 401, the memory 402, the wireless communication module 403 (optional), the display screen 404 (optional), the camera 405 (optional), the audio module 406 (optional), and the microphone 407 (optional) may be connected to the computer via a processor 401. Figure 4 Bus connections shown.

[0102] It is understandable that the structure shown in the embodiment of the present application does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may also include Figure 4 More or fewer components may be shown, or some components may be combined or separated, or the components may be arranged differently. Figure 4 The components shown may be implemented in hardware, software or a combination of software and hardware.

[0103] The processor 401 may include one or more processor units, for example, the processor 401 may include an application processor (application processor, AP), a modem processor, a graphics processor (graphics processing unit, GPU), an image signal processor (image signal processor, ISP), a controller, a video codec, a digital signal processor (digital signal processor, DSP), a baseband processor, and / or a neural-network processing unit (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 an operation control signal according to the instruction opcode and the timing signal to complete the control of fetching and executing instructions.

[0104] A memory may also be provided in the processor 401 for storing instructions and data. In some embodiments, the memory in the processor 401 is a cache memory. The memory may store instructions or data that the processor 401 has just used or circulated. If the processor 401 needs to use the instruction or data again, it may be directly called from the memory. This avoids repeated access, reduces the waiting time of the processor 401, and thus improves the efficiency of the system.

[0105] In some embodiments, the processor 401 may include one or more interfaces. The interface may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a USB interface, etc.

[0106] The memory 402 is coupled to the processor 401 and is used to store various software programs and / or multiple groups of instructions. In a specific implementation, the memory 402 may include a volatile memory, such as a random access memory (RAM); it may also include a non-volatile memory, such as a ROM, a flash memory, a hard disk drive (HDD) or a solid state drive (SSD); the memory 402 may also include a combination of the above-mentioned types of memories. The memory 402 may also store some program codes so that the processor 401 calls the program codes stored in the memory 402 to implement the implementation method of the embodiment of the present application in the electronic device 100. The memory 402 may store an operating system, such as an embedded operating system such as uCOS, VxWorks, RTLinux, etc.

[0107] The wireless communication module 403 can provide wireless communication solutions applied to the electronic device 100, including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared (IR), etc. The wireless communication module 403 can be one or more devices integrating at least one communication processing module. The wireless communication module 403 receives electromagnetic waves via an antenna, modulates and filters the electromagnetic wave signals, and sends the processed signals to the processor 401. The wireless communication module 403 can also receive signals to be sent from the processor 401, modulate and amplify them, and convert them into electromagnetic waves for radiation through the antenna. In some embodiments, the electronic device 100 can also communicate with the processor 401 through the Bluetooth module ( Figure 4 Not shown), WLAN module ( Figure 4The WLAN module may provide a solution including one or more Bluetooth communication in basic rate / enhanced data rate (BR / EDR) or Bluetooth low energy (BLE), and a solution including one or more WLAN communication in Wi-Fi direct, Wi-Fi LAN or Wi-Fi softAP.

[0108] The display screen 404 can be used to display images, videos, etc. The display screen 404 may include a display panel. The display panel may be 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 (AMOLED), a flexible light-emitting diode (FLED), Miniled, MicroLed, Micro-oLed, a quantum dot light emitting diode (QLED), etc. In some embodiments, the electronic device 100 may include 1 or N display screens 404, where N is a positive integer greater than 1.

[0109] The camera 405 is used to capture still images or videos. The object generates an optical image through the lens and projects it onto the photosensitive element. The photosensitive element can be a charge coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the optical signal into an electrical signal, and then passes the electrical signal to the ISP to be converted into a digital image signal. The ISP outputs the digital image signal to the DSP for processing. The DSP converts the digital image signal into an image signal in a standard RGB, YUV or other format. In some embodiments, the electronic device 100 may include 1 or N cameras 405, where N is a positive integer greater than 1.

[0110] The audio module 406 can be used to convert digital audio information into analog audio signal output, and can also be used to convert analog audio input into digital audio signal. The audio module 406 can also be used to encode and decode audio signals. In some embodiments, the audio module 406 can also be arranged in the processor 401, or some functional modules of the audio module 406 can be arranged in the processor 401.

[0111] Microphone 407, which may also be called "microphone" or "microphone", may be used to collect sound signals in the environment surrounding the electronic device, convert the sound signals into electrical signals, and then subject the electrical signals to a series of processes, such as analog-to-digital conversion, to obtain an audio signal in digital form that can be processed by the processor 401 of the electronic device. When making a call or sending a voice message, the user may make a sound by approaching the microphone 407 with his or her mouth to input the sound signal into the microphone 407. The electronic device 100 may be provided with at least one microphone 407. In other embodiments, the electronic device 100 may be provided with two microphones 407, which, in addition to collecting sound signals, may also implement noise reduction. In other embodiments, the electronic device 100 may also be provided with three, four or more microphones 407 to collect sound signals, reduce noise, identify the source of sound, implement directional recording functions, and the like.

[0112] The electronic device 100 may further include a sensor module ( Figure 4 The sensor module may include a plurality of sensor devices, for example, a touch sensor ( Figure 4 The touch sensor may also be referred to as a "touch control device". The touch sensor may be provided on the display screen 404, and the touch sensor and the display screen 404 form a touch screen, also referred to as a "touch control screen". The touch sensor may be used to detect a touch operation on or near the touch sensor.

[0113] It should be noted that Figure 4 The electronic device 100 shown in the figure is only used to exemplify the hardware structure of the electronic device provided by the present application, and does not constitute a specific limitation to the present application.

[0114] As used in the above embodiments, the term "when..." may be interpreted to mean "if..." or "after..." or "in response to determining..." or "in response to detecting...", depending on the context. Similarly, the phrases "upon determining..." or "if (the stated condition or event) is detected" may be interpreted to mean "if determining..." or "in response to determining..." or "upon detecting (the stated condition or event)" or "in response to detecting (the stated condition or event)", depending on the context.

[0115] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that contains one or more available media integration. The available medium can be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk), etc.

[0116] Those skilled in the art can understand that to implement all or part of the processes in the above-mentioned embodiments, the processes can be completed by computer programs to instruct related hardware, and the programs can be stored in computer-readable storage media. When the programs are executed, they can include the processes of the above-mentioned method embodiments. The aforementioned storage media include: ROM or random access memory RAM, magnetic disk or optical disk and other media that can store program codes.

Claims

1. A memory leak detection method, It is characterized in that Applied to an electronic device including an application processor AP and a digital signal processor DSP, the method includes: The DSP runs one or more processes, wherein the one or more processes include a first process; The AP sends a memory leak detection instruction to the DSP; When the DSP receives the memory leak detection instruction, the DSP obtains the memory occupancy information of the first process through the first memory detection thread in the first process, or the memory monitoring process running in parallel with the first process; wherein the memory occupancy information of the first process includes one or more of the following: the memory occupancy size of the first process, the memory occupancy duration of the first process, and the time information of the first process applying for memory occupancy; When the DSP determines that a memory leak occurs in the first process based on the memory occupancy information of the first process, the DSP sends first indication information to the AP, or the DSP performs a first operation; When the AP receives the first indication information, the AP performs the first operation; wherein, the first indication information is used to indicate that a memory leak occurs in the first process, and the first operation includes one or more of the following: restarting the first process, restarting the DSP, and triggering the DSP to capture the memory application information log of the first process from the DSP.

2. The method according to claim 1, It is characterized in that The memory request information log of the first process includes one or more of the following: The identifier of the first process, the memory size occupied by each code module in the first process, the memory application time of each code module in the first process, and the memory occupation duration of each code module in the first process.

3. The method according to claim 1 or 2, It is characterized in that The method further comprises: When the AP receives the memory request information log of the first process sent by the DSP, the AP sends the memory request information log of the first process to a server connected to the electronic device; wherein, the memory request information log of the first process is used by the server to determine the cause of the memory leak in the first process.

4. The method according to claim 1, It is characterized in that The electronic device determines, by the DSP based on the memory occupancy information of the first process, whether a memory leak occurs in the first process, specifically including: The DSP in the electronic device determines a memory occupancy growth slope of the first process based on the memory occupancy information of the first process; wherein the memory occupancy growth slope of the first process is used to indicate a growth rate of the memory size occupied by the first process; When the memory usage growth slope of the first process is greater than a first preset threshold value within a first preset time period, the DSP determines that a memory leak occurs in the first process; Alternatively, when the memory usage growth slope of the first process is greater than a second preset threshold for N consecutive times within a second preset time period, the DSP determines that a memory leak occurs in the first process.

5. The method according to claim 1, It is characterized in that The electronic device determines, by the DSP based on the memory occupancy information of the first process, whether a memory leak occurs in the first process, specifically including: When the absolute value of the memory usage of the first process is greater than a third preset threshold within a third preset time period, the DSP determines that a memory leak occurs in the first process.

6. The method according to claim 1, It is characterized in that Before the AP in the electronic device sends a memory leak detection instruction to the DSP, the method further includes: The AP in the electronic device sends an identifier of the first process to the DSP; When the DSP receives the memory leak detection instruction, the DSP obtains the memory usage information of the first process, which specifically includes: When the DSP receives the memory leak detection instruction and the identifier of the first process, the DSP obtains the memory occupancy information of the first process.

7. The method according to claim 1, It is characterized in that The method further comprises: When the DSP executes the first operation, the DSP sends second indication information and a memory application information log of the first process to the AP; wherein the second indication information is used to indicate that a memory leak occurs in the first process.

8. An electronic device, It is characterized in that The electronic device includes an application processor AP and a digital signal processor DSP, the AP includes a fault information processing module, the DSP includes a cross-core memory monitoring interface, one or more processes are run on the DSP, the one or more processes include a first process, the first process includes a first memory detection thread, the first memory detection thread includes a memory leak monitoring interface layer and a memory monitoring implementation layer, wherein: The fault information processing module is used to send a memory leak detection instruction to the DSP; The first memory detection thread is used to, when the DSP receives the memory leak detection instruction, obtain the memory occupancy information of the first process through the memory monitoring implementation layer; wherein the memory occupancy information of the first process includes one or more of the following: the memory occupancy size of the first process, the memory occupancy duration of the first process, and the time information of the first process applying for memory occupancy; The first memory detection thread is further used to, when determining that a memory leak occurs in the first process based on the memory occupancy information of the first process, send first indication information to the fault information processing module through the memory leak monitoring interface layer, or trigger the DSP to perform a first operation; The fault information processing module is also used to execute the first operation when the first indication information is received; wherein the first indication information is used to indicate that a memory leak occurs in the first process, and the first operation includes one or more of the following: restarting the first process, restarting the DSP, and triggering the DSP to capture the memory application information log of the first process from the DSP.

9. The electronic device according to claim 8, It is characterized in that The memory request information log of the first process includes one or more of the following: The identifier of the first process, the memory size occupied by each code module in the first process, the memory application time of each code module in the first process, and the memory occupation duration of each code module in the first process.

10. The electronic device according to claim 8 or 9, It is characterized in that The fault information processing module is also used to, when receiving the memory request information log of the first process, send the memory request information log of the first process to a server connected to the electronic device; wherein, the memory request information log of the first process is used by the server to determine the cause of the memory leak in the first process.

11. The electronic device according to claim 8, It is characterized in that The first memory detection thread is specifically used for: Determine, based on the memory usage information of the first process, a memory usage growth slope of the first process; wherein the memory usage growth slope of the first process is used to indicate how fast the memory size occupied by the first process grows; When the memory usage growth slope of the first process is greater than a first preset threshold within a first preset time period, it is determined that a memory leak occurs in the first process; Alternatively, when the memory usage growth slope of the first process is greater than a second preset threshold for N consecutive times within a second preset time period, it is determined that a memory leak occurs in the first process.

12. The electronic device according to claim 8, It is characterized in that The first memory detection thread is specifically used for: When the absolute value of the memory usage of the first process is greater than a third preset threshold within a third preset time period, it is determined that a memory leak occurs in the first process.

13. The electronic device according to claim 8, It is characterized in that The fault information processing module is further used to send an identifier of the first process to the DSP; The first memory detection thread is specifically used to obtain memory occupancy information of the first process when the DSP receives the memory leak detection instruction and the identifier of the first process.

14. An electronic device, It is characterized in that The electronic device includes an application processor AP and a digital signal processor DSP, the AP includes a fault information processing module, the DSP includes a user layer and a kernel layer, the user layer includes a memory monitoring process and one or more detected processes, the one or more detected processes include a first process, the kernel layer includes a memory occupancy information acquisition interface, the memory monitoring process and the first process run in parallel, and the memory monitoring process includes a memory leak monitoring interface layer, wherein: The fault information processing module is used to send a memory leak detection instruction to the DSP; The memory occupancy information acquisition interface is used to acquire the memory occupancy information of the first process when the DSP receives the memory leak detection instruction; wherein the memory occupancy information of the first process includes one or more of the following: the memory occupancy size of the first process, the memory occupancy duration of the first process, and the time information of the first process applying for memory occupancy; The memory monitoring process is used to, when acquiring the memory occupancy information of the first process based on the memory occupancy information acquisition interface and determining that a memory leak occurs in the first process, send first indication information to the fault information processing module through the memory leak monitoring interface layer, or trigger the DSP to perform a first operation; The fault information processing module is also used to execute the first operation when the first indication information is received; wherein the first indication information is used to indicate that a memory leak occurs in the first process, and the first operation includes one or more of the following: restarting the first process, restarting the DSP, and triggering the DSP to capture the memory application information log of the first process from the DSP.

15. The electronic device according to claim 14, It is characterized in that The memory request information log of the first process includes one or more of the following: The identifier of the first process, the memory size occupied by each code module in the first process, the memory application time of each code module in the first process, and the memory occupation duration of each code module in the first process.

16. The electronic device according to claim 14, It is characterized in that The memory monitoring process is specifically used for: Determine, based on the memory usage information of the first process, a memory usage growth slope of the first process; wherein the memory usage growth slope of the first process is used to indicate how fast the memory size occupied by the first process grows; When the memory usage growth slope of the first process is greater than a first preset threshold within a first preset time period, it is determined that a memory leak occurs in the first process; Alternatively, when the memory usage growth slope of the first process is greater than a second preset threshold for N consecutive times within a second preset time period, it is determined that a memory leak occurs in the first process.

17. The electronic device according to claim 14, It is characterized in that The memory monitoring process is specifically used for: When the absolute value of the memory usage of the first process is greater than a third preset threshold within a third preset time period, it is determined that a memory leak occurs in the first process.

18. The electronic device according to any one of claims 14 to 17, It is characterized in that The fault information processing module is also used to, when receiving the memory request information log of the first process, send the memory request information log of the first process to a server connected to the electronic device; wherein, the memory request information log of the first process is used by the server to determine the cause of the memory leak in the first process.

19. The electronic device according to claim 15, It is characterized in that The fault information processing module is further used to send an identifier of the first process to the DSP; The memory occupancy information acquisition interface is specifically used to acquire the memory occupancy information of the first process when the DSP receives the memory leak detection instruction and the identifier of the first process.

20. An electronic device, It is characterized in that include: Multiple processors and one or more memories, wherein the multiple processors include an AP and a DSP; The one or more memories are coupled to the multiple processors, and the one or more memories are used to store computer program codes. When the one or more processors execute the computer program codes, the electronic device executes the method according to any one of claims 1 to 7.

21. A chip, It is characterized in that The chip comprises a plurality of processors and an interface circuit, wherein the plurality of processors include an AP and a DSP, wherein the interface circuit is used to receive code instructions and transmit the code instructions to the plurality of processors, and wherein the plurality of processors are used to execute the code instructions so that the chip executes the method as described in any one of claims 1 to 7.

22. A computer-readable storage medium, It is characterized in that The method comprises computer instructions, which, when executed on an electronic device, cause the electronic device to execute the method according to any one of claims 1 to 7.