CN106933733B - Method and device for determining memory leak position - Google Patents

Method and device for determining memory leak position Download PDF

Info

Publication number
CN106933733B
CN106933733B CN201511026106.XA CN201511026106A CN106933733B CN 106933733 B CN106933733 B CN 106933733B CN 201511026106 A CN201511026106 A CN 201511026106A CN 106933733 B CN106933733 B CN 106933733B
Authority
CN
China
Prior art keywords
memory
function
address
calling
relation
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201511026106.XA
Other languages
Chinese (zh)
Other versions
CN106933733A (en
Inventor
刘剑青
张�林
邱亚平
朱宏泽
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Huawei Technologies Co Ltd
Original Assignee
Huawei Technologies Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Huawei Technologies Co Ltd filed Critical Huawei Technologies Co Ltd
Priority to CN201511026106.XA priority Critical patent/CN106933733B/en
Publication of CN106933733A publication Critical patent/CN106933733A/en
Application granted granted Critical
Publication of CN106933733B publication Critical patent/CN106933733B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/362Software debugging
    • G06F11/3636Software debugging by tracing the execution of the program

Abstract

The invention discloses a method and a device for determining a memory leakage position, and belongs to the technical field of computers. The method comprises the following steps: in the execution process of a target program, when detecting that a dynamic memory application function is called, acquiring a memory address applied by the dynamic memory application function, acquiring the current calling relationship of each superior calling function of the dynamic memory application function, and recording the corresponding relationship between the memory address and the calling relationship in a memory occupation database; and determining the position of the memory leak according to the recorded calling relationship. By adopting the method and the device, the efficiency of searching the code position of memory leakage can be improved.

Description

Method and device for determining memory leak position
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a method and an apparatus for determining a memory leak location.
Background
For an application program which does not know how much memory space needs to be applied in advance, a memory is dynamically applied during running, after the application program is used, the dynamically applied memory is released, if the dynamically applied memory is not released, the memory is leaked, namely, the application program dynamically applies to the memory, and the memory is not released in time after the memory is used, so that the memory is always occupied.
The technician can check for the application. In the prior art, a method for detecting whether an application program has a memory leak is to record a function calling a dynamic memory application function during an application program running process, for example, when a function calls the dynamic memory application function, the application program will record the a function and a corresponding memory applied by the a function. When the application releases the applied memory, the corresponding record can be deleted. After the current flow of the application program is finished, technicians can find all positions where a certain target function appears in the functions in the remaining records, then search corresponding memory release statements based on each position, and finally determine the code position causing memory leakage.
In the process of implementing the invention, the inventor finds that the prior art has at least the following problems:
based on the above processing method, the recorded function may appear in the whole program for many times, and a technician needs to search for many code positions, so that the efficiency of searching for a code position with memory leakage is low.
Disclosure of Invention
In order to solve the problems in the prior art, embodiments of the present invention provide a method and an apparatus for determining a memory leak location. The technical scheme is as follows:
in a first aspect, a method for determining a memory leak location is provided, where the method includes:
in the execution process of a target program, when detecting that a dynamic memory application function is called, acquiring a memory address applied by the dynamic memory application function, acquiring the current calling relationship of each superior calling function of the dynamic memory application function, and recording the corresponding relationship between the memory address and the calling relationship in a memory occupation database;
and determining the position of the memory leak according to the recorded calling relationship.
In the process of executing the target program, whenever it is detected that the dynamic memory application function is called, a memory with a specified size can be applied according to the parameter value of the function, and the function can return the initial address (which may be called as a memory address) of the applied memory, can acquire the memory address applied by the dynamic memory application function, and can acquire the nesting relationship of each function calling the dynamic application function, that is, the calling relationship of each current upper-level calling function of the dynamic memory application function can be acquired and stored, after the memory address and the calling relationship are acquired, the corresponding relationship between the memory address and the calling relationship can be recorded and stored in a memory usage database, wherein the memory usage database can be a memory usage table or a memory usage tree, that is, the corresponding relationship between the memory address and the calling relationship can be stored in the table, it may also be stored in a tree, such as a red-black tree. The dynamic memory application function may be used for a memory in the dynamic application system. In the execution process of the target program, each time the call relation of each current superior call function of the dynamic memory application function is obtained, the memory application times and the memory release times corresponding to the call relation can be stored. After the call relation corresponding to the memory address is obtained, the position where the memory leak occurs may be determined according to the recorded call relation, and specifically, the computing device may further obtain the application time point corresponding to the memory address after obtaining the memory address applied by the dynamic memory application function, in this case, the memory address where the time length of the application time point from the current time point is greater than the preset time length may be determined, and the call relation corresponding to the memory address may be determined, and further, the position where the memory leak occurs may be determined according to the determined call relation corresponding to the memory address where the time length of the application time point from the current time point is greater than the preset time length.
With reference to the first aspect, in a first possible implementation manner of the first aspect, the method further includes:
when detecting that the dynamic memory application function is called, acquiring a code line identifier for calling the dynamic memory application function;
the recording, in the memory usage database, a correspondence between the memory address and the call relationship includes:
and recording the corresponding relation between the memory address and the code line identification and the calling relation in a memory occupation database.
In the execution process of the target program, when it is detected that the dynamic memory application function is called, an instruction address for calling the dynamic memory application function can be further obtained, and further, the code position of the dynamic memory application function in calling the dynamic memory application function can be determined according to the corresponding relation between the instruction address and the code position, that is, when it is detected that the dynamic memory application function is called, a code line identifier for calling the dynamic memory application function is obtained, wherein the code line identifier can be a line number of a code in the calling function. In this case, the corresponding relationship between the memory address and the code row identifier and the call relationship may be recorded in the memory usage database.
Therefore, the searching range can be reduced through the recorded calling relation and the code line identification, and the code position with memory leakage can be quickly found in the target program.
With reference to the first aspect or the first possible implementation manner of the first aspect, in a second possible implementation manner of the first aspect, the obtaining a call relationship of each current upper-level call function of the dynamic memory application function includes:
acquiring the currently recorded return addresses in the stack of the target program, and determining the arrangement sequence of each return address in the stack;
respectively determining function identifications corresponding to the same instruction addresses as the return addresses according to the corresponding relation between the instruction addresses of the target program and the function identifications to obtain the function identifications corresponding to the return addresses;
and determining the calling relationship of each current upper-level calling function of the dynamic memory application function according to the arrangement sequence of each return address in the stack and the function identifier corresponding to each return address.
When a function in the target program is run, related information of the function is pushed into a stack of the target program, where the related information of the function may be a return address corresponding to the function (when a function is run, the return address of the function is the most advanced stack), a local variable related to the function, and a parameter value of the function, that is, the related information of the function occupies a certain space of the stack. After the function is pushed into the stack, the first address in the stack where the function is located can be obtained through the current stack frame address, wherein the stack frame address can be the first address of a certain section of space of the stack occupied by the relevant information corresponding to the function. And when the function is finished running, the relevant information corresponding to the function is popped. Therefore, the return address currently recorded in the stack of the target program can be obtained, and the arrangement sequence of each return address in the stack can be determined. After the return address currently recorded in the stack of the target program is obtained, the corresponding relationship between the instruction address of the target program and the function identifier, which is the corresponding relationship between the code to which the instruction address corresponds belongs, of the locally stored target program may be obtained, and the function identifier corresponding to the instruction address which is the same as the return address may be obtained in the corresponding relationship between the instruction address of the target program and the function identifier, where the return address of the called function is the instruction address of the calling function, and the function identifier corresponding to each return address is obtained. After the function identifier corresponding to each return address is obtained, the call relationship of each current upper-level call function of the dynamic memory application function can be determined according to the obtained arrangement sequence of each return address in the stack and the function identifier corresponding to each return address. Since the calling function is firstly stacked and the called function is then stacked, the calling relation of the function can be obtained according to the arrangement sequence of each acquired return address in the stack.
With reference to the second possible implementation manner of the first aspect, in a third possible implementation manner of the first aspect, after the obtaining the function identifier corresponding to each return address, the method further includes:
determining function identifiers meeting preset filtering conditions in the function identifiers corresponding to each return address, and selecting the return addresses corresponding to the function identifiers meeting the preset filtering conditions;
determining a calling relationship of each current upper-level calling function of the dynamic memory application function according to the arrangement sequence of each return address in the stack and the function identifier corresponding to each return address, including:
and determining the calling relationship of each current upper-level calling function of the dynamic memory application function according to the arrangement sequence of the selected return addresses in the stack and the function identification meeting the preset filtering condition.
A filter condition (which may be referred to as a preset filter condition) may be preset and stored, wherein the c-standard function or the function for which it is determined that the memory leak does not occur may be filtered out by the preset filter condition. After the function identifier corresponding to the currently recorded return address in the stack of the target program is obtained, whether the corresponding function identifier meets the preset filtering condition or not can be judged, the function identifier meeting the preset filtering condition can be selected from all the obtained function identifiers, and then the return address corresponding to the function identifier meeting the preset filtering condition can be selected according to the obtained corresponding relation between each return address and the function identifier. After filtering out the general part of function identifiers, the calling relationship of each current upper-level calling function of the dynamic memory application function can be determined according to the arrangement sequence of the remaining return addresses in the stack and the function identifiers corresponding to the remaining return addresses.
In this way, the stored information is relatively reduced, so that the storage space can be saved, and the efficiency of determining the position where the memory leak occurs can be improved.
With reference to the first aspect, in a fourth possible implementation manner of the first aspect, the method further includes:
and when the memory corresponding to the memory address is detected to be released, deleting the corresponding relation of the memory address from the memory occupation database.
In the execution process of the target program, whenever it is detected that the memory release function is called, the memory release function may be used to release the memory applied by the dynamic memory application function, that is, when it is detected that the memory corresponding to the memory address is released, the corresponding relationship to which the memory address belongs may be deleted from the memory database.
With reference to the fourth possible implementation manner of the first aspect, in a fifth possible implementation manner of the first aspect, in the executing process of the target program, when it is detected that the dynamic memory application function is invoked, obtaining a memory address applied by the dynamic memory application function, obtaining a call relationship of each current upper-level call function of the dynamic memory application function, and recording a corresponding relationship between the memory address and the call relationship in a memory usage database, includes:
in the execution process of a target program, when a call instruction of the dynamic memory application function is detected, executing a program in a preset dynamic link library to execute the dynamic memory application function, acquiring a memory address applied by the dynamic memory application function, acquiring a call relation of each superior call function of the call instruction, and recording a corresponding relation between the memory address and the call relation in a memory occupation database;
when it is detected that the memory corresponding to the memory address is released, deleting the corresponding relationship to which the memory address belongs from the memory usage database, including:
and when a release instruction of the memory corresponding to the memory address is detected, executing a program in the preset dynamic link library, releasing the memory, and deleting the corresponding relation of the memory address from the memory occupation database.
A dynamic link library (which may be referred to as a preset dynamic link library) may be preset, and in the process of executing a target program, when a call instruction of a dynamic memory application function is detected, a program in the preset dynamic link library may be executed so as to execute the dynamic memory application function, at this time, the program in the preset dynamic memory application function is equivalent to a specific code of the dynamic memory application function, and when all the programs in the preset dynamic memory application function are completely executed, the execution of the preset dynamic memory application function is equivalent to the completion of the execution of the dynamic memory application function. Specifically, the program in the preset dynamic link library is executed, the memory address applied by the dynamic memory application function can be obtained, and the call relationship of each superior call function of the call instruction, that is, the call relationship of each superior call function of the target program calling the dynamic memory application function, is obtained, and the corresponding relationship between the memory address and the call relationship can be recorded in the memory occupancy database.
In the execution process of the target program, when a release instruction for the memory corresponding to the memory address is detected, the program in the preset dynamic link library can be executed to release the memory corresponding to the memory address, and the corresponding relation to the memory address can be deleted from the memory occupation database.
In addition, by the method, if the target program cannot be modified, when the target program is a standard c function or a third-party program, a technician cannot modify the source code, and also can obtain related information by executing the program in the preset dynamic link library so as to perform related processing for subsequently determining the position where the memory leakage occurs.
With reference to the first aspect or the first to fifth possible implementation manners of the first aspect, in a sixth possible implementation manner of the first aspect, a memory application number and a memory release number corresponding to each invocation relationship are determined, and a difference value between the memory application number and the memory release number corresponding to each invocation relationship is determined;
determining a difference value meeting a preset selection condition from the difference values of the memory application times and the memory release times corresponding to each calling relationship, and selecting a target calling relationship corresponding to the difference value meeting the preset selection condition;
and determining the program position corresponding to the target calling relation as the position of memory leakage.
A difference acquisition trigger event may be preset, where the difference acquisition trigger event may be a preset difference acquisition period, or may be a corresponding relationship between a stored memory address and a call relationship, and when a preset difference acquisition trigger event is detected, a memory application frequency and a memory release frequency corresponding to each stored call relationship may be determined, and a difference between the memory application frequency and the memory release frequency corresponding to each call relationship may be determined. Then, the difference value meeting the preset selection condition can be determined in the difference value between the memory application times and the memory release times corresponding to each calling relationship, and the target calling relationship corresponding to the difference value meeting the preset selection condition can be selected, and further, the program position corresponding to the target calling relationship can be determined as the position where the memory leakage occurs, that is, the code position where the target calling relationship occurs in the target program can be determined as the position where the memory leakage occurs.
With reference to the sixth possible implementation manner of the first aspect, in a seventh possible implementation manner of the first aspect, a preset number of maximum differences are obtained from differences between the memory application times and the memory release times corresponding to each calling relationship, and a target calling relationship corresponding to the preset number of maximum differences is determined.
After the difference value between the memory application times and the memory release times corresponding to each calling relationship is determined, the memory application times and the memory release times can be sequenced according to the sequence of the difference values from large to small, and the target calling relationships corresponding to the preset number of difference values arranged in the front row can be obtained from the difference values
Therefore, the determined target calling relation is the position where the memory leak is most likely to occur, and the position where the memory leak occurs can be detected in real time in the execution process of the target program.
In a second aspect, an apparatus for determining a memory leak location is provided, the apparatus comprising a processor and a memory, wherein:
the processor is used for acquiring a memory address applied by a dynamic memory application function when detecting that the dynamic memory application function is called in the execution process of a target program, acquiring the current calling relation of each superior calling function of the dynamic memory application function, and recording the corresponding relation between the memory address and the calling relation in a memory occupation database established in the memory; and determining the position of the memory leak according to the recorded calling relationship.
With reference to the second aspect, in a first possible implementation manner of the second aspect, the processor is further configured to:
when detecting that the dynamic memory application function is called, acquiring a code line identifier for calling the dynamic memory application function;
the processor is specifically configured to:
and recording the corresponding relation between the memory address and the code line identification and the calling relation in a memory occupation database.
With reference to the second aspect or the first possible implementation manner of the second aspect, in a second possible implementation manner of the second aspect, the processor is specifically configured to:
acquiring the currently recorded return addresses in the stack of the target program, and determining the arrangement sequence of each return address in the stack;
respectively determining function identifications corresponding to the same instruction addresses as the return addresses according to the corresponding relation between the instruction addresses of the target program and the function identifications to obtain the function identifications corresponding to the return addresses;
and determining the calling relationship of each current upper-level calling function of the dynamic memory application function according to the arrangement sequence of each return address in the stack and the function identifier corresponding to each return address.
With reference to the second possible implementation manner of the second aspect, in three possible implementation manners of the second aspect, the processor is further configured to:
determining function identifiers meeting preset filtering conditions in the function identifiers corresponding to each return address, and selecting the return addresses corresponding to the function identifiers meeting the preset filtering conditions;
the processor is specifically configured to:
and determining the calling relationship of each current upper-level calling function of the dynamic memory application function according to the arrangement sequence of the selected return addresses in the stack and the function identification meeting the preset filtering condition.
With reference to the second aspect, in a fourth possible implementation manner of the second aspect, the processor is further configured to:
and when the memory corresponding to the memory address is detected to be released, deleting the corresponding relation of the memory address from the memory occupation database.
With reference to the fourth possible implementation manner of the second aspect, in a fifth possible implementation manner of the second aspect, the processor is specifically configured to:
in the execution process of a target program, when a call instruction of the dynamic memory application function is detected, executing a program in a preset dynamic link library to execute the dynamic memory application function, acquiring a memory address applied by the dynamic memory application function, acquiring a call relation of each superior call function of the call instruction, and recording a corresponding relation between the memory address and the call relation in a memory occupation database;
and when a release instruction of the memory corresponding to the memory address is detected, executing a program in the preset dynamic link library, releasing the memory, and deleting the corresponding relation of the memory address from the memory occupation database.
With reference to the second aspect or the first to fifth possible implementation manners of the second aspect, in a sixth possible implementation manner of the second aspect, the processor is specifically configured to:
determining the memory application times and the memory release times corresponding to each calling relation, and determining the difference value of the memory application times and the memory release times corresponding to each calling relation;
determining a difference value meeting a preset selection condition from the difference values of the memory application times and the memory release times corresponding to each calling relationship, and selecting a target calling relationship corresponding to the difference value meeting the preset selection condition;
and determining the program position corresponding to the target calling relation as the position of memory leakage.
With reference to the sixth possible implementation manner of the second aspect, in a seventh possible implementation manner of the second aspect, the processor is specifically configured to:
and acquiring a preset number of maximum difference values from the difference values of the memory application times and the memory release times corresponding to each calling relationship, and determining a target calling relationship corresponding to the preset number of maximum difference values.
In a third aspect, an apparatus for determining a memory leak location is provided, including:
an obtaining module, which may be specifically implemented by a processor, configured to, in an execution process of a target program, when it is detected that a dynamic memory application function is invoked, obtain a memory address applied by the dynamic memory application function, obtain a call relationship of current upper-level call functions of the dynamic memory application function, and record, in a memory occupancy database, a corresponding relationship between the memory address and the call relationship;
the determining module, which may be specifically implemented by a processor, is configured to determine a location where the memory leak occurs according to the call relationship recorded by the obtaining module.
With reference to the third aspect, in a first possible implementation manner of the third aspect, the obtaining module is further configured to:
when detecting that the dynamic memory application function is called, acquiring a code line identifier for calling the dynamic memory application function;
the acquisition module is specifically configured to:
and recording the corresponding relation between the memory address and the code line identification and the calling relation in a memory occupation database.
With reference to the third aspect or the first possible implementation manner of the third aspect, in a second possible implementation manner of the third aspect, the obtaining module is specifically configured to:
acquiring the currently recorded return addresses in the stack of the target program, and determining the arrangement sequence of each return address in the stack;
the determining module is specifically configured to:
respectively determining function identifications corresponding to the same instruction addresses as the return addresses according to the corresponding relation between the instruction addresses of the target program and the function identifications to obtain the function identifications corresponding to the return addresses;
and determining the calling relationship of each current upper-level calling function of the dynamic memory application function according to the arrangement sequence of each return address in the stack and the function identifier corresponding to each return address.
With reference to the second possible implementation manner of the third aspect, in a third possible implementation manner of the third aspect, the determining module is further configured to:
determining function identifiers meeting preset filtering conditions in the function identifiers corresponding to each return address, and selecting the return addresses corresponding to the function identifiers meeting the preset filtering conditions;
the determining module is specifically configured to:
and determining the calling relationship of each current upper-level calling function of the dynamic memory application function according to the arrangement sequence of the selected return addresses in the stack and the function identification meeting the preset filtering condition.
With reference to the third aspect, in a fourth possible implementation manner of the third aspect, the method further includes:
and the deleting module is used for deleting the corresponding relation of the memory address from the memory occupation database when the memory corresponding to the memory address is detected to be released.
With reference to the fourth possible implementation manner of the third aspect, in a fifth possible implementation manner of the third aspect, the obtaining module is specifically configured to:
in the execution process of a target program, when a call instruction of the dynamic memory application function is detected, executing a program in a preset dynamic link library to execute the dynamic memory application function, acquiring a memory address applied by the dynamic memory application function, acquiring a call relation of each superior call function of the call instruction, and recording a corresponding relation between the memory address and the call relation in a memory occupation database;
the deletion module is specifically configured to:
and when a release instruction of the memory corresponding to the memory address is detected, executing a program in the preset dynamic link library, releasing the memory, and deleting the corresponding relation of the memory address from the memory occupation database.
With reference to the third aspect or the first to fifth possible implementation manners of the third aspect, in a sixth possible implementation manner of the third aspect, the determining module is specifically configured to:
determining the memory application times and the memory release times corresponding to each calling relation, and determining the difference value of the memory application times and the memory release times corresponding to each calling relation;
determining a difference value meeting a preset selection condition from the difference values of the memory application times and the memory release times corresponding to each calling relationship, and selecting a target calling relationship corresponding to the difference value meeting the preset selection condition;
and determining the program position corresponding to the target calling relation as the position of memory leakage.
With reference to the sixth possible implementation manner of the third aspect, in a seventh possible implementation manner of the third aspect, the determining module is specifically configured to:
and acquiring a preset number of maximum difference values from the difference values of the memory application times and the memory release times corresponding to each calling relationship, and determining a target calling relationship corresponding to the preset number of maximum difference values.
The technical scheme provided by the embodiment of the invention has the following beneficial effects:
in the embodiment of the invention, in the execution process of a target program, when a dynamic memory application function is detected to be called, a memory address applied by the dynamic memory application function is obtained, the calling relation of each current superior calling function of the dynamic memory application function is obtained, the corresponding relation between the memory address and the calling relation is recorded in a memory occupation database, and the position where memory leakage occurs is determined according to the recorded calling relation. Therefore, in the execution process of the target program, the searching range can be reduced through the recorded calling relation, and the code position with memory leakage can be quickly found in the target program, so that the efficiency of searching the code position with memory leakage can be improved.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings used in the description of the embodiments will be briefly introduced below.
FIG. 1 is a schematic structural diagram of a computing device according to an embodiment of the present invention;
fig. 2 is a flowchart of a method for determining a memory leak location according to an embodiment of the present invention;
fig. 3 is a flowchart of a method for obtaining a call relation according to an embodiment of the present invention;
FIG. 4 is a diagram illustrating a fetch return address according to an embodiment of the present invention;
fig. 5 is a schematic structural diagram of an apparatus for determining a memory leak location according to an embodiment of the present invention;
fig. 6 is a schematic structural diagram of an apparatus for determining a memory leak location according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, embodiments of the present invention will be described in detail with reference to the accompanying drawings.
The embodiment of the invention provides a method for determining a memory leak position. The computing device may be a Personal Computer (PC) or a server.
The computing device may include a processor 110, a memory 120, and the processor 110 may be connected to the memory 120, as shown in fig. 1. The processor 110 may be a control center of the computing device, connect various parts of the computing device using various interfaces and lines, perform various functions of the computing device and process data by running or executing software programs and/or modules stored in the memory 120 and calling up data stored in the memory 120, thereby monitoring the computing device as a whole. Processor 110 may include one or more processing units; the processor 110 may be a general-purpose processor, and includes a Central Processing Unit (CPU), a Network Processor (NP), and the like; but may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other programmable logic device, etc. The memory 110 may be used to store programs. In particular, the program may include program code including computer operating instructions. The memory 120 may include RAM, and may further include a non-volatile memory (non-volatile memory), such as at least one disk memory. The processor 110 executes the program codes stored in the memory 120 to implement various functions, wherein the memory may also be used to store data required and generated during the processes described below in the present invention.
As shown in fig. 2, the specific processing flow of the method may include the following steps:
step 201, in the execution process of the target program, when it is detected that the dynamic memory application function is called, acquiring the memory address applied by the dynamic memory application function, acquiring the current calling relationship of each superior calling function of the dynamic memory application function, and recording the corresponding relationship between the memory address and the calling relationship in the memory occupation database.
The target application program may be a program that is detected whether a memory leak occurs, that is, whether a memory applied by the dynamic memory application function is used is detected, and the dynamically applied memory is released in time when the use of the memory is finished.
In implementation, when a technician develops software (or called an application program) and writes a corresponding program, the memory that has been dynamically applied for and is no longer used is often inadvertently or erroneously not released, thereby causing a memory leak problem. The memory resources are limited, after dynamically applying for the memory each time, the subsequently applicable memory resources are reduced, if the memory leaks, the dynamically applied memory is always in an occupied state, the subsequently unreleased memory cannot be applied, when the program leaks from multiple places, the memory resources are relatively tense, the program can run slowly, the normal work of the program is affected, and even under severe conditions, for example, the subsequent applicable memory does not exist, the program will have errors and cannot continue to run, and further, the user cannot normally run the software, so that the detection and the positioning of the position of the memory leak in the program become more important.
In the process of executing the target program, whenever it is detected that a dynamic memory application function is called, where the dynamic memory application function may be used for a memory in a dynamic application system, a memory with a size specified by a parameter value of the function may be applied, and the function may return to a first address (which may be referred to as a memory address) of the memory applied, may obtain a memory address applied by the dynamic memory application function, and may obtain a nested relation of functions calling the dynamic application function, that is, may obtain a calling relation of current upper-level calling functions of the dynamic memory application function, and store the calling relation, for example, the dynamic memory application function is an M function, a function calls an M function, b function calls a function, when b function is run, a function is called to run, and when a function is run, an M function is called, the memory is dynamically applied through the M function, at this time, the computing device detects that the M function is called, and further, may obtain a memory address corresponding to the memory to which the M function applies, and may obtain a call relationship of each current upper-level call function of the M function, that is, a function is called by the b function, and an a function calls the M function and stores it, or may only obtain and store the b function calling the a function, which means the M function called by the a function at this time. After the memory address and the call relation are obtained, the corresponding relation between the memory address and the call relation may be recorded and stored in a memory usage database, where the memory usage database may be a memory usage table or a memory usage tree, that is, the corresponding relation between the memory address and the call relation may be stored in the table or the tree, for example, a red-black tree.
In addition, when storing the corresponding relationship between the memory address and the call relationship, a hierarchical storage mode may be adopted, specifically, different storage areas may be set in the memory occupancy database, and when detecting that the dynamic memory application function is called, the corresponding relationship between the memory address and the call relationship may be stored in the first storage area. It is also possible to preset a switch memory area condition (which may be referred to as a preset switch memory area condition), when the first correspondence relationship between the memory address stored in the first memory area and the call relationship satisfies the preset switch memory area condition, the first corresponding relation may be switched to the second storage area for storage, otherwise, the related processing of switching the storage areas may not be performed, for example, the condition of switching the memory area in advance may be that the time length from the application time point to the current time point is longer than a preset time length, in this case, the computing device may further obtain and record an application time point when the dynamic memory application function is detected to be invoked, and when a preset detection period is reached, or detecting whether the corresponding relation between the memory address already stored in the first storage area and the call relation meets the preset storage area switching condition or not when the corresponding relation between the memory address and the call relation is detected.
Optionally, in the execution process of the target program, a code line identifier for calling the dynamic memory application function may also be obtained, and accordingly, the processing process may be as follows: and when detecting that the dynamic memory application function is called, acquiring a code line identifier for calling the dynamic memory application function. Further, the following processing may be performed: and recording the corresponding relation between the memory address and the code line identification and calling relation in a memory occupation database.
In implementation, in the execution process of the target program, when it is detected that the dynamic memory application function is called, an instruction address for calling the dynamic memory application function may also be obtained, and further, a code position of the dynamic memory application function in calling the dynamic memory application function may be determined according to a corresponding relationship between the instruction address and the code position, that is, when it is detected that the dynamic memory application function is called, a code line identifier for calling the dynamic memory application function is obtained, where the code line identifier may be a line number of a code in the calling function. In this case, the corresponding relationship between the memory address and the code row identifier and the call relationship may be recorded in the memory usage database.
Optionally, the corresponding relationship between the memory address in the memory usage database and the call relationship may also be deleted, and correspondingly, the processing procedure may be as follows: and when the memory corresponding to the memory address is released, deleting the corresponding relation of the memory address from the memory occupation database.
In implementation, in the execution process of the target program, whenever it is detected that the memory release function is called, the memory release function may be used to release the memory applied by the dynamic memory application function, that is, when it is detected that the memory corresponding to the memory address is released, the corresponding relationship to which the memory address belongs may be deleted from the memory database.
Optionally, in the execution process of the target program, the preset dynamic link library may be loaded to record the corresponding relationship between the memory address and the call relationship, so as to determine the relevant processing of the location where the memory leak occurs in the subsequent step, and correspondingly, the processing procedure in step 201 may be as follows: in the execution process of a target program, when a call instruction of a dynamic memory application function is detected, executing a program in a preset dynamic link library to execute the dynamic memory application function, acquiring a memory address applied by the dynamic memory application function, acquiring a call relation of each superior call function of the call instruction, and recording a corresponding relation between the memory address and the call relation in a memory occupation database. The following processing may also be performed: when a release instruction of the memory corresponding to the memory address is detected, executing a program in a preset dynamic link library, releasing the memory, and deleting the corresponding relation of the memory address from the memory occupation database.
In implementation, a dynamic link library (which may be referred to as a preset dynamic link library) may be preset, and in the execution process of a target program, when a call instruction of a dynamic memory application function is detected, a program in the preset dynamic link library may be executed so as to execute the dynamic memory application function, at this time, the program in the preset dynamic memory application function is equivalent to a specific code of the dynamic memory application function, and when all the programs in the preset dynamic memory application function are completely executed, the execution of the program is equivalent to the completion of the execution of the dynamic memory application function. Specifically, the program in the preset dynamic link library is executed, the memory address applied by the dynamic memory application function may be obtained in the manner described in step 201, and the call relationship of each upper-level call function of the call instruction, that is, the call relationship of each upper-level call function that calls the dynamic memory application function in the target program is obtained, and the corresponding relationship between the memory address and the call relationship may be recorded in the memory usage database. In addition, by the method, if the target program cannot be modified, when the target program is a standard c function or a third-party program, a technician cannot modify the source code, and also can obtain related information by executing the program in the preset dynamic link library so as to perform related processing for subsequently determining the position where the memory leakage occurs.
In the execution process of the target program, when a release instruction for the memory corresponding to the memory address is detected, the program in the preset dynamic link library can be executed to release the memory corresponding to the memory address, and the corresponding relation to the memory address can be deleted from the memory occupation database.
Step 202, determining the position of the memory leak according to the recorded calling relationship.
In implementation, after the call relation corresponding to the memory address is obtained, the location where the memory leak occurs may be determined according to the recorded call relation, specifically, the computing device may further obtain the application time point corresponding to the memory address after obtaining the memory address applied by the dynamic memory application function, in this case, the memory address where the duration of the application time point from the current time point is greater than the preset duration may be determined, and the call relation corresponding to the memory address may be determined, and further, the location where the memory leak occurs may be determined according to the determined call relation corresponding to the memory address where the duration of the application time point from the current time point is greater than the preset duration.
Optionally, the location where the memory leak occurs may be determined by determining a call relationship that meets a preset selection condition, and correspondingly, the processing procedure in step 202 may be as follows: determining the memory application times and the memory release times corresponding to each calling relationship, determining the difference value of the memory application times and the memory release times corresponding to each calling relationship, determining the difference value meeting a preset selection condition in the difference value of the memory application times and the memory release times corresponding to each calling relationship, and selecting a target calling relationship corresponding to the difference value meeting the preset selection condition; and determining the program position corresponding to the target calling relation as the position of memory leakage.
In implementation, in the execution process of the target program, when the call relationship of each current upper-level call function of the dynamic memory application function is obtained, the memory application times and the memory release times corresponding to the call relationship may be stored, that is, the target program may call the dynamic memory application function multiple times at multiple code positions, and the call relationships of each upper-level call function calling the dynamic memory application function at multiple positions may be the same, at this time, the related information of the same call relationship may be uniformly stored, that is, for the call relationship appearing multiple times, the call relationship is stored only once, and the memory application times corresponding to the call relationship may be updated every time the call relationship appears in the target program. Specifically, each time the call relationship of each current upper-level call function of the dynamic memory application function is obtained, it may be determined whether the call relationship is already stored, if the call relationship is already stored, the memory application frequency corresponding to the call relationship may be updated, that is, 1 may be added to the memory application frequency, if the call relationship is not stored, that is, the target program appears for the first time at this time, the call relationship may be stored, and meanwhile, the memory application frequency corresponding to the call relationship may be recorded as a preset initial value, for example, 1. In addition, for the case of storing the memory application times and the memory release times corresponding to the call relationship, the memory occupancy database records the corresponding relationship between the memory address and the call relationship, and may record the corresponding relationship between the memory address and the identifier of the call relationship, where the identifier of the call relationship has uniqueness, and may be the memory address corresponding to the call relationship, or may be the identifier of each call relationship mark, such as an arabic numeral, according to a preset rule.
For the condition that the memory corresponding to the memory address is released is detected, the memory address corresponding to the released memory can be obtained, further, the call relation corresponding to the memory address corresponding to the released memory can be determined in the corresponding relation between the memory address and the call relation recorded in the memory occupation database, the memory release frequency corresponding to the call relation can be obtained according to the determined call relation, the memory release frequency is updated, and the memory release frequency can be added by 1. In addition, for the case of storing the correspondence between the memory address and the call relation in the hierarchical storage manner, when it is detected that the memory corresponding to the memory address is released, the call relation corresponding to the memory address corresponding to the released memory may be first searched in the correspondence between the memory address and the call relation stored in the first storage area, and if the memory address corresponding to the released memory is not included in the first storage area, the call relation corresponding to the memory address corresponding to the released memory may be searched in the correspondence between the memory address and the call relation stored in the second storage area. Therefore, the efficiency of determining the calling relationship corresponding to the memory address corresponding to the released memory can be effectively improved.
A difference acquisition trigger event may be preset, where the difference acquisition trigger event may be a preset difference acquisition period, or may be a corresponding relationship between a stored memory address and a call relationship, and when a preset difference acquisition trigger event is detected, a memory application frequency and a memory release frequency corresponding to each stored call relationship may be determined, and a difference between the memory application frequency and the memory release frequency corresponding to each call relationship may be determined. Then, the difference value meeting the preset selection condition can be determined in the difference value between the memory application times and the memory release times corresponding to each calling relationship, and the target calling relationship corresponding to the difference value meeting the preset selection condition can be selected, and further, the program position corresponding to the target calling relationship can be determined as the position where the memory leakage occurs, that is, the code position where the target calling relationship occurs in the target program can be determined as the position where the memory leakage occurs.
Optionally, the location where the memory leak occurs may be determined according to a call relationship corresponding to a difference between a larger number of memory applications and a larger number of memory releases, and accordingly, the processing procedure may be as follows: and obtaining a preset number of maximum difference values from the difference values of the memory application times and the memory release times corresponding to each calling relationship, and determining a target calling relationship corresponding to the preset number of maximum difference values.
In implementation, after the difference between the memory application times and the memory release times corresponding to each calling relationship is determined, the memory application times and the memory release times can be sorted according to the sequence of the difference from large to small, and the target calling relationships corresponding to the preset number of difference arranged in the front row can be obtained from the difference.
In addition, after the target call relationship corresponding to the preset number of maximum difference values is obtained, the target call relationship corresponding to the selected preset number of maximum difference values may be updated, specifically, when it is detected that the difference between the memory application times and the memory release times corresponding to other call relationships except the target call relationship increases, the difference between the memory application times and the memory release times corresponding to other call relationships may be compared with the difference between the memory application times and the memory release times corresponding to each target call relationship, and if the former is greater than the latter, the target call relationship may be updated, that is, the other call relationship corresponding to the larger difference between the memory application times and the memory release times may replace the call relationship corresponding to the smaller difference between the memory application times and the memory release times in the target call relationship, that is, in the process of executing the target program, the difference value between the memory application times and the memory release times corresponding to the selected target calling relationship is the largest in the difference values between the memory application times and the memory release times corresponding to all the calling relationships. In addition, the historical maximum unreleased times corresponding to each call relation can be recorded, wherein the historical maximum unreleased times can be the maximum difference between the memory application times and the memory release times corresponding to the call relations so far, when the difference value between the memory application times and the memory release times corresponding to other calling relations except the target calling relation is detected to be larger than the corresponding historical maximum unreleased times, the difference value between the memory application times and the memory release times corresponding to other calling relations can be compared with the difference value between the memory application times and the memory release times corresponding to each target calling relation, if the former is larger than the latter, the target calling relation can be updated, that is, the other calling relationship corresponding to the difference between the greater number of memory applications and the greater number of memory releases may replace the calling relationship corresponding to the difference between the smaller number of memory applications and the smaller number of memory releases in the target calling relationship.
The embodiment of the invention also provides a method for acquiring the call relation, wherein the call relation of each current upper-level call function of the dynamic memory application function can be acquired through the current recorded information in the stack of the target program.
As shown in fig. 3, the specific processing flow of the method may include the following steps:
step 301, obtaining the return address currently recorded in the stack of the target program, and determining the arrangement order of each return address in the stack.
For example, when the a function is called on the 50 th line of the b function and is run to the 50 th line of the b function, the a function starts to run, and if the a function is run after the a function is returned, the 51 th line of the b function is executed, the instruction address corresponding to the 51 st line code of the b function may be called as a return address, and may be called as a return address of the a function.
In an implementation, when a computing device runs a target program, a program is loaded into a memory, where the memory storing the program may be referred to as a code segment, each code (instruction) in the program corresponds to a memory address, and when a function in the target program is run, information related to the function is pushed into a stack of the target program, where the information related to the function may be a return address corresponding to the function (when a function is run, the return address of the function is the most advanced stack), a local variable related to the function, and a parameter value of the function, that is, the information related to the function occupies a certain space in the stack. After the function is pushed into the stack, the first address of the function in the stack can be obtained through the current stack frame address, wherein the stack frame address can be the first address of a certain section of space of the stack occupied by the relevant information corresponding to the function, that is, the position of the return address of the function in the stack can be obtained through the stack frame address. And when the function is finished running, the relevant information corresponding to the function is popped.
To sum up, if there are multiple levels of function calls, for a function that has not been run, the stack stores the related information of each function, that is, the return address corresponding to each function is stored, and when the function is run, the related information of the function is pushed onto the stack, so that the current function call relationship can be obtained according to the information recorded in the stack, and if there is new function related information pushed onto the stack, the stack frame address corresponding to the previous function (the function that calls the currently pushed function) is also pushed onto the stack for storage, wherein the stack frame address corresponding to the previous function and the return address of the currently running function are distributed adjacently in the stack, and the current stack frame address is the stack frame address corresponding to the currently running function, so that we can obtain the return address corresponding to the current function according to the current stack frame address, and then obtain the return address of the previous function according to the frame address distributed adjacently to the return address, and so on, the return address currently recorded in the stack of the target program can be determined, and the arrangement order of each return address in the stack can be determined, for example, the main function of the target program calls the b function, the b function calls the a function, the a function calls the M function, when the b function is executed, the relevant information of the b function is pushed, the return address of the b function is pushed first (if the main function calls the b function at line 50, the return address of the b function can be the address of the main function at line 51 in the code segment), as shown in fig. 4, the current stack frame address is the first address of the b function in the stack, such as 0x123470, when the a function is executed, the relevant information of the b function is pushed, the current stack frame address is the first address of the a function in the stack, that is the address of the return address of the a function in the stack, such as 0x123448, at this time the first address of the b function in the stack is pushed into the stack, such as 0x123470, and the return address of the a function is distributed adjacent to the stack frame address of the b function, for a 32-bit system, the address of the stack of 0x123470 may be 0x123452, when the M function is executed, the related information of the M function is pushed, the current stack frame address is the first address of the M function in the stack, that is, the address of the return address of the M function in the stack, for example, 0x123412, at this time, the first address of the a function in the stack, 0x123448, is pushed into the stack, and the return address of the M function is distributed adjacent to the stack frame address of the a function, that is, 0x123416, so that the return address of the M function, that is, the information stored in the address 0x123412, can be obtained according to the current stack frame address of 0x123412, the address of the M function in the stack where the return address of the a is located, that is 0x123448, can be obtained according to the return address of the b function, that is stored in the address 0x123452 distributed adjacent to the current stack, that is 0x123412, the address of the stack 470, that is obtained in the stack of the stack, therefore, the return addresses currently recorded in the stack of the target program can be obtained, the arrangement sequence of each return address in the stack can be determined, and the return addresses can be stored.
Step 302, according to the corresponding relationship between the instruction address of the target program and the function identifier, respectively determining the function identifier corresponding to the instruction address which is the same as each return address, and obtaining the function identifier corresponding to each return address.
The instruction address may be an address corresponding to each instruction in the target program, that is, a location in the code segment.
In implementation, after obtaining a return address currently recorded in a stack of a target program, a corresponding relationship between an instruction address of the target program and a function identifier, that is, a corresponding relationship between a code corresponding to the instruction address, which is stored locally, and a function identifier corresponding to an instruction address identical to the return address in the corresponding relationship between the instruction address of the target program and the function identifier, where the return address of a called function is an instruction address of a calling function, a function identifier corresponding to each return address is obtained, for example, a function b calls a function, a function calls M function, and a function identifier corresponding to the return address of the M function (that is, an instruction address corresponding to a next code calling the M function code in the a function) and a corresponding relationship between the instruction address corresponding to a code in the a function and the a function are obtained, by analogy, the function corresponding to the return address of the function a can be obtained as the function b.
Optionally, after obtaining the function identifier corresponding to each return address, the obtained function identifier may also be filtered, and accordingly, the processing procedure may be as follows: and determining the function identifiers meeting the preset filtering condition from the function identifiers corresponding to each return address, and selecting the return addresses corresponding to the function identifiers meeting the preset filtering condition.
In implementation, a filter condition (which may be referred to as a preset filter condition) may be preset and stored, wherein the c-standard function or the function that has been determined that no memory leak occurs may be filtered out by the preset filter condition. After the function identifier corresponding to the currently recorded return address in the stack of the target program is obtained, whether the corresponding function identifier meets the preset filtering condition or not can be judged, the function identifier meeting the preset filtering condition can be selected from all the obtained function identifiers, and then the return address corresponding to the function identifier meeting the preset filtering condition can be selected according to the obtained corresponding relation between each return address and the function identifier.
Step 303, determining a calling relationship of each current upper-level calling function of the dynamic memory application function according to an arrangement sequence of each return address in the stack and a function identifier corresponding to each return address.
In implementation, after the function identifier corresponding to each return address is obtained, the call relationship of each current upper-level call function of the dynamic memory application function may be determined according to the obtained arrangement order of each return address in the stack and the function identifier corresponding to each return address. Since the calling function is firstly stacked and the called function is then stacked, the calling relation of the function can be obtained according to the arrangement sequence of each acquired return address in the stack.
Optionally, for the case of filtering the function identifier corresponding to each return address, correspondingly, the processing procedure of step 303 may be as follows: and determining the calling relationship of each current upper-level calling function of the dynamic memory application function according to the arrangement sequence of the selected return addresses in the stack and the function identification meeting the preset filtering condition.
In implementation, after filtering out a general part of function identifiers, the call relationship of each current upper-level call function of the dynamic memory application function can be determined according to the arrangement sequence of the remaining return addresses in the stack and the function identifiers corresponding to the remaining return addresses. In addition, in order to improve the processing speed, the number of the acquired return addresses can be preset, and further, the call relationship of each current higher-level call function of the call relationship dynamic memory application function can be determined according to the preset number of return addresses and the arrangement sequence of the return addresses in the stack.
In the embodiment of the invention, in the execution process of a target program, when a dynamic memory application function is detected to be called, a memory address applied by the dynamic memory application function is obtained, the calling relation of each current superior calling function of the dynamic memory application function is obtained, the corresponding relation between the memory address and the calling relation is recorded in a memory occupation database, and the position where memory leakage occurs is determined according to the recorded calling relation. Therefore, in the execution process of the target program, the searching range can be reduced through the recorded calling relation, and the code position with memory leakage can be quickly found in the target program, so that the efficiency of searching the code position with memory leakage can be improved.
Based on the same technical concept, an embodiment of the present invention further provides a device for determining a memory leak location, as shown in fig. 1, where the device can implement the method described in the foregoing steps 201-202 and 301-303, and the device includes a processor 110 and a storage 120, where:
the processor 110 is configured to, in an execution process of a target program, when it is detected that a dynamic memory application function is invoked, obtain a memory address applied by the dynamic memory application function, obtain a call relationship of each current upper-level call function of the dynamic memory application function, and record a corresponding relationship between the memory address and the call relationship in a memory occupancy database established in the memory 120; and determining the position of the memory leak according to the recorded calling relationship.
In implementation, in the process of executing the target program, each time the processor 110 detects that a dynamic memory application function is called, where the dynamic memory application function may be used for a memory in a dynamic application system, a memory with a specified size may be applied according to a parameter value of the function, and the function may return a first address (which may be referred to as a memory address) of the applied memory, may obtain a memory address applied by the dynamic memory application function, and may obtain a nested relation of functions calling the dynamic application function, that is, may obtain a calling relation of current upper-level calling functions of the dynamic memory application function, and store the calling relation, and after obtaining the memory address and the calling relation, may record a corresponding relation between the memory address and the calling relation, and store the corresponding relation in a memory usage database established in the memory 120, where the memory usage database may be a memory usage table, the memory may also be a memory occupied tree, that is, the corresponding relationship between the memory address and the call relationship may be stored in a table, or may be stored in a tree, for example, a red-black tree. In the execution process of the target program, each time the call relation of each current superior call function of the dynamic memory application function is obtained, the memory application times and the memory release times corresponding to the call relation can be stored. After the call relation corresponding to the memory address is obtained, the position where the memory leak occurs may be determined according to the recorded call relation, and specifically, the computing device may further obtain the application time point corresponding to the memory address after obtaining the memory address applied by the dynamic memory application function, in this case, the memory address where the time length of the application time point from the current time point is greater than the preset time length may be determined, and the call relation corresponding to the memory address may be determined, and further, the position where the memory leak occurs may be determined according to the determined call relation corresponding to the memory address where the time length of the application time point from the current time point is greater than the preset time length.
Optionally, the processor 110 is further configured to:
when detecting that the dynamic memory application function is called, acquiring a code line identifier for calling the dynamic memory application function;
the processor 110 is specifically configured to:
and recording the corresponding relation between the memory address and the code line identification and the calling relation in a memory occupation database.
In implementation, in the execution process of the target program, when the processor 110 detects that the dynamic memory application function is called, an instruction address for calling the dynamic memory application function may also be obtained, and further, a code position of the dynamic memory application function in calling the dynamic memory application function may be determined according to a corresponding relationship between the instruction address and the code position, that is, when it is detected that the dynamic memory application function is called, a code line identifier for calling the dynamic memory application function is obtained, where the code line identifier may be a line number of the code in the calling function. In this case, the corresponding relationship between the memory address and the code row identifier and the call relationship may be recorded in the memory usage database.
Optionally, the processor 110 is specifically configured to:
acquiring the currently recorded return addresses in the stack of the target program, and determining the arrangement sequence of each return address in the stack;
respectively determining function identifications corresponding to the same instruction addresses as the return addresses according to the corresponding relation between the instruction addresses of the target program and the function identifications to obtain the function identifications corresponding to the return addresses;
and determining the calling relationship of each current upper-level calling function of the dynamic memory application function according to the arrangement sequence of each return address in the stack and the function identifier corresponding to each return address.
In implementation, when a function in the target program is executed, the processor 110 pushes relevant information of the function into a stack of the target program, where the relevant information of the function may be a return address corresponding to the function (when a certain function is executed, the return address of the function is the most advanced stack), a local variable related to the function, and a parameter value of the function, that is, the relevant information of the function occupies a certain space in the stack. After the function is pushed into the stack, the first address in the stack where the function is located can be obtained through the current stack frame address, wherein the stack frame address can be the first address of a certain section of space of the stack occupied by the relevant information corresponding to the function. And when the function is finished running, the relevant information corresponding to the function is popped. Therefore, the return address currently recorded in the stack of the target program can be obtained, and the arrangement sequence of each return address in the stack can be determined. After the return address currently recorded in the stack of the target program is obtained, the corresponding relationship between the instruction address of the target program and the function identifier, which is the corresponding relationship between the code to which the instruction address corresponds belongs, of the locally stored target program may be obtained, and the function identifier corresponding to the instruction address which is the same as the return address may be obtained in the corresponding relationship between the instruction address of the target program and the function identifier, where the return address of the called function is the instruction address of the calling function, and the function identifier corresponding to each return address is obtained. After the function identifier corresponding to each return address is obtained, the call relationship of each current upper-level call function of the dynamic memory application function can be determined according to the obtained arrangement sequence of each return address in the stack and the function identifier corresponding to each return address. Since the calling function is firstly stacked and the called function is then stacked, the calling relation of the function can be obtained according to the arrangement sequence of each acquired return address in the stack.
Optionally, the processor 110 is further configured to:
determining function identifiers meeting preset filtering conditions in the function identifiers corresponding to each return address, and selecting the return addresses corresponding to the function identifiers meeting the preset filtering conditions;
the processor 110 is specifically configured to:
and determining the calling relationship of each current upper-level calling function of the dynamic memory application function according to the arrangement sequence of the selected return addresses in the stack and the function identification meeting the preset filtering condition.
In implementation, a filter condition (which may be referred to as a preset filter condition) may be preset and stored, wherein the c-standard function or the function that has been determined that no memory leak occurs may be filtered out by the preset filter condition. After obtaining the function identifier corresponding to the currently recorded return address in the stack of the target program, the processor 110 may determine whether the corresponding function identifier satisfies the preset filtering condition, may select the function identifier satisfying the preset filtering condition from all the obtained function identifiers, and may further select the return address corresponding to the function identifier satisfying the preset filtering condition according to the obtained corresponding relationship between each return address and the function identifier. After filtering out the general part of function identifiers, the calling relationship of each current upper-level calling function of the dynamic memory application function can be determined according to the arrangement sequence of the remaining return addresses in the stack and the function identifiers corresponding to the remaining return addresses. In this way, the stored information is relatively reduced, so that the storage space can be saved, and the efficiency of determining the position where the memory leak occurs can be improved.
Optionally, the processor 110 is further configured to:
and when the memory corresponding to the memory address is detected to be released, deleting the corresponding relation of the memory address from the memory occupation database.
In implementation, in the process of executing the target program, the processor 110 detects that the memory release function is called, where the memory release function may be used to release the memory applied by the dynamic memory application function, that is, when it is detected that the memory corresponding to the memory address is released, the corresponding relationship to which the memory address belongs may be deleted from the memory database.
Optionally, the processor 110 is specifically configured to:
in the execution process of a target program, when a call instruction of the dynamic memory application function is detected, executing a program in a preset dynamic link library to execute the dynamic memory application function, acquiring a memory address applied by the dynamic memory application function, acquiring a call relation of each superior call function of the call instruction, and recording a corresponding relation between the memory address and the call relation in a memory occupation database;
and when a release instruction of the memory corresponding to the memory address is detected, executing a program in the preset dynamic link library, releasing the memory, and deleting the corresponding relation of the memory address from the memory occupation database.
In an implementation, a dynamic link library (which may be referred to as a preset dynamic link library) may be preset, and in an execution process of a target program, when detecting a call instruction of a dynamic memory application function, the processor 110 may execute a program in the preset dynamic link library so as to execute the dynamic memory application function, at this time, the program in the preset dynamic memory application function is equivalent to a specific code of the dynamic memory application function, and when all the programs in the preset dynamic memory application function are completely executed, the execution of the preset dynamic memory application function is equivalent to the completion of the execution of the dynamic memory application function. Specifically, the program in the preset dynamic link library is executed, the memory address applied by the dynamic memory application function can be obtained, and the call relationship of each superior call function of the call instruction, that is, the call relationship of each superior call function of the target program calling the dynamic memory application function, is obtained, and the corresponding relationship between the memory address and the call relationship can be recorded in the memory occupancy database.
For the situation of deleting the corresponding relationship to which the memory address belongs, in the execution process of the target program, when the processor 110 detects a release instruction for the memory corresponding to the memory address, the processor may also execute a program in the preset dynamic link library to release the memory corresponding to the memory address, and may delete the corresponding relationship to which the memory address belongs from the memory usage database.
In addition, by the method, if the target program cannot be modified, when the target program is a standard c function or a third-party program, a technician cannot modify the source code, and also can obtain related information by executing the program in the preset dynamic link library so as to perform related processing for subsequently determining the position where the memory leakage occurs.
Optionally, the processor 110 is specifically configured to:
determining the memory application times and the memory release times corresponding to each calling relation, and determining the difference value of the memory application times and the memory release times corresponding to each calling relation;
determining a difference value meeting a preset selection condition from the difference values of the memory application times and the memory release times corresponding to each calling relationship, and selecting a target calling relationship corresponding to the difference value meeting the preset selection condition;
and determining the program position corresponding to the target calling relation as the position of memory leakage.
In implementation, a difference obtaining trigger event may be preset, where the difference obtaining trigger event may be a preset difference obtaining period, or may be a corresponding relationship between a stored memory address and a call relationship detected, and when a preset difference obtaining trigger event is detected, a memory application frequency and a memory release frequency corresponding to each stored call relationship may be determined, and a difference between the memory application frequency and the memory release frequency corresponding to each call relationship may be determined. Then, the difference value meeting the preset selection condition can be determined in the difference value between the memory application times and the memory release times corresponding to each calling relationship, and the target calling relationship corresponding to the difference value meeting the preset selection condition can be selected, and further, the program position corresponding to the target calling relationship can be determined as the position where the memory leakage occurs, that is, the code position where the target calling relationship occurs in the target program can be determined as the position where the memory leakage occurs.
Optionally, the processor 110 is specifically configured to:
and acquiring a preset number of maximum difference values from the difference values of the memory application times and the memory release times corresponding to each calling relationship, and determining a target calling relationship corresponding to the preset number of maximum difference values.
In implementation, after the difference between the memory application times and the memory release times corresponding to each calling relationship is determined, the memory application times and the memory release times can be sorted according to the sequence of the difference from large to small, and the target calling relationships corresponding to the preset number of difference arranged in the front row can be obtained from the difference.
In the embodiment of the invention, in the execution process of a target program, when a dynamic memory application function is detected to be called, a memory address applied by the dynamic memory application function is obtained, the calling relation of each current superior calling function of the dynamic memory application function is obtained, the corresponding relation between the memory address and the calling relation is recorded in a memory occupation database, and the position where memory leakage occurs is determined according to the recorded calling relation. Therefore, in the execution process of the target program, the searching range can be reduced through the recorded calling relation, and the code position with memory leakage can be quickly found in the target program, so that the efficiency of searching the code position with memory leakage can be improved.
Based on the same concept, the present embodiment further provides a device for determining a memory leak location, as shown in fig. 5, the device may implement the method described in step 201-:
an obtaining module 510, which may be specifically implemented by a processor, configured to, in an execution process of a target program, when it is detected that a dynamic memory application function is called, obtain a memory address applied by the dynamic memory application function, obtain a call relationship of current upper-level call functions of the dynamic memory application function, and record a corresponding relationship between the memory address and the call relationship in a memory occupancy database;
the determining module 520, which may be specifically implemented by a processor, is configured to determine a location where the memory leak occurs according to the call relationship recorded by the obtaining module 510.
In implementation, in the process of executing the target program, whenever a dynamic memory application function is detected to be called, where the dynamic memory application function may be used for a memory in the dynamic application system, a memory with a specified size may be applied according to a parameter value of the function, and the function may return to a first address (which may be referred to as a memory address) of the applied memory, the obtaining module 510 may obtain the memory address applied by the dynamic memory application function, and may obtain a nested relation of functions calling the dynamic application function, that is, may obtain a calling relation of current upper-level calling functions of the dynamic memory application function, and store the calling relation, and after obtaining the memory address and the calling relation, may record a corresponding relation between the memory address and the calling relation, and store the memory address and the calling relation in a memory usage database, where the memory usage database may be a memory usage table, the memory may also be a memory occupied tree, that is, the corresponding relationship between the memory address and the call relationship may be stored in a table, or may be stored in a tree, for example, a red-black tree. In the execution process of the target program, each time the call relation of each current superior call function of the dynamic memory application function is obtained, the memory application times and the memory release times corresponding to the call relation can be stored. After the call relation corresponding to the memory address is obtained, the determining module 520 may determine the location where the memory leak occurs according to the recorded call relation, and in particular, the computing device may further obtain an application time point corresponding to the memory address after obtaining the memory address applied by the dynamic memory application function, and in this case, may determine a memory address where the duration of the application time point from the current time point is greater than a preset duration, and determine the call relation corresponding to the memory address, and further, may determine the location where the memory leak occurs according to the determined call relation corresponding to the memory address where the duration of the application time point from the current time point is greater than the preset duration.
Optionally, the obtaining module 510 is further configured to:
when detecting that the dynamic memory application function is called, acquiring a code line identifier for calling the dynamic memory application function;
the obtaining module 510 is specifically configured to:
and recording the corresponding relation between the memory address and the code line identification and the calling relation in a memory occupation database.
In implementation, in the execution process of the target program, when it is detected that the dynamic memory application function is called, the obtaining module 510 may further obtain an instruction address for calling the dynamic memory application function, and further, may determine, according to a corresponding relationship between the instruction address and a code position, a code position of the dynamic memory application function in calling the dynamic memory application function, that is, when it is detected that the dynamic memory application function is called, obtain a code line identifier for calling the dynamic memory application function, where the code line identifier may be a line number of the code in the calling function. In this case, the corresponding relationship between the memory address and the code row identifier and the call relationship may be recorded in the memory usage database.
Optionally, the obtaining module 510 is specifically configured to:
acquiring the currently recorded return addresses in the stack of the target program, and determining the arrangement sequence of each return address in the stack;
the determining module 520 is specifically configured to:
respectively determining function identifications corresponding to the same instruction addresses as the return addresses according to the corresponding relation between the instruction addresses of the target program and the function identifications to obtain the function identifications corresponding to the return addresses;
and determining the calling relationship of each current upper-level calling function of the dynamic memory application function according to the arrangement sequence of each return address in the stack and the function identifier corresponding to each return address.
In implementation, when a function in a target program is run, related information of the function is pushed into a stack of the target program, where the related information of the function may be a return address corresponding to the function (when a certain function is run, the return address of the function is the most advanced stack), a local variable related to the function, and a parameter value of the function, that is, the related information of the function occupies a certain space in the stack. After the function is pushed into the stack, the obtaining module 510 may obtain the first address of the function in the stack through the current stack frame address, where the stack frame address may be the first address of a certain section of space of the stack occupied by the relevant information corresponding to the function. And when the function is finished running, the relevant information corresponding to the function is popped. Therefore, the return address currently recorded in the stack of the target program can be obtained, and the arrangement sequence of each return address in the stack can be determined. After the return address currently recorded in the stack of the target program is obtained, the corresponding relationship between the instruction address of the target program and the function identifier, which is the corresponding relationship between the code to which the instruction address corresponds belongs, of the locally stored target program may be obtained, and the function identifier corresponding to the instruction address which is the same as the return address may be obtained in the corresponding relationship between the instruction address of the target program and the function identifier, where the return address of the called function is the instruction address of the calling function, and the function identifier corresponding to each return address is obtained. After obtaining the function identifier corresponding to each return address, the determining module 520 may determine the call relationship of each current upper-level call function of the dynamic memory application function according to the obtained arrangement order of each return address in the stack and the function identifier corresponding to each return address. Since the calling function is firstly stacked and the called function is then stacked, the calling relation of the function can be obtained according to the arrangement sequence of each acquired return address in the stack.
Optionally, the determining module 520 is further configured to:
determining function identifiers meeting preset filtering conditions in the function identifiers corresponding to each return address, and selecting the return addresses corresponding to the function identifiers meeting the preset filtering conditions;
the determining module 520 is specifically configured to:
and determining the calling relationship of each current upper-level calling function of the dynamic memory application function according to the arrangement sequence of the selected return addresses in the stack and the function identification meeting the preset filtering condition.
In implementation, a filter condition (which may be referred to as a preset filter condition) may be preset and stored, wherein the c-standard function or the function that has been determined that no memory leak occurs may be filtered out by the preset filter condition. After obtaining the function identifier corresponding to the currently recorded return address in the stack of the target program, the determining module 520 may determine whether the corresponding function identifier satisfies the preset filtering condition, select the function identifier satisfying the preset filtering condition from all the obtained function identifiers, and further select the return address corresponding to the function identifier satisfying the preset filtering condition according to the obtained corresponding relationship between each return address and the function identifier. After filtering out the general part of the function identifiers, the determining module 520 may determine the call relationship of each current upper-level call function of the dynamic memory application function according to the arrangement order of the remaining return addresses in the stack and the function identifiers corresponding to the remaining return addresses.
Optionally, as shown in fig. 6, the method further includes:
a deleting module 530, configured to delete the corresponding relationship to which the memory address belongs from the memory usage database when it is detected that the memory corresponding to the memory address is released.
In implementation, in the execution process of the target program, whenever it is detected that the memory release function is called, where the memory release function may be used to release the memory applied by the dynamic memory application function, that is, when it is detected that the memory corresponding to the memory address is released, the deleting module 530 may delete the corresponding relationship to which the memory address belongs from the memory database.
Optionally, the obtaining module 510 is specifically configured to:
in the execution process of a target program, when a call instruction of the dynamic memory application function is detected, executing a program in a preset dynamic link library to execute the dynamic memory application function, acquiring a memory address applied by the dynamic memory application function, acquiring a call relation of each superior call function of the call instruction, and recording a corresponding relation between the memory address and the call relation in a memory occupation database;
the deleting module 530 is specifically configured to:
and when a release instruction of the memory corresponding to the memory address is detected, executing a program in the preset dynamic link library, releasing the memory, and deleting the corresponding relation of the memory address from the memory occupation database.
In implementation, a dynamic link library (which may be referred to as a preset dynamic link library) may be preset, and in the execution process of the target program, when the obtaining module 510 detects a call instruction of the dynamic memory application function, the program in the preset dynamic link library may be executed so as to execute the dynamic memory application function, at this time, the program in the preset dynamic memory application function is equivalent to a specific code of the dynamic memory application function, and when all the programs in the preset dynamic memory application function are completely executed, the execution of the program is equivalent to the completion of the execution of the dynamic memory application function. Specifically, the program in the preset dynamic link library is executed, the memory address applied by the dynamic memory application function can be obtained, and the call relationship of each superior call function of the call instruction, that is, the call relationship of each superior call function of the target program calling the dynamic memory application function, is obtained, and the corresponding relationship between the memory address and the call relationship can be recorded in the memory occupancy database.
For the situation of deleting the corresponding relationship to which the memory address belongs, in the execution process of the target program, when the deletion module 530 detects a release instruction for the memory corresponding to the memory address, the deletion module may also execute the program in the preset dynamic link library to release the memory corresponding to the memory address, and may delete the corresponding relationship to which the memory address belongs from the memory usage database.
Optionally, the determining module 520 is specifically configured to:
determining the memory application times and the memory release times corresponding to each calling relation, and determining the difference value of the memory application times and the memory release times corresponding to each calling relation;
determining a difference value meeting a preset selection condition from the difference values of the memory application times and the memory release times corresponding to each calling relationship, and selecting a target calling relationship corresponding to the difference value meeting the preset selection condition;
and determining the program position corresponding to the target calling relation as the position of memory leakage.
In implementation, a difference obtaining trigger event may be preset, where the difference obtaining trigger event may be a preset difference obtaining period, or may be a corresponding relationship between a stored memory address and a call relationship detected, and when a preset difference obtaining trigger event is detected, a memory application frequency and a memory release frequency corresponding to each stored call relationship may be determined, and a difference between the memory application frequency and the memory release frequency corresponding to each call relationship may be determined. Then, the difference value meeting the preset selection condition can be determined in the difference value between the memory application times and the memory release times corresponding to each calling relationship, and the target calling relationship corresponding to the difference value meeting the preset selection condition can be selected, and further, the program position corresponding to the target calling relationship can be determined as the position where the memory leakage occurs, that is, the code position where the target calling relationship occurs in the target program can be determined as the position where the memory leakage occurs.
Optionally, the determining module 520 is specifically configured to:
and acquiring a preset number of maximum difference values from the difference values of the memory application times and the memory release times corresponding to each calling relationship, and determining a target calling relationship corresponding to the preset number of maximum difference values.
In implementation, after the difference between the memory application times and the memory release times corresponding to each calling relationship is determined, the memory application times and the memory release times can be sorted according to the sequence of the difference from large to small, and the target calling relationships corresponding to the preset number of difference arranged in the front row can be obtained from the difference.
In the embodiment of the invention, in the execution process of a target program, when a dynamic memory application function is detected to be called, a memory address applied by the dynamic memory application function is obtained, the calling relation of each current superior calling function of the dynamic memory application function is obtained, the corresponding relation between the memory address and the calling relation is recorded in a memory occupation database, and the position where memory leakage occurs is determined according to the recorded calling relation. Therefore, in the execution process of the target program, the searching range can be reduced through the recorded calling relation, and the code position with memory leakage can be quickly found in the target program, so that the efficiency of searching the code position with memory leakage can be improved.
It should be noted that: in the apparatus for determining a memory leak location provided in the foregoing embodiment, when determining a memory leak location, only the division of each functional module is illustrated, and in practical applications, the function distribution may be completed by different functional modules according to needs, that is, an internal structure of a computing device is divided into different functional modules to complete all or part of the functions described above. In addition, the apparatus for determining a memory leak position and the method for determining a memory leak position provided by the above embodiments belong to the same concept, and specific implementation processes thereof are detailed in the method embodiments and are not described herein again.
It will be understood by those skilled in the art that all or part of the steps for implementing the above embodiments may be implemented by hardware, or may be implemented by a program instructing relevant hardware, where the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a magnetic disk or an optical disk, etc.
The above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the invention, and any modifications, equivalents, improvements and the like that fall within the spirit and principle of the present invention are intended to be included therein.

Claims (8)

1. A method of determining a location of a memory leak, comprising:
in the execution process of a target program, when a dynamic memory application function is detected to be called, executing a program in a preset dynamic link library to execute the dynamic memory application function, acquiring a memory address applied by the dynamic memory application function, acquiring an application time point when the memory address is applied, acquiring a calling relation of current superior calling functions of the dynamic memory application function, recording a corresponding relation between the memory address and the calling relation in a first storage area in a memory occupation database, and replacing the corresponding relation from the first storage area to a second storage area of the memory occupation database for storage when the application time point is longer than a preset time from the current time point;
determining the memory application times and the memory release times corresponding to each calling relation and determining the difference value of the memory application times and the memory release times corresponding to each calling relation when a preset difference value obtaining event is detected to occur, wherein the preset difference value obtaining event is that a preset difference value obtaining period is reached, or the corresponding relation between a memory storage address and the calling relation is detected;
acquiring a preset number of maximum difference values from the difference values of the memory application times and the memory release times corresponding to each calling relationship, and determining a target calling relationship corresponding to the preset number of maximum difference values;
determining the program position corresponding to the target calling relation as the position of memory leakage;
when a release instruction of the memory corresponding to the memory address is detected, executing a program in the preset dynamic link library, releasing the memory, if a call relation corresponding to the memory address of the released memory exists in a corresponding relation between the memory address stored in the first storage area and the call relation, performing deletion processing, and if the memory address of the released memory is not included in the first storage area and the call relation corresponding to the memory address of the released memory is included in a corresponding relation between the memory address stored in the second storage area and the call relation, performing deletion processing.
2. The method of claim 1, further comprising:
when detecting that the dynamic memory application function is called, acquiring a code line identifier for calling the dynamic memory application function;
the recording, in the memory usage database, a correspondence between the memory address and the call relationship includes:
and recording the corresponding relation between the memory address and the code line identification and the calling relation in a memory occupation database.
3. The method according to claim 1 or 2, wherein the obtaining of the call relationship of each current upper-level call function of the dynamic memory application function includes:
acquiring the currently recorded return addresses in the stack of the target program, and determining the arrangement sequence of each return address in the stack;
respectively determining function identifications corresponding to the same instruction addresses as the return addresses according to the corresponding relation between the instruction addresses of the target program and the function identifications to obtain the function identifications corresponding to the return addresses;
and determining the calling relationship of each current upper-level calling function of the dynamic memory application function according to the arrangement sequence of each return address in the stack and the function identifier corresponding to each return address.
4. The method of claim 3, wherein obtaining the function identifier corresponding to each return address further comprises:
determining function identifiers meeting preset filtering conditions in the function identifiers corresponding to each return address, and selecting the return addresses corresponding to the function identifiers meeting the preset filtering conditions;
determining a calling relationship of each current upper-level calling function of the dynamic memory application function according to the arrangement sequence of each return address in the stack and the function identifier corresponding to each return address, including:
and determining the calling relationship of each current upper-level calling function of the dynamic memory application function according to the arrangement sequence of the selected return addresses in the stack and the function identification meeting the preset filtering condition.
5. An apparatus for determining a location of a memory leak, comprising:
the acquisition module is used for executing a program in a preset dynamic link library when a dynamic memory application function is detected to be called in the execution process of a target program, executing the dynamic memory application function, acquiring a memory address applied by the dynamic memory application function, acquiring an application time point when the memory address is applied, acquiring the calling relation of each current superior calling function of the dynamic memory application function, recording the corresponding relation between the memory address and the calling relation in a first storage area in a memory occupation database, and replacing the corresponding relation from the first storage area to a second storage area of the memory occupation database for storage when the application time point is longer than the preset time from the current time point;
the determining module is configured to determine, when a preset difference obtaining event is detected to occur, a memory application frequency and a memory release frequency corresponding to each call relationship, and determine a difference between the memory application frequency and the memory release frequency corresponding to each call relationship, where the preset difference obtaining event is a preset difference obtaining period, or a corresponding relationship between a stored memory address and the call relationship is detected;
acquiring a preset number of maximum difference values from the difference values of the memory application times and the memory release times corresponding to each calling relationship, and determining a target calling relationship corresponding to the preset number of maximum difference values;
determining the program position corresponding to the target calling relation as the position of memory leakage;
and the deleting module is used for executing a program in the preset dynamic link library to release the memory when a releasing instruction of the memory corresponding to the memory address is detected, deleting the memory if a calling relation corresponding to the memory address of the released memory exists in a corresponding relation between the memory address stored in the first storage area and the calling relation, and deleting the memory if the memory address of the released memory does not exist in the first storage area and the calling relation corresponding to the memory address of the released memory exists in a corresponding relation between the memory address stored in the second storage area and the calling relation.
6. The apparatus of claim 5, wherein the obtaining module is further configured to:
when detecting that the dynamic memory application function is called, acquiring a code line identifier for calling the dynamic memory application function;
the acquisition module is specifically configured to:
and recording the corresponding relation between the memory address and the code line identification and the calling relation in a memory occupation database.
7. The apparatus according to claim 5 or 6, wherein the obtaining module is specifically configured to:
acquiring the currently recorded return addresses in the stack of the target program, and determining the arrangement sequence of each return address in the stack;
the determining module is specifically configured to:
respectively determining function identifications corresponding to the same instruction addresses as the return addresses according to the corresponding relation between the instruction addresses of the target program and the function identifications to obtain the function identifications corresponding to the return addresses;
and determining the calling relationship of each current upper-level calling function of the dynamic memory application function according to the arrangement sequence of each return address in the stack and the function identifier corresponding to each return address.
8. The apparatus of claim 7, wherein the determining module is further configured to:
determining function identifiers meeting preset filtering conditions in the function identifiers corresponding to each return address, and selecting the return addresses corresponding to the function identifiers meeting the preset filtering conditions;
the determining module is specifically configured to:
and determining the calling relationship of each current upper-level calling function of the dynamic memory application function according to the arrangement sequence of the selected return addresses in the stack and the function identification meeting the preset filtering condition.
CN201511026106.XA 2015-12-30 2015-12-30 Method and device for determining memory leak position Active CN106933733B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201511026106.XA CN106933733B (en) 2015-12-30 2015-12-30 Method and device for determining memory leak position

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201511026106.XA CN106933733B (en) 2015-12-30 2015-12-30 Method and device for determining memory leak position

Publications (2)

Publication Number Publication Date
CN106933733A CN106933733A (en) 2017-07-07
CN106933733B true CN106933733B (en) 2020-03-10

Family

ID=59441777

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201511026106.XA Active CN106933733B (en) 2015-12-30 2015-12-30 Method and device for determining memory leak position

Country Status (1)

Country Link
CN (1) CN106933733B (en)

Families Citing this family (16)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107451054A (en) * 2017-07-26 2017-12-08 武汉虹信通信技术有限责任公司 A kind of memory pool adjustment method being used in linux environment
CN108415922B (en) * 2017-09-30 2021-10-22 平安科技(深圳)有限公司 Database modification method and application server
CN108121602B (en) * 2017-12-14 2022-05-06 捷开通讯(深圳)有限公司 Method for determining garbage collection trigger point, electronic equipment and storage medium
CN108664394B (en) * 2018-04-10 2021-12-14 奇安信科技集团股份有限公司 Memory leakage process tracing method and device
CN108563507A (en) * 2018-04-12 2018-09-21 郑州云海信息技术有限公司 A kind of EMS memory management process, device, equipment and readable storage medium storing program for executing
CN108845934A (en) * 2018-05-24 2018-11-20 深圳市腾讯网络信息技术有限公司 The localization method and device in memory overflow source, storage medium, electronic device
CN110659194A (en) * 2018-06-28 2020-01-07 中兴通讯股份有限公司 Dynamic memory detection method, device and storage medium
CN110457150B (en) * 2019-07-10 2023-03-21 锐捷网络股份有限公司 Memory fault detection method and device
CN110502891B (en) * 2019-08-08 2021-06-15 北京字节跳动网络技术有限公司 Method, device, medium and electronic equipment for acquiring process memory leakage
CN110795355A (en) * 2019-10-30 2020-02-14 深圳开立生物医疗科技股份有限公司 Method and device for detecting memory leakage
CN110908865A (en) * 2019-11-15 2020-03-24 珠海豹趣科技有限公司 Memory leakage monitoring method and device and electronic equipment
CN111209062B (en) * 2020-01-11 2023-04-25 阿里巴巴集团控股有限公司 Information acquisition method, information acquisition device, electronic equipment and computer storage medium
CN111274155B (en) * 2020-02-25 2021-08-06 腾讯科技(深圳)有限公司 Memory operation recording method, device, equipment and storage medium of dynamic library
CN112860444B (en) * 2021-04-26 2021-08-20 腾讯科技(深圳)有限公司 Memory calling information determining method and device, storage medium and electronic equipment
CN115705294A (en) * 2021-08-12 2023-02-17 华为技术有限公司 Method, device, electronic equipment and medium for acquiring function call information
CN113407752B (en) * 2021-08-19 2021-11-16 杭州欧若数网科技有限公司 Graph database memory management method, system, electronic device and storage medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101593152A (en) * 2009-06-25 2009-12-02 青岛海信移动通信技术股份有限公司 A kind of portable terminal memory leakage detecting method and device
CN102148844A (en) * 2010-02-09 2011-08-10 深圳市金蝶中间件有限公司 Memory leak positioning method, server, client and system
CN103019787A (en) * 2012-12-14 2013-04-03 华为技术有限公司 Function call relation determining method, hotfix updating method and hotfix updating device

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100131803A1 (en) * 2008-11-25 2010-05-27 Express Logic Computation of stack usage in embedded computing systems

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101593152A (en) * 2009-06-25 2009-12-02 青岛海信移动通信技术股份有限公司 A kind of portable terminal memory leakage detecting method and device
CN102148844A (en) * 2010-02-09 2011-08-10 深圳市金蝶中间件有限公司 Memory leak positioning method, server, client and system
CN103019787A (en) * 2012-12-14 2013-04-03 华为技术有限公司 Function call relation determining method, hotfix updating method and hotfix updating device

Also Published As

Publication number Publication date
CN106933733A (en) 2017-07-07

Similar Documents

Publication Publication Date Title
CN106933733B (en) Method and device for determining memory leak position
CN107766236B (en) Test task automatic management method, device, equipment and storage medium
CN108664394B (en) Memory leakage process tracing method and device
CN110908865A (en) Memory leakage monitoring method and device and electronic equipment
JP5832954B2 (en) Tag assignment device and tag assignment method
CN110209520B (en) Method and device for improving SSD (solid State disk) testing efficiency, computer equipment and storage medium
JP2017531852A (en) Resource leak detection method, apparatus and system
CN114297630A (en) Malicious data detection method and device, storage medium and processor
CN112712125B (en) Event stream pattern matching method and device, storage medium and processor
CN113704117A (en) Algorithm testing system, method and device
CN113064674B (en) Method and device for expanding state machine logic, storage medium and electronic device
CN112559565A (en) Abnormity detection method, system and device
CN105912467A (en) Performance test method and device
CN105701004B (en) Application testing method and device
CN114500249B (en) Root cause positioning method and device
CN111338864A (en) Memory problem detection method and device, computer equipment and storage medium
CN108108300B (en) Resource allocation detection method and device for operating system
CN115757172A (en) Test execution method and device, storage medium and computer equipment
CN111552608B (en) Drive memory monitoring method and system
US11593474B2 (en) Container behavior representation
CN108563578A (en) SDK compatibility detection method, device, equipment and readable storage medium storing program for executing
CN114691496A (en) Unit testing method, unit testing device, computing equipment and medium
CN113220334B (en) Program fault positioning method, terminal equipment and computer readable storage medium
CN110795100A (en) Branch merging method and device
CN107102938B (en) Test script updating method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant