-
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) ?
-
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
-
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)
-
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
-
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?
-
Re: Session Size (kb) ?
-
Re: Session Size (kb) ?
thanks from quick look it seems exactly what i need.
i'll update.
-
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)
-
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.
-
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...
-
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