Search code examples
c#multithreadingwindbgsos

Which thread is using a given object?


  1. I run dumpheap -type MyObjectType command to get the method table for MyObjectType. It shows three object on heap.
  2. I run dumpheap -mt <method table address> to get address.
  3. I run !gcroot <address> command to find the references to these objects, find nothing
  4. !do <address> and it provides details about fields for this object etc.

How can I find which thread is referencing or using object? Any command to find that out?


Solution

  • There's no easy way to do this, but you could run !dso for each thread (i.e. ~*!dso). That will tell you which objects each of the threads reference. To help navigate the output I usually log it to a file and use grep or a decent text editor to search the results.