Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

.Net debugging 2017


Published on

Slides for .NET Debugging Presentation

Published in: Software
  • Be the first to comment

.Net debugging 2017

  1. 1. .NET DEBUGGING @TessFerrandez Microsoft
  2. 2. Crashes Performance Issues Memory Leaks Issues that we can’t step by step debug @TessFerrandez
  4. 4. User-mode dump Snapshot of a process and the memory it addresses @TessFerrandez
  5. 5. Threads call stacks, stack objects Modules dlls, exes .NET Heap .net objects, sizes, info @TessFerrandez
  7. 7. TASK MANAGER @TessFerrandez
  8. 8. PROCDUMP Light-weight, no-install utility for generating dumps Procdump –ma app.exe app.dmp Procdump –ma –h app.exe hang.dmp Procdump –ma –e app.exe crash.dmp Procdump –ma –c 90 app.exe cpu.dmp @TessFerrandez
  9. 9. DEBUG DIAG GUI tool to generate dumps based on rules and analyze dumps for common .net issues @TessFerrandez
  11. 11. WINDBG Native debugger Installed with WDK and Debugging tools for Windows @TessFerrandez
  12. 12. @TessFerrandez DEBUG DIAG
  13. 13. VISUAL STUDIO @TessFerrandez
  14. 14. CRASHES
  15. 15. When I open an email with a pdf attachement that is larger than 2 MB, a message box saying Unknown Error shows up and then the process exits Tess!!! the internet e-thingy is not working anymore
  16. 16. WHO DUNNIT? Unhandled Exception – 2nd chance StackOverflowException OutOfMemoryException ExecutionEngineException Kill or recycle
  17. 17. 1 Check the event viewer 2 Capture dump on crash 3 Look at the faulting stack @TessFerrandez
  19. 19. App is not responding Requests take too long How long should they take? CPU is going hey-wire
  20. 20. WHO DUNNIT? LOW CPU Waiting for an external resource Deadlock HIGH CPU Busy, Tight loop High CPU in GC
  21. 21. 1 Determine if it is high or low CPU 2 Capture one or more dumps 3 Look at all stacks If you can repro in test, consider profiling @TessFerrandez
  22. 22. MEMORY LEAKS
  23. 23. OutOfMemoryExceptions Slow response times Due to GC activities Memory increase in perfmon or task manager
  24. 24. WHO DUNNIT? Cache or Session State Static / Pinned Blocked Finalizer Assembly Leak Native Leak
  25. 25. 1 Capture multiple dumps 2 Compare to see what objects are leaking 3 Find out why they are still around For native leaks, use leaktracking in debug diag @TessFerrandez
  26. 26. AUTOMATION
  27. 27. CLRMD @TessFerrandez
  28. 28. DataTarget target = DataTarget.LoadCrashDump(@"TheApp.dmp"); target.SymbolLocator.SymbolCache = @"c:symbols"; target.SymbolLocator.SymbolPath = ""; var runtime = target.ClrVersions[0].CreateRuntime(); Console.WriteLine("Is Server GC: {0}", runtime.ServerGC); Console.WriteLine("Number of heaps: {0}", runtime.HeapCount); Console.WriteLine("Number of threads: {0}", runtime.Threads.Count); @TessFerrandez
  29. 29. foreach (var thread in runtime.Threads) { var e = thread.CurrentException; if (e != null) { Console.WriteLine("Thread {0}", thread.ManagedThreadId); Console.WriteLine("t{0} - {1}", e.Type.Name, e.Message); foreach (var frame in e.StackTrace) { Console.WriteLine("t" + frame.DisplayString); } } } @TessFerrandez
  30. 30. .NET DEBUGGING @TessFerrandez Microsoft