Memory usage

  • Thread starter Thread starter Sgt. Sausage
  • Start date Start date
S

Sgt. Sausage

How can I get the amount of memory an arbitrary
instance is consuming? The typeof() operator is
not good for what I'm looking for -- I need to
pass in any arbitrary instance of any arbitrary
class. It needs to be recursive -- if that's the
word. It needs to follow the references to any
child objects and retrieve their size too, recursing
to any child objects of the child objects, etc.

Can someone suggest a method of doing this?

Thanks.
 
Sgt. Sausage said:
How can I get the amount of memory an arbitrary
instance is consuming? The typeof() operator is
not good for what I'm looking for -- I need to
pass in any arbitrary instance of any arbitrary
class. It needs to be recursive -- if that's the
word. It needs to follow the references to any
child objects and retrieve their size too, recursing
to any child objects of the child objects, etc.

Can someone suggest a method of doing this?

Well, for one thing you'd need to be very precise about exactly what
you mean. For instance, if you had an object which contained two string
references, would you find out how much memory each of those strings
consumed, and add them up? If so, you'd then get the wrong answer if
they were both references to the same string...
 
Back
Top