File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes How many objects can be in Session Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "How many objects can be in Session" Watch "How many objects can be in Session" New topic
Author

How many objects can be in Session

Saith Govind
Greenhorn

Joined: Jan 24, 2003
Posts: 13
Is there any limit to the number of objects I keep in Httpsession object. Does putting more number of objects affect the performance of the servlet?
Please help.
Thank you so much..
Pete Harris
Ranch Hand

Joined: Feb 05, 2003
Posts: 39
In a word, no. The HttpSession Attribute list is usually backed by a HashMap and so it can grow unconstrained.
As for performance, the speed of retrieval of objects is constant, but the problem you may run into is the memory usage of the server if you have many sessions.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12682
    
    5
A servlet engine has the option of serializing sessions out to disk if it wants to due to memory getting tight. (Not all servlet engines implement this, I know JRun does.) Thats why all objects you put in a session should implement Serializable.
Naturally recovering a session from disk introduces a delay.
Bill
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How many objects can be in Session
 
Similar Threads
SAXParseException
Pass by Value (Method arguments)
Number of String objects created
GC problem
Number of objects created ?/