Memory usage of Managed Objects

A

Adam Parker

I am in the process of writing a simple web server monitor (ASP.Net with
VB.Net). One piece of useful information for me to gather would be the
amount of memory used by objects stored in the cache, since objects are
thrown in there left and right.

Items in the cache are either custom objects or are Hashtables. How can I
get the memory size of these objects.

Marshal.SizeOf(object) does not work in this case because .Net cannot
Marshal Managed objects. I thought that I might be able to pull out the
component items in each object and build the total size from their aggregate
sizes, however that would require me to determine each objects type so that I
can correctly gather size info from the internal attributes, something that I
do not want to do.

Is there a generic way to either:
1) get the size of Managed Objects
2) convert Managed Objects into Unmanaged Objects that can be marshaled?
OR
3) some other way to get memory sizes of cached objects

I appreciate the help.
 

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

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top