SlideShare a Scribd company logo
1 of 11
Download to read offline
   Stands for User Mode Dump Heap

   Can be downloaded for free as part of the
    Windows 7 SDK (also works for Windows XP)

   Helps you to find memory leaks in running
    processes!
1.   Set the _NT_SYMBOL_PATH environment var to:
     srv*c:symbols*http://msdl.microsoft.com/download/symbols;




2.   Append the path to your executable
1. Flag your process under test as being
    monitored:
C:> gflags -i Test.exe +ust

 2. Start your process under test:
C:> Test.exe

 3. Take an initial “snapshot” of allocated
    memory as Test.exe runs:
C:> umdh -pn:Test.exe -f:C:f1.txt
4.   Exercise your program in a way that you
      think may make it leak memory.
 5. Take a second snapshot and save it with a
    different file name from the first.
C:> umdh -pn:Test.exe -f:C:f2.txt
 6.Use UMDH to “diff” the first and last
   snapshots taken to get the best idea of what
   has leaked
C:> umdh -d f1.txt f2.txt > f12.txt
   The “diff” file shows a stack trace, and the
        number/size of allocations that were allocated but not
        freed between two snapshots.
+       483328 ( 487424 -   4096)   119 allocs      BackTrace23FF
+          118 (    119 -      1)     BackTrace23FF allocations

 ntdll!RtlDebugAllocateHeap+000000E1
 ntdll!RtlAllocateHeapSlowly+00000044
 ntdll!RtlAllocateHeap+00000E64
 kernel32!FindNextFileW+00000077
 kernel32!FindNextFileA+00000028
 MSVCR80D!findnext64i32+00000178
 Test!readdir+00000075 (c:myprojectutil.cpp, 674)
…
Bytes “leaked” between
                                             the two snapshots


+   483328 ( 487424 -   4096)   119 allocs      BackTrace23FF
+      118 (    119 -      1)     BackTrace23FF allocations

 ntdll!RtlDebugAllocateHeap+000000E1
 ntdll!RtlAllocateHeapSlowly+00000044
 ntdll!RtlAllocateHeap+00000E64
 kernel32!FindNextFileW+00000077
 kernel32!FindNextFileA+00000028
 MSVCR80D!findnext64i32+00000178
 Test!readdir+00000075 (c:myprojectutil.cpp, 674)
…

                                          Stacktrace showing
                                          where the “leaked”
                                         memory was allocated.
   At the very bottom of the file, there is an
      overall summary of how much memory was
      allocated but not freed. E.g.:

Total increase == 13919896 requested + 830364 overhead = 14750260


     If used as part of an automated test, it is fairly
      easy to extract the “Total increase” number
      using a Perl script and graphs of memory
      allocations and usage over time.
   UMDH is a useful tool for finding
    memory leaks in Windows
    applications.

   Its output is a file listing outstanding
    memory allocations that can be read
    directly, or processed by another
    program or script.
   http://msdn.microsoft.com/en-
    us/library/ff558947%28v=vs.85%29.aspx
Finding Memory Leaks with UMDH

More Related Content

Recently uploaded

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

Recently uploaded (20)

Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 

Featured

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 

Featured (20)

Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 

Finding Memory Leaks with UMDH

  • 1.
  • 2. Stands for User Mode Dump Heap  Can be downloaded for free as part of the Windows 7 SDK (also works for Windows XP)  Helps you to find memory leaks in running processes!
  • 3. 1. Set the _NT_SYMBOL_PATH environment var to: srv*c:symbols*http://msdl.microsoft.com/download/symbols; 2. Append the path to your executable
  • 4. 1. Flag your process under test as being monitored: C:> gflags -i Test.exe +ust 2. Start your process under test: C:> Test.exe 3. Take an initial “snapshot” of allocated memory as Test.exe runs: C:> umdh -pn:Test.exe -f:C:f1.txt
  • 5. 4. Exercise your program in a way that you think may make it leak memory. 5. Take a second snapshot and save it with a different file name from the first. C:> umdh -pn:Test.exe -f:C:f2.txt 6.Use UMDH to “diff” the first and last snapshots taken to get the best idea of what has leaked C:> umdh -d f1.txt f2.txt > f12.txt
  • 6. The “diff” file shows a stack trace, and the number/size of allocations that were allocated but not freed between two snapshots. + 483328 ( 487424 - 4096) 119 allocs BackTrace23FF + 118 ( 119 - 1) BackTrace23FF allocations ntdll!RtlDebugAllocateHeap+000000E1 ntdll!RtlAllocateHeapSlowly+00000044 ntdll!RtlAllocateHeap+00000E64 kernel32!FindNextFileW+00000077 kernel32!FindNextFileA+00000028 MSVCR80D!findnext64i32+00000178 Test!readdir+00000075 (c:myprojectutil.cpp, 674) …
  • 7. Bytes “leaked” between the two snapshots + 483328 ( 487424 - 4096) 119 allocs BackTrace23FF + 118 ( 119 - 1) BackTrace23FF allocations ntdll!RtlDebugAllocateHeap+000000E1 ntdll!RtlAllocateHeapSlowly+00000044 ntdll!RtlAllocateHeap+00000E64 kernel32!FindNextFileW+00000077 kernel32!FindNextFileA+00000028 MSVCR80D!findnext64i32+00000178 Test!readdir+00000075 (c:myprojectutil.cpp, 674) … Stacktrace showing where the “leaked” memory was allocated.
  • 8. At the very bottom of the file, there is an overall summary of how much memory was allocated but not freed. E.g.: Total increase == 13919896 requested + 830364 overhead = 14750260  If used as part of an automated test, it is fairly easy to extract the “Total increase” number using a Perl script and graphs of memory allocations and usage over time.
  • 9. UMDH is a useful tool for finding memory leaks in Windows applications.  Its output is a file listing outstanding memory allocations that can be read directly, or processed by another program or script.
  • 10. http://msdn.microsoft.com/en- us/library/ff558947%28v=vs.85%29.aspx