I had a discussion with my friend regarding the how much value can be put into the httpsession. He told me that the max can be 8000 bytes of data can be stored into the session.
Is it true? If not how much data can we store in a session. Also I want to know for an application how many sessions can be there concurrently. I have read somewhere that it is 4096 sessions. Is is true or is it specific to servers?
He told me that the max can be 8000 bytes of data can be stored into the session.
Seems to me that that would be a fairly easy supposition to test.
I've never seen anything in the spec about limiting the number of sessions but that's not to say it couldn't be a feature of a specific server implementation.
Originally posted by vjy chin:
Thanks for all ur replies. But still if you can tell me how to find it exactly, it would be of great help.
My point is that the "size of a session" is a vauge concept. In order to know the size of one, you would need to measure the footprint of every object that is referenced by it and all the objects referenced by them and so on and so on. To complicate this further multiple sessions can all reference the same object. This would mean that the total footprint of the app is less than the sum of it's sessions.
You'll get a more accurate idea of your requirements by doing as you've said: Use a profiler to measure the total memory consumption and make comparisons as sessions are added.
Certain tools are available for knowing memory usage of objects.
Using this tool you can know the how much a session can hold.
Please let me know how to get the current size of the session.
We have a major ongoing misconception here caused (I suspect) by sloppy use of terms.
1. You do NOT "put an object in a session" you put a reference to an object in a session.
2. The "size" of the session object in memory is that of any other Map style collection - each entry adds a reference (pointer) to a key String and a reference (pointer) to an object - and that is all.
3. The size of these referenced objects only matters if the servlet container decides to serialize the session. Something not under the direct control of the programmer.
If you are worried about memory use by your servlet, put in some monitoring and reporting functions.