Windows Memory leak detection tool-leakdiag

Source: Internet
Author: User

The check of Memory leakage is essentially to locate Memory leakage. This positioning includes two meanings:

The first is the positioning module, that is, the module that has encountered a problem.

Second, locate the code, that is, find the code that causes memory leakage.

In this regard, in the context of division of labor and cooperation to complete a system, we should check the memory leakage workflow: first, locate the module; second, if there is a problem with our module, locate the code.

 

Checking for memory leaks is more like a detective. Only by finding enough evidence can we find the real cause. In order to become a good detective, the reconnaissance capability is the most important. Good detectives generally have some good detective tools.

 

So how should we evaluate the advantages and disadvantages of the memory leak check tool? Here, let's imagine:

1) It can freely choose the monitoring time point;

2) It can attach any running process to track memory leaks;

3) I do not need to add any code in my program;

4) without source code, I can still find memory leaks;

5) I can get the heap state of memory allocation but not released each time.

6) whether it is the release version or the debugging version of the program, the above points can be achieved.

 

Here, we recommend that you use leakdiag, a tool developed by Microsoft.

 

Leakdiag is a tool used to monitor memory leaks. It can be used to precisely locate memory leaks until the code line. It uses Microsoft's detours technology to intercept calls with specified memory allocation, track various call stacks, and report allocated but not released memory, this information allows us to precisely check which components are allocated when we eliminate a memory leak. With the correct debugging symbol, we can even see the code lines allocated by the request. Compared with various memory leak detection tools on the market, I think this tool has better achieved the above six points.

 

Leakdiag supports five different distributions:

1) virtual allocation. This allocation can trace the memory allocated by virtual memory, such as virtualalloc/virtualallocex. In this case, select the "Virtual Memory Allocator" option of [Memory allocators] On leakdiag to detect.

2) Heap allocation. This allocation can track the memory allocated by the following functions in Ntdll. dll.

· Rtlcreateheap,

· Rtldestroyheap,

· Rtlallocateheap,

· Rtlfreeheap,

· Rtlreallocateheap,

· Localrealloc,

· Localfree,

· Localalloc,

· Localrealloc,

· Globalalloc,

· Globalrealloc and

· Globalfree

In this case, select "Windows heap Allocator" for the [Memory allocators] Option on leakdiag to detect the event.

3) Thread Local Storage (TLS refers to a Win32 mechanism that allows multiple threads of a process to store data unique to each thread) allocation. This allocation can track the memory allocated by the following functions in msdart32.dll.

· Mpheapalloc,

· Mpheapfree and

· Mpheaprealloc

In this case, select "mpheap Allocator" for the [Memory allocators] Option on leakdiag to detect the event.

4) com allocation (external and internal ). This allocation can be traced to ole32.dll, and the memory allocated by the following function in oleaut32.dll.

· Cogetmalloc,

· Cotaskmemalloc,

· Cotaskmemfree,

· Cotaskmemrealloc,

· Cretailmalloc_alloc,

· Cretailmalloc_free,

· Cretailmalloc_realloc,

· Sysallocstringlen,

· Sysallocstringbytelen,

· Sysallocstring,

· Sysfreestring,

· Sysreallocstring and

· Sysreallocstringlen

In this case, select "com Allocator" or "com internal Allocator" for the [Memory allocators] Option on leakdiag to detect the event.

5) C is allocated during runtime. This allocation can track the memory allocated by the following functions in msvcrt. dll.

· Malloc,

· Calloc,

· Realloc,

· Free,

· New,

· New [],

· Delete and

· Delete []

In this case, select "C Runtime Allocator" for the [Memory allocators] Option on leakdiag to detect the event.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.