CN106610892B - Memory leak detection method and device - Google Patents
Memory leak detection method and device Download PDFInfo
- Publication number
- CN106610892B CN106610892B CN201510697835.1A CN201510697835A CN106610892B CN 106610892 B CN106610892 B CN 106610892B CN 201510697835 A CN201510697835 A CN 201510697835A CN 106610892 B CN106610892 B CN 106610892B
- Authority
- CN
- China
- Prior art keywords
- memory
- function
- allocation information
- information
- memory allocation
- 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
Links
Images
Landscapes
- Debugging And Monitoring (AREA)
Abstract
The invention relates to a memory leak detection method and a memory leak detection device. The method comprises the following steps: loading a preset memory monitoring dynamic link library when a tested process is started; the memory distribution function and/or the windows system application programming interface are/is hooked through the memory monitoring dynamic link library; calling the memory allocation function and/or the windows system application programming interface through a hook function, collecting memory allocation information when the tested process is started, and collecting memory allocation information when the tested process is quitted; and comparing the memory allocation information when the tested process is started with the memory allocation information when the tested process is exited to obtain the memory leakage information. The memory leakage detection method and the memory leakage detection device monitor the memory allocation information of the whole process from the start to the exit of the detected process, the monitoring time point is accurate, the obtained data is comprehensive, the counted result is not released all the time, and the obtained memory leakage information is more accurate.
Description
Technical Field
The present invention relates to the field of memory detection, and in particular, to a method and an apparatus for detecting memory leakage.
Background
Memory leaks are leaks of heap memory. Heap memory refers to memory that a program allocates from the heap, is of any size, and must be shown freed after use. The application program generally uses the functions of malloc, realloc, new, etc. to allocate a block of memory from the heap, after use, the program must be responsible for corresponding calling free or delete to release the block of memory, otherwise, the block of memory cannot be used again, that is, the block of memory leaks.
In a conventional client performance special test, the memory use condition is an index of key concern. The UMDH tool in the debug tool set of Windows (the debug Tools for Windows) can monitor the problem point of memory leakage to obtain the stack at the memory leakage. The UMDH monitors the memory allocation function in the Windows system function, and obtains the memory leakage between the two time points by counting and comparing the memory allocation conditions of the two time points of the start and the end manually specified by the user, however, the manual specification is difficult to be accurate, and the obtained data is not comprehensive.
Disclosure of Invention
Therefore, it is necessary to provide a memory leak detection method for solving the problems that the conventional memory leak detection manually specifies the time point which is not accurate enough and the obtained data is incomplete, the monitored time point is accurate and the monitored data is comprehensive.
In addition, it is necessary to provide a memory leak detection device, which can monitor the time precisely and the monitored data comprehensively.
A memory leak detection method includes the following steps:
loading a preset memory monitoring dynamic link library when a tested process is started;
the memory distribution function and/or the windows system application programming interface are/is hooked through the memory monitoring dynamic link library;
calling the memory allocation function and/or the windows system application programming interface through a hook function, collecting memory allocation information when the tested process is started, and collecting memory allocation information when the tested process is quitted;
and comparing the memory allocation information when the tested process is started with the memory allocation information when the tested process is exited to obtain the memory leakage information.
A memory leak detection apparatus, comprising:
the loading module is used for loading a preset memory monitoring dynamic link library when the tested process is started;
the hook module is used for hooking a memory distribution function and/or a windows system application program programming interface through the memory monitoring dynamic link library;
the collection module is used for calling the memory allocation function and/or the windows system application programming interface through the hook function, collecting memory allocation information when the tested process is started, and collecting memory allocation information when the tested process exits;
and the comparison module is used for comparing the memory allocation information when the tested process is started with the memory allocation information when the tested process is exited to obtain the memory leakage information.
According to the memory leak detection method and device, the memory monitoring dynamic link library is loaded when the tested process is started, the memory distribution function is hooked through the memory monitoring dynamic link library, the memory distribution information when the tested process is started and the memory distribution information after quitting are collected, the memory leak information is obtained by comparing the memory distribution information when the tested process is started and the memory distribution information when the tested process is quitted, the memory distribution information in the whole process from starting to quitting of the tested process is monitored, the monitoring time point is accurate, the obtained data are comprehensive, the counted result is not released all the time, and the obtained memory leak information is more accurate.
Drawings
Fig. 1A is a schematic diagram of an internal structure of a terminal in one embodiment;
FIG. 1B is a diagram illustrating an internal architecture of a server according to an embodiment;
FIG. 2 is a flow diagram of a method for memory leak detection in accordance with one embodiment;
FIG. 3 is a diagram illustrating a function call relationship;
fig. 4 is a specific flowchart illustrating the memory monitoring information is sent to a data processing process, and the data processing process processes the memory monitoring information according to an embodiment;
FIG. 5A is a schematic diagram of data transmission between a process under test and a data processing process;
FIG. 5B is a diagram illustrating a process for inter-process data transfer;
FIG. 6 is a schematic diagram of a data cache;
FIG. 7 is a schematic diagram of a caching mechanism;
FIG. 8 is a diagram illustrating a comparison of memory addresses in a memory snapshot;
FIG. 9 is a diagram illustrating a comparison of function stacks in memory snapshots;
FIG. 10 is a graph of the change of a stack;
FIG. 11 is a block diagram illustrating an exemplary memory leak detection apparatus;
FIG. 12 is a block diagram of an alternative embodiment of a memory leak detection apparatus;
FIG. 13 is a block diagram of another embodiment of a memory leak detection apparatus;
fig. 14 is a block diagram showing the structure of a memory leak detection apparatus according to another embodiment.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
It will be understood that, as used herein, the terms "first," "second," and the like may be used herein to describe various elements, but these elements are not limited by these terms. These terms are only used to distinguish one element from another. For example, a first client may be referred to as a second client, and similarly, a second client may be referred to as a first client, without departing from the scope of the present invention. Both the first client and the second client are clients, but they are not the same client.
Fig. 1A is a schematic diagram of an internal structure of a terminal in one embodiment. As shown in fig. 1A, the terminal includes a processor, a storage medium, a memory, a network interface, a sound collection device, a display screen, a speaker, and an input device, which are connected by a system bus. The storage medium of the terminal stores an operating system, and the memory leak detection device is used for realizing a memory leak detection method. The processor is used for providing calculation and control capability and supporting the operation of the whole terminal. The memory in the terminal provides an environment for the operation of the memory leak device in the storage medium, and the network interface is used for carrying out network communication with the server, such as sending a game data request to the server, receiving game data returned by the server and the like. The display screen of the terminal can be a liquid crystal display screen or an electronic ink display screen, and the input device can be a touch layer covered on the display screen, a key, a track ball or a touch pad arranged on a shell of the terminal, or an external keyboard, a touch pad or a mouse. The terminal may be a mobile phone, a tablet computer or a personal digital assistant. Those skilled in the art will appreciate that the configuration shown in fig. 1A is a block diagram of only a portion of the configuration relevant to the present application, and does not constitute a limitation on the terminal to which the present application is applied, and that a particular terminal may include more or less components than those shown in the figures, or may combine certain components, or have a different arrangement of components.
Fig. 1B is a schematic diagram of an internal structure of a server in one embodiment. As shown in fig. 1B, the server includes a processor, a storage medium, a memory, a network interface, a display screen, and an input device connected through a system bus. The storage medium of the server stores an operating system, a database and a memory leak detection device, the database stores game scene data, game user data and the like, and the memory leak detection device is used for realizing a memory leak detection method suitable for the server. The processor of the server is used for providing calculation and control capacity and supporting the operation of the whole server. The memory of the server provides an environment for the operation of the memory leak device in the storage medium. The display screen of the server can be a liquid crystal display screen or an electronic ink display screen, and the input device can be a touch layer covered on the display screen, a key, a track ball or a touch pad arranged on a terminal shell, or an external keyboard, a touch pad or a mouse. The network interface of the server is used for communicating with external terminals through network connection, such as receiving game data requests sent by the terminals and returning game data to the terminals. The server may be implemented as a stand-alone server or as a server cluster consisting of a plurality of servers. Those skilled in the art will appreciate that the architecture shown in FIG. 1B is merely a block diagram of some of the structures associated with the disclosed aspects and is not intended to limit the servers to which the disclosed aspects apply, and that a particular server may include more or less components than those shown, or may combine certain components, or have a different arrangement of components.
The memory leakage is caused by that an application program uses functions such as malloc, realloc, new and the like to allocate a block of memory from a heap, and after the application program is used up, a free function or a delete function is not called to release the block of memory. The traditional memory leak detection method compares the memory leak conditions of two time points specified by a user, and some application programs release the allocated memory after exiting, so that the detected memory leak data is incomplete and inaccurate. The memory leak detection method of the invention, through loading the dynamic link library of memory monitoring and carrying out the function therein when the process to be tested is started, begin to monitor the memory allocation information when the process to be tested is started, still carry out the memory allocation information after the dynamic link library of memory monitoring after loading monitors the process to be tested and withdraws when the process to be tested withdraws, through comparing the memory allocation information when the process to be tested is started with the memory allocation information when withdrawing, obtain the memory leak information, the memory allocation information in the whole process from starting to withdrawing of the process to be tested is monitored, the time point of monitoring is accurate, the data obtained are comprehensive, and it is more accurate to obtain the memory leak information.
If the allocation is successful, a pointer pointing to the allocated memory is returned, otherwise, a null pointer is returned.
A realloc function, namely reset allocation, a dynamic memory adjustment function, if the reallocation is successful, a pointer pointing to the allocated memory is returned, otherwise, a null pointer is returned.
new is equivalent to a function, and after the memory opens up a space, the first address of the space is returned.
free or delete function, release memory.
The memory allocation information may include a memory allocation address, a memory allocation size, and a function stack of the memory allocation, or a function stack of the memory allocation size and the memory allocation, or a memory allocation address and a memory allocation size.
FIG. 2 is a flow diagram of a method for memory leak detection in one embodiment. As shown in fig. 2, a method for detecting memory leak includes the following steps:
Specifically, firstly, a static injection method is adopted, before a tested process is started, setdill.exe in a tools kit is used for modifying an executable file (.exe file) of the process, so that a preset memory monitoring Dynamic Link Library (DLL) is automatically loaded when the tested process is started, and a hook memory allocation function and/or a windows system API (Application Programming Interface) are/is realized.
Specifically, the functions of memory allocation functions (malloc, free, realloc and the like) in a hook C/C + + standard library are realized by utilizing a nodes library provided by Microsoft in a memory monitoring dynamic link library. Alternatively, the hook windows system application programming interface, i.e., the hook more underlying HeapAlloc series of functions (including HeapAlloc, HeapFree, and HeapRealloc) or hook underlying system functions (RtAllocateHeap, etc.). The HeapAlloc function is used to allocate memory on a specified heap and the allocated memory is not removable. By adopting the memory allocation function in the hook C/C + + standard library, the influence of windows system functions can be greatly removed, and the accuracy of the result is improved.
In addition, the method can also switch between the hook memory allocation function and the application programming interface of the windows system at the same time.
During hook of the two functions malloc/free, the address may not be found, and the reason is related to the linking mode of the standard library, and the standard library function can be linked into the program from a libc lib static state or an msvcrt dll dynamic state. When statically linked to a program, a program gets its own proprietary version of the standard library function; when programs are dynamically linked, one program shares a version of the static standard library function in the DLL. And distinguishing when the malloc/free address is acquired.
Fig. 3 is a diagram illustrating a function call relationship. As shown in fig. 3, after the memory allocation is performed in the new direction, the memory allocation information is collected by calling the malloc function and the heamalloc function.
Specifically, the memory monitoring dynamic link library mainly monitors malloc operations and free operations in the memory, including the size of memory allocation, the address of memory release, the function stack of memory allocation, and the like. And calling the memory allocation function malloc or free by the hook function, and collecting the memory allocation information when the tested process is started by recording malloc operation and free operation. The memory allocation information may include a memory allocation address, a memory allocation size, and a function stack of the memory allocation, or a function stack of the memory allocation size and the memory allocation, or a memory allocation address and a memory allocation size.
The malloc is used for collecting memory allocation information. The free function is used to collect memory release information. The memory release information may include a memory release address and/or a function stack of the memory release, etc.
The malloc series of functions are stated as follows:
void*__cdecl malloc(_In_size_t_Size);
void__cdecl free(_Inout_opt_void*_Memory);
void*__cdecl realloc(_In_opt_void*_Memory,_In_size_t_NewSize);
it can be seen from the declaration of malloc series functions that the address and size can be directly obtained from the parameter or return value of function call, and the stack needs to call the function provided in dbghelp.dll to obtain, and the specific method is to call the system function LoadLibrary () to load dbghelp.dll, and the call is as follows:
HMODULE m_dbgHelp=LoadLibrary(“dbghelp.dll”);
and then acquiring the specific function address in the DLL through a function GetProcAddress ().
Specifically, two functions can acquire the stack, CaptureStackBackTrace () and StackWalk64 (). The method has some differences between the two, namely CaptureStackBackTrace is a windows system function, all stacks can be obtained by calling once, and the speed is high; the Stackwalk64 can only acquire one layer of stack when called once, and can acquire all stacks only by circular calling during use, so that the speed is low, and more stacks can be acquired.
For example, CaptureStackBackTrace () is called in funcB, and the stack obtained is:
funcB()
funcA()
main()
if StackWalk64() is called in funCB, only funCB () can be obtained, and funcA () needs to be called once again to be obtained, and the call is circulated until a stack can not be obtained any more.
In an embodiment, the method for detecting memory leak further includes: and acquiring the stack by using a stack global acquisition function (such as CaptureStackBackTrace), and acquiring the stack once by using a stack local acquisition function (such as StackWalk64) if the acquisition fails.
In step 208, the memory allocation information when the tested process is started and the memory allocation information when the tested process is exited are compared to obtain the memory leakage information.
Specifically, the memory allocation information may include a memory allocation address, a memory allocation size, and a function stack of the memory allocation, or a function stack of the memory allocation size and the memory allocation, or a memory allocation address and a memory allocation size.
In one embodiment, the memory allocation address in the memory allocation information when the tested process is started and the memory allocation address in the memory allocation information when the tested process exits may be compared, and it is determined that more memory addresses are present in the memory allocation information when the tested process exits than in the memory allocation information when the tested process is started, and then more memory addresses are memory leak addresses, and the memory leak size is obtained.
In another embodiment, the function stack of the memory allocation information when the tested process is started and the function stack of the memory allocation information when the tested process is exited may be compared, and it is determined that there are more function stacks in the memory allocation information when the tested process is exited than in the memory allocation information when the tested process is started, and that there are more function stacks that are memory leaks from the function stacks.
In one embodiment, a plurality of function stacks are sorted according to the sizes of corresponding function addresses, and then the sorted function stacks are subjected to classification statistics to obtain the times of function stack memory leakage and the sizes of function memory leakage.
Specifically, a plurality of function stacks are classified, the leakage times of the function stacks of the same class are counted, and the memory leakage size of all the function stacks is calculated.
The comparison of a group of numbers actually adopts function stack comparison, the same function stack is calculated only if each number in the group is equal, the comparison of each number is needed to judge whether two function stacks are equal, the comparison is time-consuming when a large number of stacks are searched, and the function stacks can be sorted from large to small or from small to large according to function addresses by sorting the function stacks. The function stack after the sorting process is completed by using std: : the set data structure realizes the management of the red and black trees, reduces the complexity of the search time to O (lgn), and greatly shortens the search time.
In addition, the code line and the severity of the memory leakage, the change trend of the function stack of the memory allocation and the like can be counted, and the memory leakage problem can be better positioned through the change trend of the function stack.
According to the memory leak detection method, the memory monitoring dynamic link library is loaded when the tested process is started, the memory distribution function is hooked through the memory monitoring dynamic link library, the memory distribution information when the tested process is started and the memory distribution information after quitting are collected, the memory leak information is obtained by comparing the memory distribution information when the tested process is started and the memory distribution information when the tested process is quitted, the memory distribution information in the whole process from starting to quitting of the tested process is monitored, the monitoring time point is accurate, the obtained data are comprehensive, the counted result is not released all the time, and the obtained memory leak information is more accurate.
In one embodiment, the memory leak detection method further includes: calling the memory allocation function and/or the windows system application programming interface through a hook function, and collecting memory monitoring information after the tested process is started; and sending the memory monitoring information to a data processing process, and processing the memory monitoring information by the data processing process.
Specifically, the memory monitoring information may be memory allocation information or memory release information. The memory allocation information may include a memory allocation address, a memory allocation size, and a function stack of the memory allocation, or a function stack of the memory allocation size and the memory allocation, or a memory allocation address and a memory allocation size. The memory release information may include a memory release address and/or a function stack of the memory release, etc.
The data processing process processes the memory monitoring information, and the collected memory monitoring information mainly comprises two types, namely memory allocation and memory release. When the memory is allocated, the memory allocation information is recorded, when the memory is released, the recorded memory allocation information is deleted, and the data obtained by counting in this way is the memory which is currently allocated and not released.
The data processing process processes the memory monitoring information, and the recorded data structure can adopt std (map), because the map is realized by a red-black tree, the map is suitable for frequent searching, inserting and deleting operations, and the time complexity of the three operations is O (lgn). The specific data structure states the following:
the key value (key) of the map is the address of the allocated memory.
By comparing the memory allocation information of the two recording points, the memory which is newly allocated and not released between the two time points is analyzed, and the memory leaks in the memory. In this embodiment, the time points used for the test are when the tested process is started and after the tested process exits, and thus, the counted result is not released all the time, which can be determined as memory leakage, and the accuracy is very high.
Because data collection and processing are written in the dynamic link library of the memory, but the time consumption of data processing is more, the process is possibly seriously blocked, the collected data is sent to another process for processing and outputting a result, the load of the process to be tested can be reduced, the blocking is avoided, and the data processing efficiency can be improved.
Fig. 4 is a specific flowchart illustrating sending of the memory monitoring information to the data processing process, and processing of the memory monitoring information by the data processing process according to an embodiment. As shown in fig. 4, the step of sending the memory monitoring information to a data processing process, where the step of processing the memory monitoring information by the data processing process includes:
in step 402, the memory monitoring information is written into the shared memory.
Specifically, the number of processing threads may be multiple, such as 5, 8, etc. The number of processing threads can be correspondingly reduced for the central processing units below four cores. In this embodiment, 5 processing threads are adopted, and the processing efficiency can be improved by adopting a plurality of processing threads.
The refresh thread is mainly used for analyzing function names in the function stack, module names where the functions are located and the like.
The process to be tested sends the collected memory monitoring information to the data processing process, which relates to inter-process communication, and can realize data transmission by adopting a shared memory mode, and the shared memory has high transmission speed and is not easy to make mistakes.
Fig. 5A is a schematic diagram of data transmission between a process under test and a data processing process. As shown in fig. 5A, a memory monitoring dynamic link library is injected into a process to be tested, a malloc/free function is called, related data is collected, the collected data is stored, the stored data is transmitted to a data processing process, and the data processing process performs data storage and processing, leakage filtering and analysis, memory leakage result output, filtering setting, monitoring kernel setting and the like.
FIG. 5B is a diagram illustrating a process of inter-process data transmission. As shown in fig. 5B, when the tested process collects the memory allocation and release operations, the memory monitoring dynamic link library writes the collected data into the shared memory, and the monitoring thread in the data processing process (e.g., tmemennalyzer. exe) finds that there is data in the shared memory and reads the data.
FIG. 6 is a diagram of a data cache. As shown in fig. 6, a cache is added in the data processing process to temporarily store data sent by the tested process (i.e., data read from the shared memory by the monitoring thread), a synchronous mode in which the original data is received one by one is changed into an asynchronous mode in which data collection and data processing are separated, and data collection is not greatly affected by data processing, so that the data collected by the tested process can be sent to the data processing process, thereby preventing the tested process from being slow in data transmission and stuck. The data structure of the buffer is a first-in first-out queue, which can ensure the correct data processing sequence.
Because malloc and free are two reciprocal processes (malloc inserts data, and free deletes data) in the data processing stage, if corresponding malloc and free data (corresponding to the same memory address) can be found before the data processing stage, the two reciprocal operations can be saved, and the efficiency is improved, so that a cache (cache) is added into the cache. And searching corresponding malloc data from the cache every time when free data enters the cache, and deleting the free data and the corresponding malloc data if the corresponding malloc data is found. The cache may be sized as desired, such as 64 data sizes, 128 data sizes, 256 data sizes, and so on. By adopting a cache with the size of 128 data, the problems that each search is time-consuming and the hit rate is reduced due to too large capacity can be avoided.
In one embodiment, the memory leak method further includes: when the memory monitoring information is memory release information, searching whether corresponding memory allocation information exists in a cache of the data processing process according to the memory release information, if so, deleting the memory release information and the corresponding memory allocation information, if not, searching whether the corresponding memory allocation information exists in the cache, and if so, deleting the memory release information and the corresponding memory allocation information.
FIG. 7 is a schematic diagram of a caching mechanism. As shown in fig. 7, data collected by a tested process is synchronously written into a shared memory, then a data processing process reads data from the shared memory and temporarily stores the data in a cache, where the read data is memory release information, the data processing process searches whether corresponding memory allocation information exists in a cache in its own cache, if so, deletes the memory release information and the corresponding memory allocation information, if not, searches whether corresponding memory allocation information exists in the cache, and if so, deletes the memory release information and the corresponding memory allocation information.
To obtain memory allocation information at a certain time, a memory snapshot may be used. A memory snapshot is a collection of memory that is allocated malloc at some point and has not been released by calling free. The memory snapshot at each moment will basically change throughout the life cycle of the application program operation, because the memory changes as the application program is continuously operated by the user. The memory snapshot at each moment is obtained, which memory operations occur between the two memory snapshots, namely, the memory leak occurs between the two memory snapshots, and the memory addresses of the memory leak are obtained by comparing the two memory snapshots.
Fig. 8 is a schematic diagram illustrating a comparison of memory addresses in a memory snapshot. As shown in fig. 8, snapshot 1 is collected when the function starts, snapshot 2 is collected when the function ends, and it is found through this process that 0x2 of snapshot 1 has been released, so that it does not exist in snapshot 2, and 0x1 still exists in snapshot 2, which indicates that 0x1 is not released, and 0x3 and 0x4 only exist in snapshot 2, which indicates that 0x3 and 0x4 memory blocks are allocated in the function, and they are not released in time after the function ends, which indicates that these two memory blocks are leaked memory blocks.
FIG. 9 is a diagram illustrating a comparison of function stacks in a memory snapshot. As shown in fig. 9, snapshot 1 is collected when the function starts, snapshot 2 is collected when the function ends, and through this process, after entering the function, the memory block that is not used in the preamble scene is released, that is, 0x2 of snapshot 1 is subjected to a release operation, and 0x1 still exists in snapshot 2, which indicates that 0x1 is not released, 0x3 and 0x4 leave the function and return to the preamble scene interface, the program allocates the relevant memory blocks, and there is a function stack corresponding to the two memory block addresses in snapshot 1. 0x5 is the only memory block in snapshot 2 that is allocated after the function is entered, and the function is not released in time after the function is completed, then the memory block 0x5 is the leaky stack.
The following describes the process of the memory leak detection method according to the present invention with reference to a specific application scenario. In a game program, a player enters another scene from one scene and returns to the original scene after the other scene is finished, and the memory leak detection comprises the following steps:
(a1) after entering a tested scene, exiting to a preorder scene to start collecting a first memory snapshot, wherein the first memory snapshot records memory allocation information at the current moment;
(a2) after entering the tested scene again, exiting to the preorder scene to start collecting a second memory snapshot, wherein the second memory snapshot records the memory allocation information at the current moment;
(a3) and comparing the memory allocation information recorded by the first memory snapshot with the memory allocation information recorded by the second memory snapshot to obtain the memory leakage information of the detected scene.
With the steps from a1 to a3, the time point can be set by the player to meet the personalized needs of the player.
Alternatively, the memory leak detection comprises:
(b1) collecting and collecting a first memory snapshot when a game program is started, wherein the first memory snapshot records memory allocation information at the current moment;
(b2) collecting a second memory snapshot when the game program exits, wherein the second memory snapshot records the memory allocation information at the current moment;
(b3) and comparing the memory allocation information recorded by the first memory snapshot with the memory allocation information recorded by the second memory snapshot to obtain the memory leakage information of the detected scene.
By using the steps b1 through b3, two snapshots collected from the start to the exit of the game program are used, and the comparison of the two snapshots results in more accurate leakage.
The memory allocation information includes a memory allocation address, a memory allocation size, and a memory allocation function stack.
The step of comparing the memory allocation information of the first memory snapshot record with the memory allocation information of the second memory snapshot record includes: comparing the function stack in the memory allocation information of the first memory snapshot record with the function stack in the memory allocation information of the second memory snapshot record, and judging that more function stacks are in the memory allocation information of the second memory snapshot record than in the memory allocation information of the first memory snapshot record, and the more function stacks are function stack memory leakage.
Further, sequencing a plurality of function stacks according to the corresponding function address size, and then carrying out classification statistics on the sequenced function stacks to obtain the function stack memory leakage times and the function memory leakage size.
Specifically, the function stacks are classified, the leakage times of the function stacks of the same class are counted, and the memory leakage size of all the function stacks is calculated.
The comparison of a group of numbers actually adopts function stack comparison, the same function stack is calculated only if each number in the group is equal, the comparison of each number is needed to judge whether two function stacks are equal, the comparison is time-consuming when a large number of stacks are searched, and the function stacks can be sorted from large to small or from small to large according to function addresses by sorting the function stacks. The function stack after the sorting process is completed by using std: : the set data structure realizes the management of the red and black trees, reduces the complexity of the search time to O (lgn), and greatly shortens the search time.
The memory leak information is counted in detail through the memory leak detection method, and the memory leak information comprises a leaky function stack (which can be detailed into a code line), size and times. Since malloc/free is used by programmers themselves, the functions of C runtime libraries are also heavily used, such as fopen _ s, whose call stack is below.
.exe!malloc(unsigned int size=24)Line87
.exe!_malloc_crt(unsigned int cb=24)Line44
.exe!_mtinitlocknum(int locknum=19)Line274
.exe!_getstream()Line71
.exe!_fsopen(const char *file=0x00546244,const char* mode=0x00546240,int shflag=128)Line61
.exe!fopen_s(_iobuf**pfile=0x001df994,const char*file=0x00546244,const char*mode=0x00546240)Line160
.exe!main(int argc=1,char**argv=0x00662b98)Line32
Therefore, the memory leakage information is filtered through the keywords. The keyword may be a preset keyword. And screening out the matched memory leakage information through the keywords and displaying the information.
The memory leak detection method further includes: and sequencing the leakage severity of the stacks from large to small, and displaying the stacks with the leakage severity sequenced in the front by a preset number.
The leakage severity means a leakage degree greater than a preset percentage. For example, the leakage size of the same stack is larger than a first preset value; the leakage times of the same stack are greater than a second preset value; the same stack presents an ascending trend according to the leakage size of a time shaft, and the ascending trend exceeds a third preset value, such as 30%; the occupation degree of the memory blocks with the same size allocated in the same stack in the total allocated blocks is greater than a fourth preset value, such as 50%.
In one embodiment, the memory leak detection method further includes: and the change curve graph of each stack is displayed, so that developers can judge the leakage process more accurately. Fig. 10 is a graph of the change of a stack. As shown in fig. 10, the number of stack leaks at predetermined intervals is plotted on the abscissa as time in seconds and on the ordinate as the number of leaks.
In one embodiment, the memory leak detection method further includes: providing a user interaction interface, and setting a trigger control on the user interaction interface. The memory leak detection can be completed through the trigger control on the user interaction interface, the user does not need to input different commands, and the operation is simple.
The memory leak detection method can be applied to any application program, has no influence on the performance of any application program, adopts a flexible configuration mode of a system API layer and a standard library layer to carry out hook, and is added with a filtering strategy and a severity definition, so that the accuracy and readability of a detection result are improved, a game program and other application programs can be considered, codes are not needed, one-time detection can be realized, and a single scene can be analyzed.
The memory leak detection method is applied to 'Tie Bing', and obvious memory leak is found in scenes (64 robot doctors repeatedly place incenses in Jiangling cities for 15 minutes and automatically quit after completion) in the client performance test process. And (3) analysis results: the two snapshots are respectively captured before and after entering and exiting the Jiangling city, through comparison, 335.8M (million) is leaked in the whole test process of 15 minutes, 290.5M is released after about 3 minutes, and the memory is not changed before exiting the scene, namely 45.3M memory leakage is caused before exiting the scene. In the test there were 216 dependency stacks, 7023 calls total, revealing 47536935 bytes.
The memory leak detection method is applied to 'stranger', and the memory leak can be seen most obviously through a memory manager in the test process. And (3) analysis results: by analyzing the leakage from the flash file in the program, the leakage of scaleform is classified at present, and the calling process is as follows: calling a main swf file in a flash player instance. cpp in the engine, and calling scaleforms in the swf file. Therefore, if there is a memory leak in the swf associated with the UI, the stack is called into scaleform.
Fig. 11 is a block diagram showing the structure of a memory leak detection apparatus according to an embodiment. As shown in fig. 11, a memory leak detection apparatus, which corresponds to a functional module architecture constructed by a memory leak detection method, is described in detail with reference to the method, and includes a loading module 1102, a hooking module 1104, a collecting module 1106, and a comparing module 1108. Wherein:
the loading module 1102 is configured to load a preset memory monitoring dynamic link library when a tested process is started.
Specifically, firstly, a static injection method is adopted, before a tested process is started, setdill.exe in a tools kit is used for modifying an executable file (.exe file) of the process, so that a preset memory monitoring Dynamic Link Library (DLL) is automatically loaded when the tested process is started, and a hook memory allocation function and/or a windows system API (Application Programming Interface) are/is realized.
The hooking module 1104 is used to hook a memory allocation function or a windows system application programming interface through the memory monitoring dynamic link library.
Specifically, the functions of memory allocation functions (malloc, free, realloc and the like) in a hook C/C + + standard library are realized by utilizing a nodes library provided by Microsoft in a memory monitoring dynamic link library. Alternatively, the hook windows system application programming interface, i.e., the hook more underlying HeapAlloc series of functions (including HeapAlloc, HeapFree, and HeapRealloc) or hook underlying system functions (RtAllocateHeap, etc.). The HeapAlloc function is used to allocate memory on a specified heap and the allocated memory is not removable. By adopting the memory allocation function in the hook C/C + + standard library, the influence of windows system functions can be greatly removed, and the accuracy of the result is improved.
In addition, the method can also switch between the hook memory allocation function and the application programming interface of the windows system at the same time.
The collecting module 1106 is configured to call the memory allocation function or the windows system application programming interface through the hook function, collect memory allocation information when the tested process is started, and collect memory allocation information when the tested process exits.
Specifically, the memory monitoring dynamic link library mainly monitors malloc operations and free operations in the memory, including the size of memory allocation, the address of memory release, the function stack of memory allocation, and the like. And calling the memory allocation function malloc or free by the hook function, and collecting the memory allocation information when the tested process is started by recording malloc operation and free operation. The memory allocation information may include a memory allocation address, a memory allocation size, and a function stack of the memory allocation, or a function stack of the memory allocation size and the memory allocation, or a memory allocation address and a memory allocation size.
The comparing module 1108 is configured to compare the memory allocation information when the tested process is started with the memory allocation information when the tested process is exited, so as to obtain the memory leakage information.
Specifically, the memory allocation information may include a memory allocation address, a memory allocation size, and a function stack of the memory allocation, or a function stack of the memory allocation size and the memory allocation, or a memory allocation address and a memory allocation size.
In an embodiment, the comparing module 1108 may compare the memory allocation address in the memory allocation information when the tested process is started with the memory allocation address in the memory allocation information when the tested process is exited, determine that more memory addresses in the memory allocation information when the tested process is exited are larger than the memory allocation information when the tested process is started, and then obtain the memory leakage size.
In another embodiment, the comparing module 1108 may compare the function stack of the memory allocation information when the tested process is started with the function stack of the memory allocation information when the tested process is exited, and determine that there are more function stacks in the memory allocation information when the tested process is exited than in the memory allocation information when the tested process is started, and that there are more function stacks that are memory leaks from the function stacks.
Fig. 12 is a block diagram showing the structure of a memory leak detection apparatus according to another embodiment. As shown in fig. 12, a memory leak detection apparatus includes a first statistical module 1110 in addition to a loading module 1102, a hooking module 1104, a collecting module 1106, and a comparing module 1108. Wherein:
the first statistical module 1110 is configured to sort multiple function stacks according to the sizes of corresponding function addresses, and perform classification statistics on the sorted function stacks to obtain the number of times of memory leakage of the function stacks and the size of memory leakage of the function stacks.
Specifically, the function stacks are classified, the leakage times of the function stacks of the same class are counted, and the memory leakage size of all the function stacks is calculated.
The comparison of a group of numbers actually adopts function stack comparison, the same function stack is calculated only if each number in the group is equal, the comparison of each number is needed to judge whether two function stacks are equal, the comparison is time-consuming when a large number of stacks are searched, and the function stacks can be sorted from large to small or from small to large according to function addresses by sorting the function stacks. The function stack after the sorting process is completed by using std: : the set data structure realizes the management of the red and black trees, reduces the complexity of the search time to O (lgn), and greatly shortens the search time.
In addition, the code line and the severity of the memory leakage, the change trend of the function stack of the memory allocation and the like can be counted, and the memory leakage problem can be better positioned through the change trend of the function stack.
According to the memory leak detection device, the memory monitoring dynamic link library is loaded when the tested process is started, the memory distribution function is hooked through the memory monitoring dynamic link library, the memory distribution information when the tested process is started and the memory distribution information after quitting are collected, the memory leak information is obtained by comparing the memory distribution information when the tested process is started and the memory distribution information when the tested process is quitted, the memory distribution information in the whole process from starting to quitting of the tested process is monitored, the monitoring time point is accurate, the obtained data are comprehensive, the counted result is not released all the time, and the obtained memory leak information is more accurate.
In an embodiment, the collecting module 1106 is further configured to call the memory allocation function and/or the windows system application programming interface through a hook function, and collect the memory monitoring information after the tested process is started.
Fig. 13 is a block diagram illustrating a memory leak detection apparatus according to another embodiment. As shown in fig. 13, the memory leak detection apparatus includes, in addition to a loading module 1102, a hooking module 1104, a collecting module 1106 and a comparing module 1108, a transmitting module 1112, a reading module 1114, a storing module 1116, a fetching module 1118, an allocating module 1120, a refreshing module 1122, a searching module 1124 and a deleting module 1126.
Wherein: the transmission module 1112 is configured to send the memory monitoring information to a data processing process, and the data processing process processes the memory monitoring information.
The transmission module 1112 is further configured to write the memory monitoring information into the shared memory.
The reading module 1114 is configured to read the memory monitoring information in the shared memory through the monitoring thread of the data processing process.
The storage module 1116 is used to store the read memory monitoring information into the cache of the data processing process.
The fetching module 1118 is configured to fetch the memory monitoring information from the cache through the allocation thread of the data processing process.
The allocation module 1120 is used for allocating the processing thread of the data processing process to perform processing.
The refreshing module 1122 is configured to refresh the memory allocation information obtained by processing the memory monitoring information of the process under test through the refreshing thread of the data processing process.
The memory monitoring information is memory allocation information or memory release information;
the searching module 1124 is configured to search, when the memory monitoring information is memory releasing information, whether corresponding memory allocation information exists in the cache of the data processing process according to the memory releasing information.
The deleting module 1126 is configured to delete the memory release information and the corresponding memory allocation information if the corresponding memory allocation information exists in the cache of the data processing process.
In a game program, a player enters another scene from one scene and returns to the original scene after the other scene is finished, and the memory leak detection comprises the following steps:
the collecting module 1106 is further configured to exit to a preamble scene to start collecting a first memory snapshot after entering a detected scene once, where the first memory snapshot records memory allocation information at a current time, and exit to the preamble scene to start collecting a second memory snapshot after entering the detected scene again, where the second memory snapshot records memory allocation information at the current time;
the comparing module 1108 is further configured to compare the memory allocation information recorded in the first memory snapshot with the memory allocation information recorded in the second memory snapshot to obtain the memory leakage information of the detected scene.
Or, the collecting module 1106 is further configured to collect a first memory snapshot when the game program is started, where the first memory snapshot records memory allocation information at the current time, and collect a second memory snapshot when the game program is exited, where the second memory snapshot records memory allocation information at the current time;
the comparing module 1108 is further configured to compare the memory allocation information recorded in the first memory snapshot with the memory allocation information recorded in the second memory snapshot to obtain the memory leakage information of the detected scene.
The memory allocation information comprises addresses of unreleased memory allocation, unreleased size of memory allocation and unreleased function stacks of memory allocation;
the comparing module 1108 is further configured to compare the function stack in the memory allocation information recorded in the first memory snapshot with the function stack in the memory allocation information recorded in the second memory snapshot, and determine that more function stacks in the memory allocation information recorded in the second memory snapshot are greater than that in the memory allocation information recorded in the first memory snapshot, and that more function stacks are a function stack memory leak.
Fig. 14 is a block diagram showing the structure of a memory leak detection apparatus according to another embodiment. As shown in fig. 14, a memory leak detection apparatus includes a second statistics module 1128 in addition to a loading module 1102, a hooking module 1104, a collecting module 1106, and a comparing module 1108.
The second statistical module 1128 is configured to sort multiple function stacks according to the sizes of the corresponding function addresses, and perform classification statistics on the sorted function stacks to obtain the number of times of memory leakage of the function stacks and the size of memory leakage of the function stacks.
Specifically, the function stacks are classified, the leakage times of the function stacks of the same class are counted, and the memory leakage size of all the function stacks is calculated.
In other embodiments, the memory leak apparatus may include any possible combination of the loading module 1102, the hooking module 1104, the collecting module 1106, the comparing module 1108, the first counting module 1110, the transmitting module 1112, the reading module 1114, the storing module 1116, the retrieving module 1118, the allocating module 1120, the refreshing module 1122, the searching module 1124, the deleting module 1126, and the second counting module 1128.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by a computer program, which can be stored in a non-volatile computer-readable storage medium, and can include the processes of the embodiments of the methods described above when the program is executed. The storage medium may be a magnetic disk, an optical disk, a Read-Only Memory (ROM), or the like.
The above-mentioned embodiments only express several embodiments of the present invention, and the description thereof is more specific and detailed, but not construed as limiting the scope of the present invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the inventive concept, which falls within the scope of the present invention. Therefore, the protection scope of the present patent shall be subject to the appended claims.
Claims (17)
1. A memory leak detection method includes the following steps:
automatically loading a preset memory monitoring dynamic link library when a tested process is started;
the memory distribution function and/or the windows system application programming interface are/is hooked through the memory monitoring dynamic link library;
calling the memory allocation function and/or the windows system application programming interface through a hook function, collecting memory allocation information when the tested process is started, and collecting memory allocation information when the tested process is quitted; the memory allocation information comprises memory allocation addresses, memory allocation sizes and memory allocation function stacks;
comparing the function stacks in the memory allocation information when the tested process is started with the function stacks in the memory allocation information when the tested process is exited, and judging that more function stacks in the memory allocation information when the tested process is exited are more than the memory allocation information when the tested process is started, so that the more function stacks are function stack memory leakage;
sorting a plurality of function stacks according to the corresponding function address size, and performing classified statistics on the sorted function stacks to obtain the function stack memory leakage times and the function memory leakage size;
sorting the leakage severity of the function stacks from large to small, and displaying the function stacks with the leakage severity sorted in the top by a preset number; and showing a graph of the change for each function stack.
2. The method of claim 1, further comprising:
calling the memory allocation function and/or the windows system application programming interface through a hook function, and collecting memory monitoring information after the tested process is started;
and sending the memory monitoring information to a data processing process, and processing the memory monitoring information by the data processing process.
3. The method according to claim 2, wherein the step of sending the memory monitoring information to a data processing process, and the step of processing the memory monitoring information by the data processing process comprises:
writing the memory monitoring information into a shared memory;
reading the memory monitoring information in the shared memory through the monitoring thread of the data processing process, and storing the memory monitoring information in the cache of the data processing process;
taking out the memory monitoring information from the cache through the allocation thread of the data processing process, and allocating the memory monitoring information to the processing thread of the data processing process for processing;
and refreshing the memory allocation information obtained by processing the memory monitoring information of the tested process through the refreshing thread of the data processing process.
4. The method according to claim 3, wherein the memory monitoring information is memory allocation information or memory release information;
the method further comprises the following steps:
and when the memory monitoring information is memory release information, searching whether corresponding memory allocation information exists in a cache of the data processing process according to the memory release information, and if so, deleting the memory release information and the corresponding memory allocation information.
5. The method of claim 1, further comprising:
after entering a tested scene, exiting to a preorder scene to start collecting a first memory snapshot, wherein the first memory snapshot records memory allocation information at the current moment;
after the scene to be tested is entered again, the scene exits to the preorder scene and starts to collect a second memory snapshot, and the second memory snapshot records the memory allocation information at the current moment;
comparing the memory allocation information recorded by the first memory snapshot with the memory allocation information recorded by the second memory snapshot to obtain the memory leakage information of the detected scene;
or, collecting a first memory snapshot when the game program is started, wherein the first memory snapshot records the memory allocation information at the current moment;
collecting a second memory snapshot when the game program exits, wherein the second memory snapshot records the memory allocation information at the current moment;
and comparing the memory allocation information recorded by the first memory snapshot with the memory allocation information recorded by the second memory snapshot to obtain the memory leakage information of the detected scene.
6. The method of claim 5,
the step of comparing the memory allocation information of the first memory snapshot record with the memory allocation information of the second memory snapshot record includes:
and comparing the function stack in the memory allocation information of the first memory snapshot record with the function stack in the memory allocation information of the second memory snapshot record, and judging that more function stacks are obtained in the memory allocation information of the second memory snapshot record than in the memory allocation information of the first memory snapshot record, so that the function stacks are function stack memory leakage.
7. The method of claim 6, further comprising:
and sequencing a plurality of function stacks according to the corresponding function address size, and performing classified statistics on the sequenced function stacks to obtain the function stack memory leakage times and the function memory leakage size.
8. A memory leak detection apparatus, comprising:
the loading module is used for automatically loading a preset memory monitoring dynamic link library when the tested process is started;
the hook module is used for hooking a memory distribution function and/or a windows system application program programming interface through the memory monitoring dynamic link library;
the collection module is used for calling the memory allocation function and/or the windows system application programming interface through the hook function, collecting memory allocation information when the tested process is started, and collecting memory allocation information when the tested process exits; the memory allocation information comprises memory allocation addresses, memory allocation sizes and memory allocation function stacks;
the comparison module is used for comparing the function stacks in the memory allocation information when the tested process is started with the function stacks in the memory allocation information when the tested process exits, and judging that more function stacks are obtained in the memory allocation information when the tested process exits than in the memory allocation information when the tested process is started, so that the more function stacks are function stack memory leakage; the first statistical module is used for sorting a plurality of function stacks according to the corresponding function address size, and then performing classified statistics on the sorted function stacks to obtain the function stack memory leakage times and the function memory leakage size;
the display module is used for sequencing the leakage severity of the stacks from large to small and displaying the stacks with the leakage severity sequenced in the front by a preset number; and showing a graph of the change for each function stack.
9. The apparatus according to claim 8, wherein the collection module is further configured to call the memory allocation function and/or a windows system application programming interface through a hook function, and collect memory monitoring information after the start of the process under test;
the device further comprises:
and the transmission module is used for sending the memory monitoring information to a data processing process, and the data processing process processes the memory monitoring information.
10. The apparatus of claim 9, wherein the transmission module is further configured to write the memory monitoring information into a shared memory;
the device further comprises:
the reading module is used for reading the memory monitoring information in the shared memory through the monitoring thread of the data processing process;
the storage module is used for storing the read memory monitoring information into a cache of the data processing process;
the fetching module is used for fetching the memory monitoring information from the cache through the distribution thread of the data processing process;
the distribution module is used for distributing the processing thread of the data processing process to process;
and the refreshing module is used for refreshing the memory allocation information obtained by processing the memory monitoring information of the tested process through the refreshing thread of the data processing process.
11. The apparatus according to claim 10, wherein the memory monitoring information is memory allocation information or memory release information;
the device further comprises:
the searching module is used for searching whether corresponding memory allocation information exists in a cache of the data processing process according to the memory release information when the memory monitoring information is the memory release information;
and the deleting module is used for deleting the memory release information and the corresponding memory allocation information if the corresponding memory allocation information exists in the cache of the data processing process.
12. The apparatus according to claim 8, wherein the collecting module is further configured to exit to a preamble scene to start collecting a first memory snapshot after entering a measured scene, where the first memory snapshot records memory allocation information at a current time, and exit to the preamble scene to start collecting a second memory snapshot after entering the measured scene again, where the second memory snapshot records memory allocation information at the current time;
the comparison module is further used for comparing the memory allocation information recorded by the first memory snapshot with the memory allocation information recorded by the second memory snapshot to obtain the memory leakage information of the detected scene;
or the collection module is further configured to collect a first memory snapshot when the game program is started, where the first memory snapshot records memory allocation information at the current time, and collect a second memory snapshot when the game program is exited, where the second memory snapshot records memory allocation information at the current time;
the comparison module is further configured to compare the memory allocation information recorded in the first memory snapshot with the memory allocation information recorded in the second memory snapshot to obtain the memory leakage information of the detected scene.
13. The apparatus of claim 12,
the comparing module is further configured to compare the function stack in the memory allocation information recorded in the first memory snapshot with the function stack in the memory allocation information recorded in the second memory snapshot, and determine that there are more function stacks in the memory allocation information recorded in the second memory snapshot than in the memory allocation information recorded in the first memory snapshot, where the more function stacks are memory leaks from the function stacks.
14. The apparatus of claim 13, further comprising:
and the second statistical module is used for sequencing a plurality of function stacks according to the corresponding function addresses, and then performing classified statistics on the sequenced function stacks to obtain the function stack memory leakage times and the function memory leakage size.
15. A terminal comprising a memory and a processor, the memory storing a computer program that, when executed by the processor, causes the processor to perform the steps of the method according to any one of claims 1 to 7.
16. A server comprising a memory and a processor, the memory storing a computer program that, when executed by the processor, causes the processor to perform the steps of the method of any one of claims 1 to 7.
17. A computer-readable storage medium, storing a computer program which, when executed by a processor, causes the processor to carry out the steps of the method according to any one of claims 1 to 7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510697835.1A CN106610892B (en) | 2015-10-23 | 2015-10-23 | Memory leak detection method and device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510697835.1A CN106610892B (en) | 2015-10-23 | 2015-10-23 | Memory leak detection method and device |
Publications (2)
Publication Number | Publication Date |
---|---|
CN106610892A CN106610892A (en) | 2017-05-03 |
CN106610892B true CN106610892B (en) | 2020-12-22 |
Family
ID=58612791
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201510697835.1A Active CN106610892B (en) | 2015-10-23 | 2015-10-23 | Memory leak detection method and device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN106610892B (en) |
Families Citing this family (27)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107145447B (en) * | 2017-05-09 | 2020-07-07 | 网易(杭州)网络有限公司 | Method and device for detecting memory leakage and electronic equipment |
CN107360317B (en) * | 2017-06-29 | 2020-12-01 | 湖南胜云光电科技有限公司 | Application program resource leakage detection method, mobile terminal and storage medium |
CN107480047A (en) * | 2017-07-13 | 2017-12-15 | 珠海金山网络游戏科技有限公司 | A kind of method and device of internal memory auto snapshot |
CN107908539B (en) * | 2017-07-24 | 2020-07-17 | 平安科技(深圳)有限公司 | Method, terminal and computer readable storage medium for detecting memory leakage of application program |
CN107562586A (en) * | 2017-08-16 | 2018-01-09 | 努比亚技术有限公司 | A kind of internal-memory detection method, equipment and computer-readable storage medium |
CN107797898B (en) * | 2017-09-28 | 2020-11-27 | 东软集团股份有限公司 | Data acquisition method and device thereof |
CN108121602B (en) * | 2017-12-14 | 2022-05-06 | 捷开通讯(深圳)有限公司 | Method for determining garbage collection trigger point, electronic equipment and storage medium |
CN108108258B (en) * | 2017-12-29 | 2020-11-06 | 杭州迪普科技股份有限公司 | Memory leak repairing method and device |
CN108334435B (en) * | 2018-01-18 | 2021-12-24 | 杭州迪普科技股份有限公司 | Method and device for reminding leakage of shared memory |
CN110413401A (en) * | 2018-04-28 | 2019-11-05 | 武汉斗鱼网络科技有限公司 | Manage method, storage medium, electronic equipment and the system of global object's memory |
CN108984295B (en) * | 2018-06-19 | 2020-08-07 | 珠海全志科技股份有限公司 | Memory recovery method, computer device and computer readable storage medium |
CN109656779A (en) * | 2018-12-07 | 2019-04-19 | 广州市百果园信息技术有限公司 | Internal memory monitoring method, device, terminal and storage medium |
CN109933525A (en) * | 2019-02-22 | 2019-06-25 | 深圳市吉祥腾达科技有限公司 | A kind of general method for detecting memory leakage |
CN110032464B (en) * | 2019-03-15 | 2023-06-16 | 北京星网锐捷网络技术有限公司 | Memory leakage processing method and device |
CN110059004B (en) * | 2019-03-21 | 2021-08-17 | 深圳市腾讯信息技术有限公司 | Application testing method, device, equipment and medium |
CN110618928A (en) * | 2019-06-25 | 2019-12-27 | 北京无限光场科技有限公司 | Memory leak detection method and device, terminal equipment and medium |
CN110727585B (en) * | 2019-09-11 | 2023-07-21 | 锐捷网络股份有限公司 | Memory leak detection method, device, electronic equipment and readable storage medium |
CN110633190B (en) * | 2019-09-26 | 2023-08-29 | 北京博睿宏远数据科技股份有限公司 | Application program memory monitoring method, device, equipment and storage medium |
CN111190833B (en) * | 2019-11-26 | 2023-03-24 | 腾讯云计算(北京)有限责任公司 | Sensitive data detection method and device, storage medium and equipment |
CN111597109B (en) * | 2020-04-24 | 2022-03-11 | 清华大学 | Defect detection method and system for cross-architecture firmware stack memory |
CN111832022B (en) * | 2020-07-03 | 2024-02-13 | 北京智游网安科技有限公司 | Double Free vulnerability detection method, terminal and storage medium |
CN111931191A (en) * | 2020-09-09 | 2020-11-13 | 中国人民解放军国防科技大学 | Dynamic detection method and system for binary software stack overflow leakage hole of Linux platform |
CN114253825B (en) * | 2020-09-22 | 2024-06-21 | 腾讯科技(深圳)有限公司 | Memory leak detection method, device, computer equipment and storage medium |
CN113157455B (en) * | 2021-04-27 | 2024-07-30 | 腾讯科技(深圳)有限公司 | Memory management method, memory management device, electronic equipment and computer readable storage medium |
CN115617504A (en) * | 2022-09-06 | 2023-01-17 | 成都赛力斯科技有限公司 | Memory management system, leakage detection method and storage medium |
CN117574354A (en) * | 2023-10-26 | 2024-02-20 | 中科驭数(北京)科技有限公司 | Method, device and system for detecting DPDK large page memory leakage |
CN117453446B (en) * | 2023-12-15 | 2024-04-26 | 荣耀终端有限公司 | Auxiliary information acquisition method for memory leakage positioning and electronic equipment |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US7761852B2 (en) * | 2003-11-26 | 2010-07-20 | International Business Machines Corporation | Fast detection of the origins of memory leaks when using pooled resources |
CN102073591A (en) * | 2011-01-14 | 2011-05-25 | 福建星网视易信息系统有限公司 | Method and system for detecting memory occupancy state of embedded system |
CN102081548A (en) * | 2009-11-30 | 2011-06-01 | 华为技术有限公司 | Method and system for processing Java application and SAF (service availability forum) platform |
CN103902359A (en) * | 2014-03-31 | 2014-07-02 | 深圳创维-Rgb电子有限公司 | Android based system memory optimizing and application scheduling method and system |
US8996743B1 (en) * | 2013-09-25 | 2015-03-31 | International Business Machines Corporation | Event driven remote direct memory access snapshots |
CN104636256A (en) * | 2015-02-17 | 2015-05-20 | 中国农业银行股份有限公司 | Memory access abnormity detecting method and memory access abnormity detecting device |
Family Cites Families (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20100095281A1 (en) * | 2008-10-14 | 2010-04-15 | Riverside Research Institute | Internal Function Debugger |
CN102831068B (en) * | 2011-06-13 | 2016-04-06 | 阿里巴巴集团控股有限公司 | A kind of disposal route of internal memory operation record and device |
CN103150220B (en) * | 2011-12-07 | 2016-08-31 | 腾讯科技(深圳)有限公司 | Communication means between process and communication system |
CN103294588A (en) * | 2012-02-22 | 2013-09-11 | 深圳富泰宏精密工业有限公司 | Memory detecting system and method |
-
2015
- 2015-10-23 CN CN201510697835.1A patent/CN106610892B/en active Active
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US7761852B2 (en) * | 2003-11-26 | 2010-07-20 | International Business Machines Corporation | Fast detection of the origins of memory leaks when using pooled resources |
CN102081548A (en) * | 2009-11-30 | 2011-06-01 | 华为技术有限公司 | Method and system for processing Java application and SAF (service availability forum) platform |
CN102073591A (en) * | 2011-01-14 | 2011-05-25 | 福建星网视易信息系统有限公司 | Method and system for detecting memory occupancy state of embedded system |
US8996743B1 (en) * | 2013-09-25 | 2015-03-31 | International Business Machines Corporation | Event driven remote direct memory access snapshots |
CN103902359A (en) * | 2014-03-31 | 2014-07-02 | 深圳创维-Rgb电子有限公司 | Android based system memory optimizing and application scheduling method and system |
CN104636256A (en) * | 2015-02-17 | 2015-05-20 | 中国农业银行股份有限公司 | Memory access abnormity detecting method and memory access abnormity detecting device |
Also Published As
Publication number | Publication date |
---|---|
CN106610892A (en) | 2017-05-03 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN106610892B (en) | Memory leak detection method and device | |
US8141053B2 (en) | Call stack sampling using a virtual machine | |
US7886198B2 (en) | Method and system of identifying overlays used by a program | |
US7603589B2 (en) | Method and system for debugging a software program | |
US8132170B2 (en) | Call stack sampling in a data processing system | |
CN109656779A (en) | Internal memory monitoring method, device, terminal and storage medium | |
CN106326067B (en) | A kind of method and device that cpu performance is monitored under pressure test | |
US7178066B2 (en) | Apparatus and method for processor performance monitoring | |
US20100017583A1 (en) | Call Stack Sampling for a Multi-Processor System | |
CN109933504B (en) | Hard disk delay test method, device, terminal and storage medium | |
CN110955598B (en) | Breakpoint processing method and device for kernel mode program | |
CN112035314A (en) | Memory leakage monitoring method and device and electronic equipment | |
US7607047B2 (en) | Method and system of identifying overlays | |
CN110704303B (en) | Method and device for acquiring test coverage information | |
CN110597704A (en) | Application program pressure testing method, device, server and medium | |
CN109542341B (en) | Read-write IO monitoring method, device, terminal and computer readable storage medium | |
CN112631941B (en) | Method and system for locating linux kernel slub memory leakage | |
US9348723B2 (en) | Method, system, and computer program product | |
CN111625853B (en) | Snapshot processing method, device and equipment and readable storage medium | |
CN113760187A (en) | Method, system, terminal and storage medium for generating deduplication IO thread based on vdbench | |
CN107451038B (en) | Hardware event acquisition method, processor and computing system | |
CN111752715A (en) | System optimization method, device, equipment and storage medium under large quantity of requests | |
CN118250206A (en) | High concurrency pressure testing method and related device based on flow playback | |
EP3995966A1 (en) | System and method for automatic application log messages grouping using logging framework code instrumentation | |
US20170192878A1 (en) | Separating Test Coverage In Software Processes Using Shared Memory |
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 |