How to measure the size of an object.

  • Thread starter Thread starter Frank Rizzo
  • Start date Start date
F

Frank Rizzo

I am doing some memory profiling work and I am trying to figure out the
minimum size of an object. The object has a bunch of variables that are
other objects (hashtables, array lists, and whatnot).

How can I measure the size of such an object? C# provides a sizeof
operator, but only for value types.

Regards,
Robert
 
Robert,

You can't really do this through managed code. If you wanted to do
this, you would have to hook into the CLR using the debugging interfaces (a
bunch of COM work), and do it from there. The CLR doesn't expose this
information to managed code.

Hope this helps.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top