Giter Site home page Giter Site logo

advanceddotnetdebugging's Introduction

Advanced .NET Debugging with WinDbg and SOS

The first demo involves taking a crash dump of a process that encounters an unhandled exception during startup. To capture the dump, use the following command:

procdump -e -ma -x 1_Crash\Binaries\FileExplorer.exe crash.dmp

Then, open the dump in Visual Studio or in WinDbg. In WinDbg, load SOS and then issue the !PrintException command to obtain a stack trace of the exception that occurred.

The second demo involves a memory leak and is somewhat more complicated to diagnose. The source of the memory leak has to do with the finalization queue: the application creates objects at a rate of 100/second, but each object's finalizer takes 20ms to run (because it calls Thread.Sleep). As a result, only 50 objects can be cleaned up per second, creating a memory leak. Some commands that are useful for the diagnosis:

!dumpheap -stat
.foreach (bytearr {!dumpheap -type System.Byte[] -min 500 -short}) {!gcroot bytearr; .echo --------}
!finalizequeue

The third demo involves a deadlock -- two threads are waiting to acquire two different synchronization objects, but each object is owned by another thread. To diagnose the situation, use the SOSEX debugging extension and its !dlk command.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.