Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

maximum sensible size of httpsession and servletcontext  RSS feed

 
Tapio Niemela
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello fellow javaranchers, my simple question is that what would be "maximum" size of httpsession AND servletcontext objects. By "maximum" I mean object size where MemoryOutOfErrors or similar don't take place And before you say it, I know I shouldn't put too many things into session object..

anyhow after some research I found out that in my application in typical case I have httpsession size of 60-100 kilobytes and ServletContext (application) about 450-600 kilobytes. Do you think these values are too high? I'm bit worried they might be..

 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66203
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are not experiencing memory problems, then they're not too big.

Your question cannot really be answered because there are too many variables to take into account, beginning with how much memory is made available to the Java process, how much physical memory the machine has, what other applications are loaded and their memory needs, and a thousand other factors.
 
Mark E Hansen
Ranch Hand
Posts: 650
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:If you are not experiencing memory problems, then they're not too big.

Your question cannot really be answered because there are too many variables to take into account, beginning with how much memory is made available to the Java process, how much physical memory the machine has, what other applications are loaded and their memory needs, and a thousand other factors.

Yes, one additional question I can think of off-hand is how many sessions do you expect to have active at one time. If you will have 500 users at one time, that come out to about 51MB just for the session data. Is that more than your system will allow?

Sometimes it can be easy to just throw everything in the session, but consider cases where it may be better to keep some data in the database, and just place a reference (key) to this in the session. This won't be appropriate for all session data, of course, so you have to decide on a case by case basis.

 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!