Summary
We have to understand which part of our (or third party, probably CLR itself) code leads to boxing of integers.
Problem description
We have a rather big application where we observe high allocation rate of System.Int32
instances. With the help of Memory Profiler we see a small number of long existing Int32
instances (18, to be exact) and 20-25 thousands of Int32
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.
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.
System is compiled using VS2008, and uses .Net 3.5 (measurements were done in both debug and release builds, with the same behavior).
Question
How can we (using windbg, VS2008, Memory Profiler, AQTime or any other commercially available product) detect why boxing happens ?