title: How to detect cause of boxing in .Net?
body: <h3>Summary</h3>
  
  <p>We have to understand which part of our (or third party, probably CLR itself) code leads to boxing of integers.</p>
  
  <h3>Problem description</h3>
  
  <p>We have a rather big application where we observe high allocation rate of <code>System.Int32</code> instances. With the help of Memory Profiler we see a small number of long existing <code>Int32</code> instances (18, to be exact) and 20-25 thousands of <code>Int32</code> allocations per second. All those objects are GC collected as Gen0 objects, system has no memory leaks  and can be run for long time. When memory snapshot is created, GC is executed before snapshot, so snapshot does not contains any traces of those “temporary” objects.</p>
  
  <p>All our code was specifically written to eliminate boxing whenever possible, and “by design” we are supposed to not see boxings at all. So we suspect it is some non-eliminated forgotten boxing in our code, or boxing caused by third-party component and/or CLR type itself.</p>
  
  <p>System is compiled using VS2008, and uses .Net 3.5 (measurements were done in both debug and release builds, with the same behavior).</p>
  
  <h3>Question</h3>
  
  <p>How can we (using windbg, VS2008, Memory Profiler, AQTime or any other commercially available product) detect why boxing happens ?</p>