This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Session size...  RSS feed

 
ankur rathi
Ranch Hand
Posts: 3830
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the maximum size of session that is acceptable for *real* project or recommended??

How can we get the session size??
What we are doing is, we are writing session data into file and then just guessing the size... Could any body tell me the better way..

Thanks a lot.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This question has been asked quite a few times so you should be able to find a lot of discussion by using the search feature.

In short, a session is nothing more than a map full of references to objects living on the heap. It's not a container and it doesn't really have a size.

Since multiple sessions can point to the same object the actual memory footprint from a running app can be very different to the size of a serialized object.
 
ankur rathi
Ranch Hand
Posts: 3830
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ban for clear explanation,

But having one doubt, session is nothing but a map and having references and actual objects are present in heap as usual. It means whatever session size is, it is the size of references that it holds.



In this example, I am writing session into file and its size is around 158 byte. It means it is the size of 2 references, one is refering to "a" and other one is refering to "AObject". And if we remove comment from line 1,2 and 3 and then execute this program then file size changes to 186 byte. This time session has 8 references. Logically the size should be 158*4. Why it is not 158*4?

Please comments...

Thanks a lot.
 
Dan Novik
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Session admin from JSOS shows you the size for sessions. See
http://www.servletsuite.com/servlets.htm

There is a tag in Coldtags suite that lets you calculate the size
in JSP. See Session size tag here:
http://www.servletsuite.com/jsp.htm

And yes, if you are sharing object between your sessions than the calculated size will be bigger than the real value
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by rathi ji:
Thanks Ban for clear explanation,


BTW, why are you Banning our Ben?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!