How to Check Memory Leaks From Running the Application using UMDH?

While running some applications we might have noticed the memory resource consumption going high, This is all fine if the memory gets released when the application is stopped or killed. But what if the memory consumption does not come down even after the application is killed or stopped?

This is when we say that Memory Leaks are present in the application. Tricky part is how can we identify them? For a simple application finding the root cause can be tricky no need to mention how challenging it would be to find the root cause in the case of large commercial application which is composed of several modules.

In these situations UMDH can come to the rescue by pointing out the memory allocation and deallocation by each modules present in the process and giving hints where it might be going wrong. UMDH is typically used in situations where we have to find memory leak in the execution path of some action being performed.

Following are the steps that needs to be done for narrowing down to the root cause of memory leak.

Memory Leak Detection using UMDH

How to RUN UMDH tool to collect Memory Leaks:

-------------------------------------------------------------

==> Run .exe which is causing the leak and Perform the operations what needs to be done and follow the below steps 


1. Collect Initial Snapshot:

----------------------------------

E:\softwares\Windbg>umdh.exe -pn:<ProcessName>.exe -f:Snapshot1.txt


2.Collect second Snapshot:

-----------------------------------

E:\softwares\Windbg>umdh.exe -pn:<ProcessName>.exe -f:Snapshot2.txt


3. Generate Diff from the two snapshots:

--------------------------------------------------

E:\softwares\Windbg>umdh.exe -d Snapshot1.txt Snapshot2.txt > diffbetweenSnap1andSnap2.txt

Here <ProcessName> is the placeholder where we have to enter the suspected process and Snapshot1.txt and Snapshot2.txt are the files where the memory allocation and deallocation are dumped.

Once these files are generated we have to take the diff between the two snapshots to determine which module in the process has allocated memory and not yet released.








Comments

Popular posts from this blog

Creating RESTful Minimal WebAPI in .Net 6 in an Easy Manner! | FastEndpoints

Mastering Concurrency with Latches and Barriers in C++20: A Practical Guide for Students

Graph Visualization using MSAGL with Examples