Determine the Current Memory Usage of an Assembly

  • Thread starter Thread starter James Wansley
  • Start date Start date
J

James Wansley

I am currently running a c# service that dynamically loads assemblies
using System.Reflection.Assembly.LoadFrom("aDll.dll"). These
assemblies are stored in an arraylist after they are loaded.

I would like to periodically report the memory usage of each assembly
within the arraylist. I tried
System.Diagnostics.ProcessModule.ModuleMemorySize, but this only shows
the size of the structures within the .dll, not the current memory
usage. Does anyone know of a method to determine the memory usage of
a loaded assembly?

Thanks in advance
-James Wansley
 
James,

This is going to be rather difficult. If anything, you need to get a
tool that will profile the memory usage by class instance, from which you
could figure out which instances of which types come from which assembly
(already a big task).

However, I wouldn't recommend using any of these in production code, as
they would require you to hook into the runtime, and will most likely cause
a performance degredation.

Hope this helps.
 
Back
Top