Memory usage of Managed Objects

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Adam Parker (AdamParker_at_discussions.microsoft.com)
Date: 01/18/05


Date: Tue, 18 Jan 2005 11:01:02 -0800

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.



Relevant Pages

  • Re: Memory usage of Managed Objects
    ... this is an asp group. ... > get the memory size of these objects. ... > 1) get the size of Managed Objects ... > 3) some other way to get memory sizes of cached objects ...
    (microsoft.public.inetserver.asp.general)
  • Re: Strategy for caches & GC
    ... policy is just a memory leak by another name. ... I end up writing manual allocators for byte arrays. ... heap if these managed objects can be derived from a common base (e.g. ...
    (microsoft.public.dotnet.framework.clr)
  • Memory Size of Managed Objects
    ... Items in the cache are either custom objects or are Hashtables. ... Marshal Managed objects. ... component items in each object and build the total size from their aggrigate ...
    (microsoft.public.dotnet.languages.vb)
  • Re: [RFC PATCH 0/10] split anon and file LRUs
    ... have trouble with today's memory sizes. ... for reclaim then we are already in trouble. ... the split VM patch series by the end of this week. ...
    (Linux-Kernel)
  • Re: Forms memory size on minimize
    ... Will managed objects I have in memory be trimmed? ... I create an empty winform application, ... The working set of an application is trimmed when its top-level window is ...
    (microsoft.public.dotnet.framework.windowsforms)