Tag Archives: debugging

Debugging Assembly loading

Does a referenced assembly get loaded if no types in the assembly are “not used”?The term used is is very subjective. For a developer it would mean that you probably never created an instance or called a method on it. But this does not cover the whole story. You can instead consider what are the reasons for an assembly load occurring. Suzanne’s blog on Assembly loading Failures would give you a good understanding of failures if that is what you are interested in. This post focuses on how to identify what exactly is causing an assembly to load.We in the WCF team are very cautious on introducing assembly dependencies and how how our code paths can cause assembly loads since this impacts the reference set of your process. Images that get loaded during a WCF call can become the cause of slow start up since every assembly is a potential disk look up and larger the number the higher the impact to startup.  As a guidance for quick app startup is that you can eliminate a lot of the unnecessary assemblies from being loaded to speed up application startup if you refactor types properly. Continue reading

ServiceHosts & executing Operations from a crash/hang dump

Incase you are not sure of how to debug managed code with with a crash/hang dump, then you most likely need to read this first. Once you have SOS and mscordacwks(.net 3.5 and up)  loaded you first dump the heap to find out if you have any services hosts at all.

  1. We quickly find the method table entry for the ServiceHost type. We can get this from !dumpheap command as shown below. The following command helps to filter out just the types we are interested in.

    !dumpheap –stat –type System.Servicemodel.ServiceHost

    Media_httpsajaycomwpw_epnjz
  2. The next step is to dump all the ServiceHost using the method table entry shown above. The foreach command in the debugger helps us to loop through all objects that below to the type.

    .foreach(x {!dumpheap -short -mt 000007fef39ba7f0}) {!do x}
    Media_httpsajaycomwpw_flyio
  3. Our next step would be to find out how many calls are pending on the service. For this we can examine the ServiceThrottle on calls Field the service host. You can either use the instance value of the service throttle or offset. The following shows the call throttle and the count value in the flow throttle object would show how many services are being executed. The FlowThrottle is the object that holds the counters for the calls for the service.
    Media_httpsajaycomwpw_xcije

    In this case there is nothing executing so this dump was probably collected when there was no load. This is a quick way to identify if your service was actually executing any operations when collecting a process dump.