how to measure memory consumption

Discussion in 'ASP .Net' started by Tom L, Apr 13, 2004.

  1. Tom L

    Tom L Guest

    How can I tell how much memory is being user for each user session?
    Tom L, Apr 13, 2004
    #1
    1. Advertising

  2. Tom L

    Tom L Guest

    How can I tell how much memory is being USED for each user session? :)
    thanks!

    > How can I tell how much memory is being user for each user session?
    >
    Tom L, Apr 13, 2004
    #2
    1. Advertising

  3. Tom L

    bruce barker Guest

    there is no sure way, this will give an estimate:


    double size = 0;
    foreach (object obj in this.Session)
    {
    size += Convert.ToDouble(ObjectSizer.GetSize(obj));
    }
    Response.Write(string.Format("Session size: {0} KB",size / 1000));

    class ObjectSizer
    {
    public static long GetSize(object obj)
    {
    MemoryStream m = new MemoryStream();
    BinaryFormatter b = new BinaryFormatter();
    try
    {
    b.Serialize(m, obj);
    return m.Length;
    }
    finally
    {
    m.Close();
    }
    }
    }


    -- bruce (sqlwork.com)


    "Tom L" <tlanger_n05p4m_dls.net> wrote in message
    news:...
    >
    > How can I tell how much memory is being USED for each user session? :)
    > thanks!
    >
    > > How can I tell how much memory is being user for each user session?
    > >

    >
    >
    >
    bruce barker, Apr 14, 2004
    #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. Duccio
    Replies:
    0
    Views:
    518
    Duccio
    Feb 25, 2006
  2. Kiran Kumar

    aspnet_wp.exe memory consumption

    Kiran Kumar, Jul 15, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    451
    Natty Gur
    Jul 15, 2003
  3. Ervin

    Urgent! GDI+ Memory consumption

    Ervin, Sep 15, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    611
    Ervin
    Sep 15, 2003
  4. tony_wang
    Replies:
    1
    Views:
    4,074
    Saravana [MVP]
    Nov 21, 2003
  5. Sam Holden
    Replies:
    0
    Views:
    457
    Sam Holden
    Aug 22, 2003
Loading...

Share This Page