Memory leak detection method and device, equipment and storage medium
By using the proxy function to save and analyze memory status snapshots when the memory error is detected in the current process, the problem of memory leakage detection affecting the operation of the process in the existing technology is solved, and the detection effect of zero performance loss is achieved.
Patent Information
- Application Number
- CN202411050298.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-30
- Publication Date
- 2024-11-01
AI Technical Summary
In the prior art, memory leak detection methods need to consume the program resources of the current process and affect the operation of the process.
When an error in memory is detected by the current process, a proxy function that does not belong to the current process is called, and the proxy function saves and analyzes the memory status snapshot to generate memory leakage detection results.
Memory leakage detection with zero performance loss is realized, avoiding the consumption of current process resources and ensuring the normal operation of the process.
Smart Images

Figure CN118885397A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of communication technology, and in particular to a memory leak detection method, device, equipment and storage medium. Background Art
[0002] In the computer field, memory leak refers to the inability to reclaim memory that is no longer used by the program due to negligence or error. As the application runs, the available memory in the system becomes less and less, causing the system to crash due to insufficient memory.
[0003] In order to solve the problem of memory leak, it is necessary to detect the cause of memory leak. In the prior art, the usual way to detect memory leak is to poll and save the memory state snapshot of the process, and then analyze the snapshot to find out the cause of memory leak.
[0004] However, the method of polling to save the memory state snapshot also consumes the program resources of the current process, thereby affecting the operation of the current process. Therefore, how to provide a memory leak detection method with zero performance loss is a technical problem to be solved in this field. Summary of the invention
[0005] The main purpose of the present invention is to provide a memory leak detection method, device, computer equipment and storage medium, aiming to solve the technical problem that the current memory leak detection method needs to consume the program resources of the current process, thereby affecting the operation of the current process.
[0006] To achieve the above object, the present invention provides a memory leak detection method, the method comprising:
[0007] In the case of detecting a memory error in the current process, calling a proxy function that does not belong to the current process;
[0008] Save the memory state snapshot corresponding to the current process through the proxy function;
[0009] The memory status snapshot is analyzed to generate a memory leak detection result.
[0010] Optionally, in the case where a memory error of the current process is detected, calling a proxy function that does not belong to the current process includes:
[0011] When a memory overflow of the current process is detected, a memory overflow alarm corresponding to the current process is generated;
[0012] The memory overflow alarm is intercepted, and the proxy function associated with the memory overflow alarm is called.
[0013] Optionally, when a memory error of the current process is detected, before calling a proxy function that does not belong to the current process, the method further includes:
[0014] Get the memory space of each process;
[0015] Based on the memory space of each process, generating an alarm trigger function corresponding to each process, wherein the alarm trigger function is used to generate a memory overflow alarm when the memory of the corresponding process overflows;
[0016] Compile the codes of each process and establish an association relationship between the memory overflow alarm corresponding to each process and the proxy function.
[0017] Optionally, the saving of a memory state snapshot corresponding to the current process by the proxy function includes:
[0018] reallocating the memory of the current process through the proxy function; and,
[0019] The memory state snapshot corresponding to the current process is saved through the proxy function.
[0020] Optionally, reallocating the memory of the current process through the proxy function includes:
[0021] Calling the proxy function to delete the memory belonging to the LOS area in the current process;
[0022] The proxy function is called to reclassify the memory of the current process after deleting the LOS area memory.
[0023] Optionally, the saving of a memory state snapshot corresponding to the current process by the proxy function includes:
[0024] Fixing a memory state snapshot of the current process;
[0025] Create a child process;
[0026] A memory state snapshot of the current process is saved in the child process.
[0027] Optionally, analyzing the memory state snapshot to generate a memory leak detection result includes:
[0028] Acquire the address and reference relationship of the heap memory from the memory state snapshot;
[0029] Based on the address and reference relationship of the heap memory, a memory leak detection result is generated.
[0030] In addition, to achieve the above-mentioned purpose, the present invention also provides a memory leak detection device, the memory leak detection device comprising:
[0031] A calling module, used for calling a proxy function that does not belong to the current process when a memory error of the current process is detected;
[0032] A saving module, used for saving a memory state snapshot corresponding to the current process through the proxy function;
[0033] The analysis module is used to analyze the memory status snapshot and generate a memory leak detection result.
[0034] In order to solve the above technical problems, the embodiment of the present application further provides a computer device, which adopts the following technical solution:
[0035] The computer device includes a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the steps of any one of the memory leak detection methods proposed in the embodiments of the present application are implemented.
[0036] In order to solve the above technical problems, the embodiment of the present application further provides a computer-readable storage medium, which adopts the following technical solution:
[0037] The computer-readable storage medium stores a computer program, and when the computer program is executed by the processor, the steps of any one of the memory leak detection methods proposed in the embodiments of the present application are implemented.
[0038] Compared with the prior art, the embodiments of the present application have the following beneficial effects:
[0039] The embodiment of the present application provides a memory leak detection method, including: when a memory error of the current process is detected, calling a proxy function that does not belong to the current process; saving a memory status snapshot corresponding to the current process through the proxy function; analyzing the memory status snapshot to generate a memory leak detection result. In the embodiment of the present application, calling a proxy function to save a memory status snapshot corresponding to the current process, analyzing the memory status snapshot, thereby generating a memory leak detection result, wherein the above-mentioned proxy function does not belong to the current process. Therefore, calling the proxy function will not consume the program resources of the current process, nor will it affect the operation of the current process. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] In order to more clearly illustrate the scheme in the present application, a brief introduction is given below to the drawings required for use in the description of the embodiments of the present application. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0041] Figure 1is an exemplary system architecture diagram to which the present application may be applied;
[0042] Figure 2 is a flow chart of a memory leak detection method provided by an embodiment of the present invention;
[0043] Figure 3 is an application scenario diagram of the memory leak detection method provided by an embodiment of the present invention;
[0044] Figure 4 is a structural diagram of an embodiment of a memory leak detection device provided by an embodiment of the present invention;
[0045] Figure 5 This is a basic structural block diagram of the computer device in this embodiment. DETAILED DESCRIPTION
[0046] The memory leak detection method provided by the embodiment of the present invention is applied to the memory leak detection device. Unless otherwise defined, all technical and scientific terms used in this article have the same meaning as those generally understood by technicians in the technical field of this application; the terms used in the specification of the application herein are only for the purpose of describing specific embodiments and are not intended to limit this application; the terms "including" and "having" in the specification and claims of this application and the above-mentioned figure descriptions and any variations thereof are intended to cover non-exclusive inclusions. The terms "first", "second", etc. in the specification and claims of this application or the above-mentioned figures are used to distinguish different objects, not to describe a specific order.
[0047] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0048] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the accompanying drawings.
[0049] like Figure 1 As shown, the system architecture 100 may include terminal devices 101, 102, 103, a network 104 and a server 105. The network 104 is used to provide a medium for communication links between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0050] Users can use terminal devices 101, 102, 103 to interact with server 105 through network 104 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 101, 102, 103, such as web browser applications, shopping applications, search applications, instant messaging tools, email clients, social online platform software, etc.
[0051] Terminal devices 101, 102, 103 can be various electronic devices with display screens and supporting web browsing, including but not limited to smart phones, tablet computers, e-book readers, MP3 players (Moving Picture Experts Group Audio Layer III), MP4 (Moving Picture Experts Group Audio Layer IV) players, laptop computers, desktop computers, etc.
[0052] The server 105 may be a server that provides various services, such as a background server that provides support for web pages displayed on the terminal devices 101 , 102 , and 103 .
[0053] It should be noted that the memory leak detection method provided in the embodiment of the present application is generally executed by a server / terminal device, and accordingly, the memory leak detection device is generally arranged in the server / terminal device.
[0054] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0055] Please refer to Figure 2 , shows a flow chart of an embodiment of the memory leak detection method proposed in the present application. The embodiment of the present application can acquire and process relevant data based on artificial intelligence technology.
[0056] The memory leak detection method provided by the embodiment of the present invention comprises the following steps:
[0057] S210, when a memory error of the current process is detected, calling a proxy function that does not belong to the current process.
[0058] It should be understood that the above-mentioned current process can be understood as any process currently running in the system.
[0059] In this step, an optional implementation method is to obtain the working status of the current running process in real time, and call the proxy function when a memory error of the current process is detected.
[0060] Another optional implementation method is to periodically obtain the working status of the current running process, and call the proxy function when a memory error of the current process is detected.
[0061] The above proxy function is not a function included in the current process.
[0062] S220, saving a memory state snapshot corresponding to the current process through the proxy function.
[0063] It should be noted that the above memory status snapshot is used to record the addresses and reference relationships of various memories of the current process.
[0064] In this step, after calling the proxy function, the memory state snapshot corresponding to the current process can be saved through the proxy function. For specific implementation methods of how to save the memory state snapshot, please refer to the subsequent embodiments.
[0065] S230: Analyze the memory status snapshot to generate a memory leak detection result.
[0066] In this step, after obtaining the memory state snapshot, the memory state snapshot is analyzed to generate a memory leak detection result.
[0067] Optionally, a memory monitoring tool may be used to analyze the memory status snapshot, or a command line tool may be used to analyze the memory status snapshot, or the memory status snapshot may be analyzed through a snapshot log.
[0068] The method provided in the embodiment of the present application includes: when a memory error of the current process is detected, calling a proxy function that does not belong to the current process; saving a memory status snapshot corresponding to the current process through the proxy function; analyzing the memory status snapshot to generate a memory leak detection result. In the embodiment of the present application, calling a proxy function to save a memory status snapshot corresponding to the current process, analyzing the memory status snapshot, thereby generating a memory leak detection result, wherein the above-mentioned proxy function does not belong to the current process. Therefore, calling the proxy function will not consume the program resources of the current process, nor will it affect the operation of the current process.
[0069] Optionally, in the case where a memory error of the current process is detected, calling a proxy function that does not belong to the current process includes:
[0070] When a memory overflow of the current process is detected, a memory overflow alarm corresponding to the current process is generated;
[0071] The memory overflow alarm is intercepted, and the proxy function associated with the memory overflow alarm is called.
[0072] It should be noted that the above-mentioned memory error includes memory overflow.
[0073] In this embodiment, when a memory overflow of the current process is detected, a memory overflow alarm is generated. Optionally, when an "OutOfMemoryError" field is detected, it is determined that the memory overflow of the current process has occurred.
[0074] In the case where a memory overflow alarm is detected, the memory overflow alarm is intercepted and a proxy function associated with the memory overflow alarm is called.
[0075] The proxy function is a pre-set function, and the proxy function does not belong to the function of the current process. Optionally, the proxy function can be pre-set by means of instruction set injection.
[0076] In other embodiments, the above-mentioned memory error situation also includes memory allocation error and the like.
[0077] Optionally, when a memory error of the current process is detected, before calling a proxy function that does not belong to the current process, the method further includes:
[0078] Get the memory space of each process;
[0079] Based on the memory space of each process, generating an alarm trigger function corresponding to each process, wherein the alarm trigger function is used to generate a memory overflow alarm when the memory of the corresponding process overflows;
[0080] Compile the codes of each process and establish an association relationship between the memory overflow alarm corresponding to each process and the proxy function.
[0081] In this embodiment, the system obtains the memory space of each process, and based on the memory space of each process, the memory upper limit of each process can be determined.
[0082] The system generates an alarm trigger function corresponding to each process. The above alarm trigger function is used to generate a memory overflow alarm when the corresponding process memory overflows, that is, when the corresponding process reaches the memory upper limit, a memory overflow alarm is generated.
[0083] As described above, the proxy function corresponding to each process is generated. After the memory overflow alarm corresponding to each process is determined, the association relationship between the memory overflow alarm corresponding to each process and the proxy function is established by compiling the code of each process.
[0084] Optionally, the saving of a memory state snapshot corresponding to the current process by the proxy function includes:
[0085] reallocating the memory of the current process through the proxy function; and,
[0086] The memory state snapshot corresponding to the current process is saved through the proxy function.
[0087] In this embodiment, the proxy function includes a memory state snapshot corresponding to the current process through the following operations.
[0088] For the current process, the proxy function reallocates the memory of the current process. After the memory allocation is successful, the memory state snapshot corresponding to the current process is saved. For specific implementation methods of how to allocate the memory of the current process and save the memory state snapshot corresponding to the current process, please refer to the subsequent embodiments.
[0089] The following describes in detail how to allocate memory for the current process:
[0090] Optionally, reallocating the memory of the current process through the proxy function includes:
[0091] Calling the proxy function to delete the memory belonging to the LOS area in the current process;
[0092] The proxy function is called to reclassify the memory of the current process after deleting the LOS area memory.
[0093] It should be understood that the LOS area is also called the LargeObjectSpace area. Memory allocations exceeding 12kb will be allocated to this area. This area is discrete, that is, it does not border other memory areas. In this embodiment, the proxy function is called to delete the memory belonging to the LOS area in the current process, that is, the heap memory belonging to LargeObjectSpace is deleted. After the deletion, the overall heap memory will be greatly reduced; and the proxy function is called to reclassify the memory of the current process after deleting the LOS area memory.
[0094] The following describes how to save a snapshot of the memory state corresponding to the current process:
[0095] Optionally, the saving of a memory state snapshot corresponding to the current process by the proxy function includes:
[0096] Fixing a memory state snapshot of the current process;
[0097] Create a child process;
[0098] A memory state snapshot of the current process is saved in the child process.
[0099] In this embodiment, the memory state snapshot corresponding to the current process can be saved through the Supend And Fork mechanism, wherein supend represents pausing the current process for fixing the memory snapshot, and fork represents a Linux call for creating a child process.
[0100] Specifically, the current process is paused, the memory status snapshot of the current process is fixed, a child process is created, and the memory snapshot is dumped in the child process. That is, the memory status snapshot of the current process is saved in the child process, and then provided to the developer for analysis and troubleshooting of memory leaks.
[0101] In this embodiment, a proxy function that does not belong to the current process is called to save a memory state snapshot corresponding to the current process, and the memory state snapshot is analyzed to reduce program resources of the current process.
[0102] Optionally, analyzing the memory state snapshot to generate a memory leak detection result includes:
[0103] Acquire the address and reference relationship of the heap memory from the memory state snapshot;
[0104] Based on the address and reference relationship of the heap memory, a memory leak detection result is generated.
[0105] In this embodiment, after obtaining the memory status snapshot, the memory status snapshot is parsed to obtain the address and reference relationship of the heap memory, and the object of the allocated memory and the memory release information are determined through the address and reference relationship of the heap memory. The memory release information is interpreted, and the object and time of the memory leak are determined according to the memory allocation and memory release situations, thereby generating a memory leak detection result.
[0106] In this embodiment, the detection result of the memory leak is determined based on the address and reference relationship of the heap memory, and the address and reference relationship of the heap memory can reflect the address and object of the memory allocation, thereby ensuring the accuracy of the detection result.
[0107] In other embodiments, tools such as Valgrind, Eclipse Memory Analyzer (MAT), jvisualVM, LeakCanary, and Android Studio Profiler may be used to analyze the cause of the memory leak and generate a memory leak detection result.
[0108] In other embodiments, a command line tool may be used to obtain system memory usage, process memory occupancy information, cache hits, and overall performance data to generate memory leak detection results.
[0109] In other embodiments, a graphical interface tool, such as GNOME System Monitor, Chrome Devtools, etc., may be used to obtain the usage of the CPU, memory, swap area, and network, and to obtain the CPU and memory usage.
[0110] In other embodiments, the thread status and memory leak issues can be analyzed through snapshot logs.
[0111] For the overall technical solution, please refer to Figure 3 ,exist Figure 3 In the application scenario shown, the relationship between the proxy function and the memory overflow alarm (OutOfMemoryError) is pre-set through the instruction set (inline hook). When the memory overflow alarm of the current process is detected, the memory overflow alarm is intercepted and the memory of the current process is reallocated; and the memory state snapshot corresponding to the current process is saved, and the memory leak detection result is generated through the memory state snapshot.
[0112] See also Figure 4 , an embodiment of the present invention provides a memory leak detection device 400, the memory leak detection device 400 comprising:
[0113] The calling module 410 is used to call a proxy function that does not belong to the current process when a memory error of the current process is detected;
[0114] A saving module 420 is used to save a memory state snapshot corresponding to the current process through the proxy function;
[0115] The analysis module 430 is used to analyze the memory status snapshot and generate a memory leak detection result.
[0116] Optionally, the calling module 410 is specifically configured to:
[0117] When a memory overflow of the current process is detected, a memory overflow alarm corresponding to the current process is generated;
[0118] The memory overflow alarm is intercepted, and the proxy function associated with the memory overflow alarm is called.
[0119] Optionally, the memory leak detection device 400 further includes:
[0120] Acquisition module, used to obtain the memory space of each process;
[0121] A generating module, used for generating an alarm triggering function corresponding to each process based on the memory space of each process, wherein the alarm triggering function is used for generating a memory overflow alarm when the memory of the corresponding process overflows;
[0122] The compiling module is used to compile the codes of each process and establish an association relationship between the memory overflow alarm corresponding to each process and the proxy function.
[0123] Optionally, the saving module 420 is specifically used for:
[0124] reallocating the memory of the current process through the proxy function; and,
[0125] The memory state snapshot corresponding to the current process is saved through the proxy function.
[0126] Optionally, the storage module 420 is further specifically configured to:
[0127] Calling the proxy function to delete the memory belonging to the LOS area in the current process;
[0128] The proxy function is called to reclassify the memory of the current process after deleting the LOS area memory.
[0129] Optionally, the storage module 420 is further specifically configured to:
[0130] Fixing a memory state snapshot of the current process;
[0131] Create a child process;
[0132] A memory state snapshot of the current process is saved in the child process.
[0133] Optionally, the analysis module 430 is specifically configured to:
[0134] Acquire the address and reference relationship of the heap memory from the memory state snapshot;
[0135] Based on the address and reference relationship of the heap memory, a memory leak detection result is generated.
[0136] To solve the above technical problems, the present application also provides a computer device. Figure 5 , Figure 5 This is a basic structural block diagram of the computer device in this embodiment.
[0137] The computer device 5 includes a memory 51, a processor 52, and a network interface 53 that are interconnected through a system bus. It should be noted that the figure only shows a computer device 5 with components 51-53, but it should be understood that it is not required to implement all the components shown, and more or fewer components can be implemented instead. Among them, those skilled in the art can understand that the computer device here is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to microprocessors, application specific integrated circuits (Application Specific Integrated Circuit, ASIC), programmable gate arrays (Field-Programmable Gate Array, FPGA), digital processors (Digital Signal Processor, DSP), embedded devices, etc.
[0138] The computer device may be a computing device such as a desktop computer, a notebook, a PDA, a cloud server, etc. The computer device may interact with a user through a keyboard, a mouse, a remote controller, a touch pad, or a voice control device.
[0139] The memory 51 includes at least one type of readable storage medium, and the readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, disk, optical disk, etc. In some embodiments, the memory 51 can be an internal storage unit of the computer device 5, such as a hard disk or memory of the computer device 5. In other embodiments, the memory 51 can also be an external storage device of the computer device 5, such as a plug-in hard disk equipped on the computer device 5, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (FlashCard), etc. Of course, the memory 51 can also include both the internal storage unit of the computer device 5 and its external storage device. In this embodiment, the memory 51 is generally used to store the operating system and various application software installed on the computer device 5, such as the program code of the memory leak detection method, etc. In addition, the memory 51 can also be used to temporarily store various types of data that have been output or are to be output.
[0140] The processor 52 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chips in some embodiments. The processor 52 is generally used to control the overall operation of the computer device 5. In this embodiment, the processor 52 is used to run the program code stored in the memory 51 or process data, such as running the program code of the memory leak detection method.
[0141] The network interface 53 may include a wireless network interface or a wired network interface. The network interface 53 is generally used to establish a communication connection between the computer device 5 and other electronic devices.
[0142] The present application also provides another implementation, namely, providing a computer-readable storage medium, wherein the computer-readable storage medium stores the memory leak detection program, and the memory leak detection program can be executed by at least one processor so that the at least one processor performs the steps of the memory leak detection method as described above.
[0143] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware online platform, and of course, by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in each embodiment of the present application.
[0144] The present application can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, etc. The present application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present application can also be practiced in distributed computing environments, in which tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media including storage devices.
[0145] Obviously, the embodiments described above are only some embodiments of the present application, rather than all embodiments. The preferred embodiments of the present application are given in the accompanying drawings, but they do not limit the patent scope of the present application. The present application can be implemented in many different forms. On the contrary, the purpose of providing these embodiments is to make the understanding of the disclosure of the present application more thorough and comprehensive. Although the present application is described in detail with reference to the aforementioned embodiments, for those skilled in the art, it is still possible to modify the technical solutions recorded in the aforementioned specific implementation methods, or to perform equivalent replacement of some of the technical features therein. Any equivalent structure made using the contents of the specification and drawings of this application, directly or indirectly used in other related technical fields, is similarly within the scope of patent protection of this application.
Claims
1. A memory leak detection method, characterized in that: include: In the case of detecting a memory error in the current process, calling a proxy function that does not belong to the current process; Save the memory state snapshot corresponding to the current process through the proxy function; The memory status snapshot is analyzed to generate a memory leak detection result.
2. The method according to claim 1, characterized in that In the case where a memory error of the current process is detected, calling a proxy function that does not belong to the current process includes: When a memory overflow of the current process is detected, a memory overflow alarm corresponding to the current process is generated; The memory overflow alarm is intercepted, and the proxy function associated with the memory overflow alarm is called.
3. The method according to claim 2, characterized in that In the case where a memory error of the current process is detected, before calling a proxy function that does not belong to the current process, the method further includes: Get the memory space of each process; Based on the memory space of each process, generating an alarm trigger function corresponding to each process, wherein the alarm trigger function is used to generate a memory overflow alarm when the memory of the corresponding process overflows; Compile the codes of each process and establish an association relationship between the memory overflow alarm corresponding to each process and the proxy function.
4. The method according to claim 1, characterized in that The step of saving the memory state snapshot corresponding to the current process through the proxy function includes: reallocating the memory of the current process through the proxy function; and, The memory state snapshot corresponding to the current process is saved through the proxy function.
5. The method according to claim 4, characterized in that The reallocating the memory of the current process through the proxy function includes: Calling the proxy function to delete the memory belonging to the LOS area in the current process; The proxy function is called to reclassify the memory of the current process after deleting the LOS area memory.
6. The method according to claim 4, characterized in that The step of saving the memory state snapshot corresponding to the current process through the proxy function includes: Fixing a memory state snapshot of the current process; Create a child process; A memory state snapshot of the current process is saved in the child process.
7. The method according to claim 1, characterized in that The analyzing the memory state snapshot to generate a memory leak detection result includes: Acquire the address and reference relationship of the heap memory from the memory state snapshot; Based on the address and reference relationship of the heap memory, a memory leak detection result is generated.
8. A memory leak detection device, characterized in that: include: A calling module, used for calling a proxy function that does not belong to the current process when a memory error of the current process is detected; A saving module, used for saving a memory state snapshot corresponding to the current process through the proxy function; The analysis module is used to analyze the memory status snapshot and generate a memory leak detection result.
9. A computer device, characterized in that: The method comprises a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the memory leak detection method according to any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the memory leak detection method according to any one of claims 1 to 7 are implemented.
