Results 1 to 11 of 11

Thread: Session Size (kb) ?

  1. #1

    Thread Starter
    PowerPoster motil's Avatar
    Join Date
    Apr 2009
    Location
    Tel Aviv, Israel
    Posts
    2,143

    Session Size (kb) ?

    Hi all

    when a user login to my site i'm pulling his preference data and store it as a class object inside a session and then use it as will trough out my application, i would really like to know the size of session in kb to make sure it's not too big,

    when looking in the Trace information all i can see is it's name:

    Code:
    UDetails Logic.BLL.UDetails Logic.BLL.UDetails
    is there a quick way to see the size of the session ?

    i don't believe it's greater then 30 bytes so will I be correct that if theoretically i'll have 1000 users i only be using 300kb of my server resources (for sessions) ?
    * Rate It If you Like it

    __________________________________________________________________________________________

    "Programming is like sex: one mistake and you’re providing support for a lifetime."

    Get last SQL insert ID

  2. #2
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Session Size (kb) ?

    Hey,

    When you say you have looked at the Trace information, can you confirm what you mean?

    Are you talking about trace.axd?

    Gary

  3. #3

    Thread Starter
    PowerPoster motil's Avatar
    Join Date
    Apr 2009
    Location
    Tel Aviv, Israel
    Posts
    2,143

    Re: Session Size (kb) ?

    i just set Trace="true" in the page directive (like i always do) and scroll down to the Session State section
    should i check it with the trace.axd feature? (i didn't used it for a long time now)
    * Rate It If you Like it

    __________________________________________________________________________________________

    "Programming is like sex: one mistake and you’re providing support for a lifetime."

    Get last SQL insert ID

  4. #4
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Session Size (kb) ?

    Hey,

    I seem to remember that accessing the trace.axd page, gave some more information about what is in the session variables, but I could be wrong, it has been a while.

    Gary

  5. #5

    Thread Starter
    PowerPoster motil's Avatar
    Join Date
    Apr 2009
    Location
    Tel Aviv, Israel
    Posts
    2,143

    Re: Session Size (kb) ?

    ok i'll check it out, is there any other way you aware of to check the size of the session?
    * Rate It If you Like it

    __________________________________________________________________________________________

    "Programming is like sex: one mistake and you’re providing support for a lifetime."

    Get last SQL insert ID

  6. #6

  7. #7

    Thread Starter
    PowerPoster motil's Avatar
    Join Date
    Apr 2009
    Location
    Tel Aviv, Israel
    Posts
    2,143

    Re: Session Size (kb) ?

    thanks from quick look it seems exactly what i need.

    i'll update.
    * Rate It If you Like it

    __________________________________________________________________________________________

    "Programming is like sex: one mistake and you’re providing support for a lifetime."

    Get last SQL insert ID

  8. #8
    Hyperactive Member dnanetwork's Avatar
    Join Date
    Oct 2007
    Location
    Mumbai
    Posts
    349

    Re: Session Size (kb) ?

    yo hot gal check this out..

    Code:
    int totalSessionBytes;
    BinaryFormatter b = new BinaryFormatter();
    MemoryStream m;
    for( int i = 0; i < Session.Count; i++)
    {
      m = new MemoryStream();
      b.Serialize(m, Session[i]);
      totalSessionBytes += m.Length;
    }
    Please note that in SessionState collection, items are stored as objects and they will consume as much space as an object type is allowed and the theoretical limit for the maximum size of an object is 2GB. Please check this. But practically it will depend on the available memory resources that your server has got and are available to you. Also maintaining heavy objects in memory is not recommend because its a precious server resource so I would recommend to store these objects in database and make available to your client upon request. ( A trick could be to only store the id of the record in Session)

  9. #9

    Thread Starter
    PowerPoster motil's Avatar
    Join Date
    Apr 2009
    Location
    Tel Aviv, Israel
    Posts
    2,143

    Re: Session Size (kb) ?

    hi dnanetwork, i suppose you took this method from here:
    http://stackoverflow.com/questions/1...eb-application

    i already saw that earlier today but i think you must mark the class (i think i didn't tested it) as serializable to use this method and i don't want to do that.

    thanks for the reply.
    * Rate It If you Like it

    __________________________________________________________________________________________

    "Programming is like sex: one mistake and you’re providing support for a lifetime."

    Get last SQL insert ID

  10. #10
    Hyperactive Member dnanetwork's Avatar
    Join Date
    Oct 2007
    Location
    Mumbai
    Posts
    349

    Re: Session Size (kb) ?

    yes, i gt the link from stackoverflow..but one query..?

    why did u come up with this intresting question..like this...!

    one can have the same question...like how do u measure the size of page's viewstate

    anyways i got one...i kind of think, this guy is speaking correct.

    http://forums.asp.net/t/1143942.aspx

    also do get the GEP and Mendhak's approval on this one...
    Last edited by dnanetwork; May 21st, 2010 at 09:58 AM.

  11. #11
    Frenzied Member avrail's Avatar
    Join Date
    Mar 2006
    Location
    Egypt, Cairo
    Posts
    1,221

    Re: Session Size (kb) ?

    hey,
    motil i think getting the number of bytes of the sessions will not help you, what you will do if you find your session more than what expexted ?

    i recomend gep link
    You Don't Have to Rate Me.
    I'm Not a Civilized Man I'm the Civilization it self
    White or Black, Living or Dieing and 0 or 1 that's MY life
    iam an Object in Object Oriented Life
    my blog : http://refateid.blogspot.com/
    twitter :@avrail
    010011000111010101110110001000000100110101111001001000000101000001100011

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width