Memory leak positioning method and device, equipment, medium and program product

By obtaining the virtual address set at the system level and program level, and excluding non-program level virtual addresses, the problem of low memory leakage positioning efficiency in the existing technology is solved, and efficient and accurate memory leakage point positioning is achieved.

CN119718937APending Publication Date: 2025-03-28INDUSTRIAL AND COMMERCIAL BANK OF CHINA
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411836490.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-13
Publication Date
2025-03-28

AI Technical Summary

Technical Problem

The existing technology is difficult to efficiently locate memory leak points, resulting in waste of memory resources and unavailability of business systems.

Method used

By obtaining the virtual address set at the system level and program level, excluding non-program level virtual addresses, reducing the scope of troubleshooting, and efficiently locate memory leak points.

Benefits of technology

It greatly saves the location time and positioning efficiency of memory leak points, releases a lot of labor costs, and ensures faster handling of memory leak problems.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119718937A_ABST
    Figure CN119718937A_ABST
Patent Text Reader

Abstract

The invention provides a memory leak positioning method which can be applied to the field of distributed technologies. The memory leak positioning method comprises the steps that virtual address sets are obtained, virtual addresses comprise a first virtual address set and a second virtual address set, the first virtual address set comprises N first virtual addresses obtained through a system, the second virtual address set comprises K second virtual addresses obtained through a program, and N and K are positive integers; l first virtual addresses in the first virtual address set are deleted, a third virtual address set is obtained, the L first virtual addresses are first virtual addresses which have intersections with second virtual addresses in the second virtual address set, and L is an integer larger than or equal to zero; and positioning a memory leak point based on the third virtual address set. The invention further provides a memory leak positioning device and equipment, a storage medium and a program product.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of distributed technology, and more specifically to a memory leak location method, device, equipment, medium and program product. Background Art

[0002] Incorrect editing of program source code may lead to memory leaks, which will cause waste of memory resources. In the case of insufficient memory, the program will be "killed" by the system, causing the entire business system to be unavailable, which poses a huge risk.

[0003] When encountering a memory leak problem, the troubleshooting work is implemented by using source code analysis or system analysis. However, the analysis and location of the problem is often very difficult, and it is difficult to efficiently locate the specific memory leak point. Summary of the invention

[0004] In view of the above problems, the present disclosure provides a memory leak location method, apparatus, device, medium and program product for improving the efficiency of memory leak location.

[0005] According to a first aspect of the present disclosure, a memory leak locating method is provided, comprising: obtaining a virtual address set, the virtual address comprising a first virtual address set and a second virtual address set, the first virtual address set comprising N first virtual addresses obtained through the system, the second virtual address set comprising K second virtual addresses obtained through a program, N and K being positive integers; deleting L first virtual addresses in the first virtual address set to obtain a third virtual address set, wherein the L first virtual addresses are first virtual addresses that have an intersection with the second virtual addresses in the second virtual address set, wherein L is an integer greater than or equal to zero; and locating a memory leak point based on the third virtual address set.

[0006] According to an embodiment of the present disclosure, before obtaining the virtual address set, the method further includes: obtaining a memory usage indicator; and judging whether it is known leakage information based on the memory usage indicator, wherein if the memory usage indicator is judged not to be known leakage information, obtaining the virtual address set is performed.

[0007] According to an embodiment of the present disclosure, obtaining a memory usage indicator includes: obtaining a first memory usage indicator and a second memory usage indicator, wherein the first memory usage indicator is a memory usage indicator before reclaiming free memory fragments in a process, and the second memory usage indicator is a memory usage indicator after reclaiming free memory fragments in a process; judging whether it is known leakage information based on the memory usage indicator includes: calculating the difference between the first memory usage indicator and the second memory usage indicator, and judging that the memory usage indicator is not known leakage information when the difference between the first memory usage indicator and the second memory usage indicator exceeds a preset difference threshold.

[0008] According to an embodiment of the present disclosure, the method of obtaining a virtual address set includes: for the first virtual address, obtaining a starting address and memory usage information of a target process based on a system instruction; and calculating an ending address based on the starting address and the memory usage information.

[0009] According to an embodiment of the present disclosure, the obtaining of the virtual address set also includes: for the second virtual address, determining whether the target process is a process in a container; if the target process is a process in a container, entering the container and obtaining the starting address and memory usage information of the target process based on program instructions; if the target process is not a process in a container, obtaining the starting address and memory usage information of the target process based on program instructions; and calculating the end address based on the starting address and the memory usage information.

[0010] According to an embodiment of the present disclosure, the deleting L first virtual addresses in the first virtual address set to obtain the third virtual address set includes: judging whether the starting address and the ending address of the second virtual address are within the starting address and the ending address of the first virtual address; if the starting address and the ending address of the second virtual address are within the starting address and the ending address of the first virtual address, deleting the corresponding first virtual address; and judging whether the ending address of the second virtual address is within the starting address and the ending address of the first virtual address; if the ending address of the second virtual address is within the starting address and the ending address of the first virtual address, deleting the corresponding first virtual address.

[0011] According to an embodiment of the present disclosure, the third virtual address set includes M first virtual addresses, M is a positive integer, and locating the memory leak point based on the third virtual address set includes: deleting the first virtual address of the anonymous memory and the first virtual address of the file cache in the third virtual address set, and obtaining the fourth virtual address set as a set of virtual addresses of the memory leak.

[0012] A second aspect of the present disclosure provides a memory leak locating device, including: an address acquisition module, used to acquire a virtual address set, the virtual address includes a first virtual address set and a second virtual address set, the first virtual address set includes N first virtual addresses obtained through the system, and the second virtual address set includes K second virtual addresses obtained through the program, N and K are positive integers; an address screening module, used to delete L first virtual addresses in the first virtual address set to obtain a third virtual address set, wherein the L first virtual addresses are first virtual addresses that have an intersection with the second virtual address in the second virtual address set, wherein L is an integer greater than or equal to zero; and a memory locating module, used to locate a memory leak point based on the third virtual address set.

[0013] According to an embodiment of the present disclosure, the device also includes: a problem filtering module, used to obtain a memory usage indicator; and determine whether it is known leakage information based on the memory usage indicator, wherein if the memory usage indicator is determined not to be known leakage information, the acquisition of the virtual address set is performed.

[0014] According to an embodiment of the present disclosure, the problem filtering module is specifically used to obtain a first memory usage indicator and a second memory usage indicator, wherein the first memory usage indicator is a memory usage indicator before the free memory fragments in the recovery process, and the second memory usage indicator is a memory usage indicator after the free memory fragments in the recovery process; calculate the difference between the first memory usage indicator and the second memory usage indicator, and when the difference between the first memory usage indicator and the second memory usage indicator exceeds a preset difference threshold, determine that the memory usage indicator is not a known leakage information.

[0015] According to an embodiment of the present disclosure, the address acquisition module is specifically used to obtain the starting address and memory usage information of the target process based on the system instructions for the first virtual address; and calculate the ending address based on the starting address and the memory usage information.

[0016] According to an embodiment of the present disclosure, the address acquisition module is further specifically used to determine, for the second virtual address, whether the target process is a process in a container; if the target process is a process in a container, enter the container and obtain the starting address and memory usage information of the target process based on program instructions; if the target process is not a process in a container, obtain the starting address and memory usage information of the target process based on program instructions; and calculate the end address based on the starting address and the memory usage information.

[0017] According to an embodiment of the present disclosure, the address filtering module is specifically used to determine whether the starting address and the ending address of the second virtual address are within the starting address and the ending address of the first virtual address; if the starting address and the ending address of the second virtual address are within the starting address and the ending address of the first virtual address, delete the corresponding first virtual address; and determine whether the ending address of the second virtual address is within the starting address and the ending address of the first virtual address; if the ending address of the second virtual address is within the starting address and the ending address of the first virtual address, delete the corresponding first virtual address.

[0018] According to an embodiment of the present disclosure, the third virtual address set includes M first virtual addresses, M is a positive integer, and the memory location module is specifically used to delete the first virtual address of the anonymous memory and the first virtual address of the file cache in the third virtual address set to obtain a fourth virtual address set as a set of virtual addresses of memory leaks.

[0019] A third aspect of the present disclosure provides an electronic device, comprising: one or more processors; and a memory for storing one or more computer programs, wherein the one or more processors execute the one or more computer programs to implement the steps of the above method.

[0020] The fourth aspect of the present disclosure further provides a computer-readable storage medium having a computer program or instructions stored thereon, which implements the steps of the above method when the above computer program or instructions are executed by a processor.

[0021] The fifth aspect of the present disclosure further provides a computer program product, including a computer program or instructions, which implement the steps of the above method when the above computer program or instructions are executed by a processor.

[0022] In the embodiments of the present disclosure, in order to solve the technical problem of low efficiency in locating memory leaks, the embodiments of the present disclosure collect the first virtual address set considered to be used at the system level and the second virtual address set considered to be used at the program level, and exclude and filter out the non-program-level virtual addresses in the first virtual address set at the system level to reduce the scope of investigation. The positioning is completed by the filtered virtual address collection to ensure efficient and accurate memory leak positioning. The embodiments of the present disclosure can at least achieve the following beneficial effects: the embodiments of the present disclosure can greatly save the locating time and efficiency of memory leak points, release a large amount of manpower costs, and ensure that memory leak problems can be handled more quickly. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] The above contents and other objects, features and advantages of the present disclosure will become more apparent through the following description of the embodiments of the present disclosure with reference to the accompanying drawings, in which:

[0024] Figure 1 The application scenario diagram of the memory leak location method according to the embodiment of the present disclosure is schematically shown;

[0025] Figure 2 A flowchart of a method for locating a memory leak according to an embodiment of the present disclosure is schematically shown;

[0026] Figure 3 A structural block diagram of a memory leak location device according to an embodiment of the present disclosure is schematically shown; and

[0027] Figure 4 A block diagram of an electronic device suitable for implementing a memory leak location method according to an embodiment of the present disclosure is schematically shown. DETAILED DESCRIPTION

[0028] Hereinafter, embodiments of the present disclosure will be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the present disclosure. In the following detailed description, for ease of explanation, many specific details are set forth to provide a comprehensive understanding of the embodiments of the present disclosure. However, it is apparent that one or more embodiments may also be implemented without these specific details. In addition, in the following description, descriptions of known structures and technologies are omitted to avoid unnecessary confusion of the concepts of the present disclosure.

[0029] The terms used herein are only for describing specific embodiments and are not intended to limit the present disclosure. The terms "comprise", "include", etc. used herein indicate the existence of the features, steps, operations and / or components, but do not exclude the existence or addition of one or more other features, steps, operations or components.

[0030] All terms (including technical and scientific terms) used herein have the meanings commonly understood by those skilled in the art unless otherwise defined. It should be noted that the terms used herein should be interpreted as having a meaning consistent with the context of this specification and should not be interpreted in an idealized or overly rigid manner.

[0031] When using expressions such as "at least one of A, B, and C, etc.", they should generally be interpreted according to the meaning of the expression commonly understood by those skilled in the art (for example, "a system having at least one of A, B, and C" should include but is not limited to a system having A alone, B alone, C alone, A and B, A and C, B and C, and / or A, B, C, etc.).

[0032] Before the embodiments of the present disclosure are disclosed in detail, the key technical terms in the embodiments of the present disclosure are explained one by one, as follows:

[0033] Memory leak: refers to the heap memory dynamically allocated in the program that is not released or cannot be released by the program for some reason, resulting in a waste of system memory, causing serious consequences such as slowing down the program and causing the system to crash.

[0034] Pmap technology: provides the memory map of the process. The command is used to view the memory map of the process, that is, the memory address space of the process.

[0035] NMT technology: used to track and understand the memory usage details of the JVM.

[0036] For the location of memory leaks, existing technical solutions all rely on the cooperation of developers and system operation and maintenance personnel to analyze. Developers step by step look at the code and analyze the potential leakage points, and system operation and maintenance personnel cooperate to analyze the potential leakage of memory address information from the operating system level.

[0037] However, existing technical solutions mainly rely on the cooperation and analysis of professional system personnel and developers. Developers generally only know how to develop. It takes too long for developers to manually analyze potential leaks by looking at the code, and the labor cost is high. It is necessary to rely on system operation and maintenance personnel to provide relevant suspicious points of the underlying system memory analysis; system operation and maintenance personnel only know the knowledge related to the system, and may not be able to understand the suspicious points of the analyzed system, which requires the cooperation of developers. There are also potential communication costs between system personnel and developers. Therefore, how to ensure the efficient and accurate location of memory leaks has become a technical problem that needs to be solved urgently.

[0038] In order to solve the technical problems existing in the prior art, an embodiment of the present disclosure provides a memory leak locating method, the method comprising: obtaining a virtual address set, the virtual address comprising a first virtual address set and a second virtual address set, the first virtual address set comprising N first virtual addresses obtained through the system, the second virtual address set comprising K second virtual addresses obtained through the program, N and K being positive integers; deleting L first virtual addresses in the first virtual address set to obtain a third virtual address set, wherein the L first virtual addresses are first virtual addresses that have an intersection with the second virtual address in the second virtual address set, wherein L is an integer greater than or equal to zero; and locating a memory leak point based on the third virtual address set.

[0039] In the embodiments of the present disclosure, in order to solve the technical problem of low efficiency in locating memory leaks, the embodiments of the present disclosure collect the first virtual address set considered to be used at the system level and the second virtual address set considered to be used at the program level, and exclude and filter out the non-program-level virtual addresses in the first virtual address set at the system level to reduce the scope of investigation. The positioning is completed by the filtered virtual address collection to ensure efficient and accurate memory leak positioning. The embodiments of the present disclosure can at least achieve the following beneficial effects: the embodiments of the present disclosure can greatly save the locating time and efficiency of memory leak points, release a large amount of manpower costs, and ensure that memory leak problems can be handled more quickly.

[0040] Figure 1 The application scenario diagram of the memory leak location method according to an embodiment of the present disclosure is schematically shown.

[0041] like Figure 1 As shown, the application scenario 100 according to this embodiment may include a first terminal device 101, a second terminal device 102, a third terminal device 103, a network 104, and a server 105. The network 104 is used to provide a medium for a communication link between the first terminal device 101, the second terminal device 102, the third terminal device 103, and the server 105. The network 104 may include various connection types, such as wired, wireless communication links, or optical fiber cables, etc.

[0042] The user can use the first terminal device 101, the second terminal device 102, and the third terminal device 103 to interact with the server 105 through the network 104 to receive or send messages, etc. Various communication client applications can be installed on the first terminal device 101, the second terminal device 102, and the third terminal device 103, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only for example).

[0043] The first terminal device 101, the second terminal device 102, and the third terminal device 103 may be various electronic devices having display screens and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, and the like.

[0044] The server 105 may be a server that provides various services, such as a background management server (only as an example) that provides support for websites browsed by users using the first terminal device 101, the second terminal device 102, and the third terminal device 103. The background management server may analyze and process the received data such as user requests, and feed back the processing results (such as web pages, information, or data obtained or generated according to user requests) to the terminal device.

[0045] It should be noted that the memory leak locating method provided in the embodiment of the present disclosure can generally be executed by the server 105. Accordingly, the memory leak locating device provided in the embodiment of the present disclosure can generally be set in the server 105. The memory leak locating method provided in the embodiment of the present disclosure can also be executed by a server or server cluster that is different from the server 105 and can communicate with the first terminal device 101, the second terminal device 102, the third terminal device 103 and / or the server 105. Accordingly, the memory leak locating device provided in the embodiment of the present disclosure can also be set in a server or server cluster that is different from the server 105 and can communicate with the first terminal device 101, the second terminal device 102, the third terminal device 103 and / or the server 105.

[0046] 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.

[0047] The following will be based on Figure 1 The scene described by Figure 2 The memory leak location method of the disclosed embodiment is described in detail.

[0048] Figure 2 The flowchart of the memory leak location method according to the embodiment of the present disclosure is schematically shown.

[0049] like Figure 2 As shown, the memory leak locating method of this embodiment includes operations S210 to S230, and the memory leak locating method can be executed by the server 105.

[0050] According to an embodiment of the present disclosure, before operation S210, the method further includes: obtaining a memory usage indicator; and judging whether it is known leakage information based on the memory usage indicator, wherein when the memory usage indicator is judged not to be known leakage information, obtaining the virtual address set is performed.

[0051] The memory usage indicator includes: Pid (process number), container ID (optional, if used in a container, it needs to be obtained) and the corresponding memory usage. It is understandable that the memory usage indicator is easier to obtain than the subsequent virtual address without parsing and calculation. The memory usage indicator can be used to more easily remove some known memory leak events that have been discovered.

[0052] Specifically, a simulation tool is used to perform stress testing to reproduce the memory leak problem in the process. In this process, the memory usage indicators generated by each process are collected, and the memory usage indicators are compared with the historically recorded memory leak history to remove some of the recorded memory leak events.

[0053] In a typical scenario, first, stress test the system through simulation tools to reproduce memory leaks. Memory leaks may only appear under high load or long-term operation. Through simulation tools, high-concurrency or long-term operation scenarios can be simulated to trigger and observe memory leak behaviors. Then, when analyzing memory leaks, specify the specific process (through the process ID Pid) and possible container environment (if the process runs in a Docker container), and output the corresponding memory usage indicators to a file. Finally, analyze whether there are similar problems in the existing memory leak knowledge base. For example, by comparing whether the same or similar events have occurred in history, existing memory leak events can be filtered out.

[0054] According to an embodiment of the present disclosure, obtaining a memory usage indicator includes: obtaining a first memory usage indicator and a second memory usage indicator, wherein the first memory usage indicator is a memory usage indicator before reclaiming free memory fragments in a process, and the second memory usage indicator is a memory usage indicator after reclaiming free memory fragments in a process; judging whether it is known leakage information based on the memory usage indicator includes: calculating the difference between the first memory usage indicator and the second memory usage indicator, and judging that the memory usage indicator is not known leakage information when the difference between the first memory usage indicator and the second memory usage indicator exceeds a preset difference threshold.

[0055] Specifically, use the system recycling function to collect unused memory fragments, record the amount of memory before and after collecting the memory fragments, and determine whether there is a memory leak problem based on the difference in memory usage before and after. If the difference is small, there is no memory leak problem. If the difference is large, it indicates that there is an unknown memory leak problem, and execute operation S210.

[0056] In operation S210, a virtual address set is obtained, the virtual address comprising a first virtual address set and a second virtual address set, the first virtual address set comprising N first virtual addresses obtained through the system, the second virtual address set comprising K second virtual addresses obtained through the program, and N and K are positive integers.

[0057] Specifically, the memory addresses (i.e., the first virtual addresses) used by the application (such as a Java application) are collected through system-level instructions to obtain the first virtual addresses of N processes; the virtual machine memory addresses (i.e., the second virtual addresses) that the application believes it uses are collected through software-level instructions to obtain the second virtual addresses of K processes.

[0058] According to an embodiment of the present disclosure, the method of obtaining a virtual address set includes: for the first virtual address, obtaining a starting address and memory usage information of a target process based on a system instruction; and calculating an ending address based on the starting address and the memory usage information.

[0059] The memory usage information obtained by the system instructions includes the size of the address block, the actual memory size used, and the information of the mapping content.

[0060] Specifically, whether the system uses containers is determined by directly considering the parameter process ID transmitted, and using the pmap technology to obtain the pmap virtual memory address of the process. Each line of the pmap virtual memory address file is read step by step, and only the information containing the starting address, the size of the address block, the real memory size used, and the mapping content in each line is obtained. According to the size of the address block, the decimal to hexadecimal method is used to calculate the end address of the address block and save it in a list.

[0061] According to an embodiment of the present disclosure, the obtaining of the virtual address set also includes: for the second virtual address, determining whether the target process is a process in a container; if the target process is a process in a container, entering the container and obtaining the starting address and memory usage information of the target process based on program instructions; if the target process is not a process in a container, obtaining the starting address and memory usage information of the target process based on program instructions; and calculating the end address based on the starting address and the memory usage information.

[0062] The memory usage information obtained by the program instruction includes the size of the address block and the actual memory size used.

[0063] Specifically, the program level needs to determine whether it is in a container. Determine whether the transmission parameter contains the container ID. If it contains the container ID, use the docker command to enter the container, and then use the nmt technology to obtain the nmt virtual memory address of the Java process in the container and save it in a file. If it does not contain the container ID, use the nmt technology directly, pass in the process pid, obtain the nmt virtual memory address, and save it in a file. 2.1. Read each line of information in the nmt virtual memory address file, filter out useful lines, and obtain the corresponding start address, end address, and memory size, and save them in a list. The filtering conditions are: (1) Lines containing the word committed (committed memory) and the characters "[", "]"; (2) Lines containing the word malloc (dynamic memory allocation), and then go back each line until the line does not contain the characters "[", "]".

[0064] In operation S220, L first virtual addresses in the first virtual address set are deleted to obtain a third virtual address set, wherein the L first virtual addresses are first virtual addresses that have an intersection with the second virtual addresses in the second virtual address set, and L is an integer greater than or equal to zero.

[0065] Since it is necessary to determine which memory areas in the first virtual address are leaked memory areas, and the second virtual address may occupy them, it is necessary to exclude programs (such as JDK) that use the memory. Therefore, the first virtual address that has an intersection with the second virtual address (including completely including the start address + end address, and partially including the end address) is removed.

[0066] For example, by analyzing the pmap virtual memory address list and comparing it with the nmt virtual memory address list, pmap-specific memory address items are filtered out, and the address items do not contain nmt virtual memory addresses.

[0067] According to an embodiment of the present disclosure, the deleting L first virtual addresses in the first virtual address set to obtain the third virtual address set includes: judging whether the starting address and the ending address of the second virtual address are within the starting address and the ending address of the first virtual address; if the starting address and the ending address of the second virtual address are within the starting address and the ending address of the first virtual address, deleting the corresponding first virtual address; and judging whether the ending address of the second virtual address is within the starting address and the ending address of the first virtual address; if the ending address of the second virtual address is within the starting address and the ending address of the first virtual address, deleting the corresponding first virtual address.

[0068] Specifically, the first virtual address is checked to remove the situation where the start address and end address of the second virtual address are within the start address and end address of the second virtual address, and to remove the situation where the end address of the second virtual address is within the start address and end address of the first virtual address.

[0069] For example, 1. Loop through the pmap virtual address memory list to obtain the starting address and the ending address. 2. Nest an nmt virtual memory address list inside to obtain the starting address and the ending address. 3. In the internal loop, first, determine whether the starting address of nmt is included in the starting address and the ending address of pmap. If it is included, create an nmt list (if the list does not exist), add the single item of this nmt to the list, and put the list in the single item of pmap; second, determine whether the ending address of nmt is included in the starting address and the ending address of pmap. If it is included, create an nmt list, add the single item of this nmt to the list, and put the list in the single item of pmap. 4. Filter out the items that do not contain the nmt list.

[0070] In operation S230, a memory leak point is located based on the third virtual address set.

[0071] Specifically, the memory leak point is located to locate the starting address and the ending address of the first virtual address where the memory leak exists. In this process, some first virtual addresses with normal behavior need to be excluded.

[0072] It should be noted that the located memory leak points are the start addresses and end addresses of multiple first virtual addresses, and the developer can subsequently perform more accurate code block positioning based on these start addresses and end addresses.

[0073] According to an embodiment of the present disclosure, the third virtual address set includes M first virtual addresses, M is a positive integer, and locating the memory leak point based on the third virtual address set includes: deleting the first virtual address of the anonymous memory and the first virtual address of the file cache in the third virtual address set, and obtaining the fourth virtual address set as a set of virtual addresses of the memory leak.

[0074] Specifically, it is determined whether it is a file cache situation by judging a corresponding flag of the first virtual address.

[0075] For example, 1. Determine whether the mapping content length of the pmap item is greater than 1. If it is greater than 1, filter it out, otherwise keep it to exclude the situation where the program uses anonymous memory. 2. Then determine whether the actual memory size used by the pmap item is equal to 0. If it is equal to 0, filter it out, otherwise keep it to exclude the situation of file caching. After the above screening, the remaining pmap items may be suspicious memory leak address blocks. Get each pmap item and pack the start address and end address. A log record can be formed later. The log record includes a non-garbled string and a corresponding start address and end address.

[0076] In the embodiments of the present disclosure, in order to solve the technical problem of low efficiency in locating memory leaks, the embodiments of the present disclosure collect the first virtual address set considered to be used at the system level and the second virtual address set considered to be used at the program level, and exclude and filter out the non-program-level virtual addresses in the first virtual address set at the system level to reduce the scope of investigation. The positioning is completed by the filtered virtual address collection to ensure efficient and accurate memory leak positioning. The embodiments of the present disclosure can at least achieve the following beneficial effects: the embodiments of the present disclosure can greatly save the locating time and efficiency of memory leak points, release a large amount of manpower costs, and ensure that memory leak problems can be handled more quickly.

[0077] Based on the above memory leak location method, the present disclosure also provides a memory leak location device. Figure 3 The device is described in detail.

[0078] Figure 3 The structural block diagram of the memory leak location device according to an embodiment of the present disclosure is schematically shown.

[0079] like Figure 3 As shown, the memory leak locating device 300 of this embodiment includes an address acquiring module 310 , an address filtering module 320 and a memory locating module 330 .

[0080] The address acquisition module 310 is used to acquire a virtual address set, the virtual address includes a first virtual address set and a second virtual address set, the first virtual address set includes N first virtual addresses acquired through the system, the second virtual address set includes K second virtual addresses acquired through the program, and N and K are positive integers. In one embodiment, the address acquisition module 310 can be used to perform the operation S210 described above, which will not be repeated here.

[0081] The address filtering module 320 is used to delete L first virtual addresses in the first virtual address set to obtain a third virtual address set, wherein the L first virtual addresses are first virtual addresses that have an intersection with the second virtual addresses in the second virtual address set, wherein L is an integer greater than or equal to 0. In one embodiment, the address filtering module 320 can be used to perform the operation S220 described above, which will not be repeated here.

[0082] The memory location module 330 is used to locate the memory leak point based on the third virtual address set. In one embodiment, the memory location module 330 can be used to perform the operation S230 described above, which will not be described in detail here.

[0083] In the embodiments of the present disclosure, in order to solve the technical problem of low efficiency in locating memory leaks, the embodiments of the present disclosure collect the first virtual address set considered to be used at the system level and the second virtual address set considered to be used at the program level, and exclude and filter out the non-program-level virtual addresses in the first virtual address set at the system level to reduce the scope of investigation. The positioning is completed by the filtered virtual address collection to ensure efficient and accurate memory leak positioning. The embodiments of the present disclosure can at least achieve the following beneficial effects: the embodiments of the present disclosure can greatly save the locating time and efficiency of memory leak points, release a large amount of manpower costs, and ensure that memory leak problems can be handled more quickly.

[0084] According to an embodiment of the present disclosure, the device also includes: a problem filtering module, used to obtain a memory usage indicator; and determine whether it is known leakage information based on the memory usage indicator, wherein if the memory usage indicator is determined not to be known leakage information, the acquisition of the virtual address set is performed.

[0085] According to an embodiment of the present disclosure, the problem filtering module is specifically used to obtain a first memory usage indicator and a second memory usage indicator, wherein the first memory usage indicator is a memory usage indicator before the free memory fragments in the recovery process, and the second memory usage indicator is a memory usage indicator after the free memory fragments in the recovery process; calculate the difference between the first memory usage indicator and the second memory usage indicator, and when the difference between the first memory usage indicator and the second memory usage indicator exceeds a preset difference threshold, determine that the memory usage indicator is not a known leakage information.

[0086] According to an embodiment of the present disclosure, the address acquisition module is specifically used to obtain the starting address and memory usage information of the target process based on the system instructions for the first virtual address; and calculate the ending address based on the starting address and the memory usage information.

[0087] According to an embodiment of the present disclosure, the address acquisition module is further specifically used to determine, for the second virtual address, whether the target process is a process in a container; if the target process is a process in a container, enter the container and obtain the starting address and memory usage information of the target process based on program instructions; if the target process is not a process in a container, obtain the starting address and memory usage information of the target process based on program instructions; and calculate the end address based on the starting address and the memory usage information.

[0088] According to an embodiment of the present disclosure, the address filtering module is specifically used to determine whether the starting address and the ending address of the second virtual address are within the starting address and the ending address of the first virtual address; if the starting address and the ending address of the second virtual address are within the starting address and the ending address of the first virtual address, delete the corresponding first virtual address; and determine whether the ending address of the second virtual address is within the starting address and the ending address of the first virtual address; if the ending address of the second virtual address is within the starting address and the ending address of the first virtual address, delete the corresponding first virtual address.

[0089] According to an embodiment of the present disclosure, the third virtual address set includes M first virtual addresses, M is a positive integer, and the memory location module is specifically used to delete the first virtual address of the anonymous memory and the first virtual address of the file cache in the third virtual address set to obtain a fourth virtual address set as a set of virtual addresses of memory leaks.

[0090] According to an embodiment of the present disclosure, any multiple modules of the address acquisition module 310, the address screening module 320 and the memory positioning module 330 can be combined into one module for implementation, or any one of the modules can be split into multiple modules. Alternatively, at least part of the functions of one or more of these modules can be combined with at least part of the functions of other modules and implemented in one module. According to an embodiment of the present disclosure, at least one of the address acquisition module 310, the address screening module 320 and the memory positioning module 330 can be at least partially implemented as a hardware circuit, such as a field programmable gate array (FPGA), a programmable logic array (PLA), a system on a chip, a system on a substrate, a system on a package, an application specific integrated circuit (ASIC), or can be implemented by hardware or firmware such as any other reasonable way of integrating or packaging the circuit, or implemented in any one of the three implementation methods of software, hardware and firmware or in any appropriate combination of any of them. Alternatively, at least one of the address acquisition module 310, the address screening module 320 and the memory positioning module 330 can be at least partially implemented as a computer program module, and when the computer program module is run, the corresponding function can be executed.

[0091] Figure 4 A block diagram of an electronic device suitable for implementing a memory leak location method according to an embodiment of the present disclosure is schematically shown.

[0092] like Figure 4As shown, the electronic device 400 according to an embodiment of the present disclosure includes a processor 401, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 402 or a program loaded from a storage part 408 to a random access memory (RAM) 403. The processor 401 may include, for example, a general-purpose microprocessor (e.g., a CPU), an instruction set processor and / or a related chipset and / or a dedicated microprocessor (e.g., an application-specific integrated circuit (ASIC)), etc. The processor 401 may also include an onboard memory for caching purposes. The processor 401 may include a single processing unit or multiple processing units for performing different actions of the method flow according to an embodiment of the present disclosure.

[0093] In RAM 403, various programs and data required for the operation of electronic device 400 are stored. Processor 401, ROM 402 and RAM 403 are connected to each other via bus 404. Processor 401 performs various operations of the method flow according to the embodiment of the present disclosure by executing the program in ROM 402 and / or RAM 403. It should be noted that the program can also be stored in one or more memories other than ROM 402 and RAM 403. Processor 401 can also perform various operations of the method flow according to the embodiment of the present disclosure by executing the program stored in the one or more memories.

[0094] According to an embodiment of the present disclosure, the electronic device 400 may further include an input / output (I / O) interface 405, which is also connected to the bus 404. The electronic device 400 may further include one or more of the following components connected to the input / output (I / O) interface 405: an input portion 406 including a keyboard, a mouse, etc.; an output portion 407 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage portion 408 including a hard disk, etc.; and a communication portion 409 including a network interface card such as a LAN card, a modem, etc. The communication portion 409 performs communication processing via a network such as the Internet. A drive 410 is also connected to the input / output (I / O) interface 405 as needed. A removable medium 411, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 410 as needed, so that a computer program read therefrom is installed into the storage portion 408 as needed.

[0095] The present disclosure also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiments; or may exist independently without being assembled into the device / apparatus / system. The above computer-readable storage medium carries one or more programs, and when the above one or more programs are executed, the method according to the embodiment of the present disclosure is implemented.

[0096] According to an embodiment of the present disclosure, the computer-readable storage medium may be a non-volatile computer-readable storage medium, for example, it may include but is not limited to: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, an apparatus or a device. For example, according to an embodiment of the present disclosure, the computer-readable storage medium may include the ROM 402 and / or RAM 403 described above and / or one or more memories other than ROM 402 and RAM 403.

[0097] The embodiment of the present disclosure also includes a computer program product, which includes a computer program, and the computer program contains program code for executing the method shown in the flowchart. When the computer program product is run in a computer system, the program code is used to enable the computer system to implement the method provided by the embodiment of the present disclosure.

[0098] The above functions defined in the system / device of the embodiment of the present disclosure are performed when the computer program is executed by the processor 401. According to the embodiment of the present disclosure, the system, device, module, unit, etc. described above can be implemented by a computer program module.

[0099] In one embodiment, the computer program may rely on tangible storage media such as optical storage devices, magnetic storage devices, etc. In another embodiment, the computer program may also be transmitted and distributed in the form of signals on a network medium, and downloaded and installed through the communication part 409, and / or installed from the removable medium 411. The program code contained in the computer program may be transmitted using any appropriate network medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.

[0100] In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 409, and / or installed from the removable medium 411. When the computer program is executed by the processor 401, the above functions defined in the system of the embodiment of the present disclosure are performed. According to the embodiment of the present disclosure, the system, device, apparatus, module, unit, etc. described above can be implemented by a computer program module.

[0101] According to an embodiment of the present disclosure, the program code for executing the computer program provided by the embodiment of the present disclosure can be written in any combination of one or more programming languages. Specifically, these computing programs can be implemented using high-level process and / or object-oriented programming languages, and / or assembly / machine languages. Programming languages ​​include, but are not limited to, Java, C++, python, "C" language or similar programming languages. The program code can be executed entirely on the user computing device, partially on the user device, partially on the remote computing device, or entirely on the remote computing device or server. In the case of a remote computing device, the remote computing device can be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computing device (for example, using an Internet service provider to connect through the Internet).

[0102] The flow charts and block diagrams in the accompanying drawings illustrate the possible architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0103] It will be appreciated by those skilled in the art that the features described in the various embodiments of the present disclosure may be combined and / or combined in a variety of ways, even if such combinations or combinations are not explicitly described in the present disclosure. In particular, without departing from the spirit and teachings of the present disclosure, the features described in the various embodiments of the present disclosure may be combined and / or combined in a variety of ways. All of these combinations and / or combinations fall within the scope of the present disclosure.

[0104] The embodiments of the present disclosure are described above. However, these embodiments are only for illustrative purposes and are not intended to limit the scope of the present disclosure. Although the embodiments are described above, this does not mean that the measures in the various embodiments cannot be used in combination to advantage. Without departing from the scope of the present disclosure, those skilled in the art may make a variety of substitutions and modifications, which should all fall within the scope of the present disclosure.

Claims

1. A memory leak location method, characterized in that: The method comprises: Acquire a virtual address set, the virtual address comprising a first virtual address set and a second virtual address set, the first virtual address set comprising N first virtual addresses acquired through the system, the second virtual address set comprising K second virtual addresses acquired through the program, N and K being positive integers; Deleting L first virtual addresses in the first virtual address set to obtain a third virtual address set, wherein the L first virtual addresses are first virtual addresses that have an intersection with the second virtual addresses in the second virtual address set, and L is an integer greater than or equal to zero; and A memory leak point is located based on the third virtual address set.

2. The method according to claim 1, characterized in that Before obtaining the virtual address set, the method further includes: Get memory usage metrics; and Whether it is known leakage information is determined based on the memory usage indicator, wherein if the memory usage indicator determines that it is not known leakage information, the acquisition of the virtual address set is performed.

3. The method according to claim 1, characterized in that The obtaining of memory usage indicators includes: Obtaining a first memory usage indicator and a second memory usage indicator, wherein the first memory usage indicator is a memory usage indicator before free memory fragments in a recycling process, and the second memory usage indicator is a memory usage indicator after free memory fragments in a recycling process; The determining whether the information is known leakage based on the memory usage indicator includes: A difference between the first memory usage indicator and the second memory usage indicator is calculated, and when the difference between the first memory usage indicator and the second memory usage indicator exceeds a preset difference threshold, it is determined that the memory usage indicator is not known leakage information.

4. The method according to claim 1, characterized in that: The step of obtaining the virtual address set includes: For the first virtual address, obtaining the starting address and memory usage information of the target process based on the system instruction; and An end address is calculated based on the start address and the memory usage information.

5. The method according to claim 4, characterized in that The obtaining of the virtual address set further includes: For the second virtual address, determining whether the target process is a process in the container; When the target process is a process in a container, enter the container and obtain a start address and memory usage information of the target process based on program instructions; If the target process is not a process in the container, obtaining a start address and memory usage information of the target process based on program instructions; and An end address is calculated based on the start address and the memory usage information.

6. The method according to claim 5, characterized in that The deleting L first virtual addresses in the first virtual address set to obtain a third virtual address set includes: Determine whether the start address and the end address of the second virtual address are within the start address and the end address of the first virtual address; In the case where the start address and the end address of the second virtual address are within the start address and the end address of the first virtual address, deleting the corresponding first virtual address; and Determining whether the end address of the second virtual address is within the start address and the end address of the first virtual address; When the end address of the second virtual address is within the start address and the end address of the first virtual address, the corresponding first virtual address is deleted.

7. The method according to any one of claims 1 to 6, characterized in that: in, The third virtual address set includes M first virtual addresses, where M is a positive integer. The locating the memory leak point based on the third virtual address set includes: The first virtual address of the anonymous memory and the first virtual address of the file cache in the third virtual address set are deleted to obtain a fourth virtual address set as a set of virtual addresses of memory leaks.

8. A memory leak location device, characterized in that: The device comprises: An address acquisition module, used for acquiring a virtual address set, wherein the virtual address includes a first virtual address set and a second virtual address set, wherein the first virtual address set includes N first virtual addresses acquired through the system, and the second virtual address set includes K second virtual addresses acquired through the program, where N and K are positive integers; an address filtering module, configured to delete L first virtual addresses in the first virtual address set to obtain a third virtual address set, wherein the L first virtual addresses are first virtual addresses that have an intersection with the second virtual addresses in the second virtual address set, wherein L is an integer greater than or equal to zero; and A memory locating module is used to locate a memory leak point based on the third virtual address set.

9. An electronic device, comprising: one or more processors; a memory for storing one or more computer programs, It is characterized in that the one or more processors execute the one or more computer programs to implement the steps of the method according to any one of claims 1 to 7.

10. A computer-readable storage medium having a computer program or instruction stored thereon, characterized in that: When the computer program or instruction is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.

11. A computer program product comprising a computer program or instructions, characterized in that When the computer program or instruction is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.