2

After reading the How do servlets work? Instantiation, sessions, shared variables and multithreading thread, I was wondering if the sessions stored in the JVM are erased, in a application with no time limit for user session (<session-timeout>-1</session-timeout>)? If so, is it by GC?

Thanks!

Community
  • 1
  • 1
Ciso
  • 23
  • 4

2 Answers2

0

It depends on the container, but the sessions have little to do with GC. For example, tomcat keeps active sessions in memory and saves them to disk. Swapping the active sessions in memory out with inactive (or idle) sessions as needed. This way the sessions survive even when the server is restarted.

Check this out for more info: http://tomcat.apache.org/tomcat-6.0-doc/config/manager.html#Introduction

CaptRespect
  • 1,985
  • 1
  • 16
  • 24
  • What about those sessions that are stored in disk and never used again? Are they kept indefinitely? – Ciso Feb 12 '14 at 15:45
  • Yes. You can manually expire them using the manager app based on how long they've been idle, in tomcat anyway. – CaptRespect Feb 12 '14 at 21:52
0

See information here: session-config

Default value: -2

Maximum value: Integer.MAX_VALUE ÷ 60

Special values:

-2 = Use the value set by TimeoutSecs in element of weblogic.xml

-1 = Sessions do not timeout. The value set in element of weblogic.xml is ignored.

rand0m86
  • 3,172
  • 4
  • 26
  • 29