Skip to content

Instantly share code, notes, and snippets.

@nickfloyd
Last active May 25, 2023 12:22
Show Gist options
  • Save nickfloyd/a332462f85ac32372c74 to your computer and use it in GitHub Desktop.
Save nickfloyd/a332462f85ac32372c74 to your computer and use it in GitHub Desktop.
windbg commands for finding memory leaks
From:
http://blogs.msdn.com/b/paullou/archive/2011/06/28/debugging-managed-code-memory-leak-with-memory-dump-using-windbg.aspx
#Set symbols File >> Symbol File path
SRV*c:\symbols*http://msdl.microsoft.com/download/symbols
.reload
.loadby sos clr or .loadby sos mscorwks!
#optional
!VerifyHeap
#Find largest GC Heapsize - leak is possible if > 1gb or so
!EEHeap
#Find type with the largest size
!dumpheap -stat
#put type here - find type with the largest size
!dumpheap -type [TYPE]
#put largest result here
!do [ADDRESS]
#Loop above as needed, this is where it gets a bit fuzzy. Look for repeating patterns and high threads
#get a count of thread on the thing. Find a high thread count
!threads
#Pick a thread to look at it's stack - alternatively you can rum ~*kb for all thread stacks
~[THREAD ID]s
#show the stack
Kb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment