Originally posted by Neeraj Vij:
Hi Ben,
Please correct me, If I am wrong.I feel, maintaing too many session attributes will degarde the server's performance.
Regards,
Neeraj.
It depends on how your app is being used and what you mean by too many.
If you have a constant amount of heavy traffic or large spikes then having a lot of session references could keep Garbage Collection (GC) from being able to free up memory.
On the other hand caching and reusing objects via sessions can reduce the number of objects created which will lower memory consumption and reduce the number of time GC needs to run,
Let's look at this case:
Your first request hits the the main JSP which queries the database and gets the needed data. You store it in session. The popup window's request pulls the data from session and returns quickly. You've eliminated a trip to the database and all of the object creation invloved with that process.
If GC happens to run before that session has expired then it won't clean up that object (whatever you were storing the table in). It will linger until the next time GC runs. If GC doesn't run during that session's lifespan, storing the object in session cost you nothing. The object is going to stay in memory until GC cleans it up whether it was ever bound to a session or not.
What kind of app is it? Is it something that many people will log into and work with for long periods of time or is it more like an ecommerce site where people login, check for something, buy or not, and leave?