Memory usage of Managed Objects

Discussion in 'ASP General' started by Adam Parker, Jan 18, 2005.

  1. Adam Parker

    Adam Parker Guest

    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.
     
    Adam Parker, Jan 18, 2005
    #1
    1. Advertising

  2. Adam Parker

    thorpe Guest

    this is an asp group. i suggest maybe looking for a group with .net in the
    name.

    "Adam Parker" <> wrote in message
    news:...
    >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.
     
    thorpe, Jan 18, 2005
    #2
    1. Advertising

  3. thorpe wrote:
    > this is an asp group. i suggest maybe looking for a group with .net
    > in the name.
    >

    Actually, the name needs to contain "dotnet".
    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.
     
    Bob Barrows [MVP], Jan 18, 2005
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. metfan
    Replies:
    2
    Views:
    4,853
    Robert Olofsson
    Oct 21, 2003
  2. CeZaR
    Replies:
    7
    Views:
    700
    Nemanja Trifunovic
    Aug 20, 2004
  3. hvt
    Replies:
    0
    Views:
    1,215
  4. hvt
    Replies:
    0
    Views:
    1,477
  5. Krist
    Replies:
    8
    Views:
    6,494
    Arne Vajhøj
    Feb 10, 2010
Loading...

Share This Page