开发者

Should values kept in Tomcat Session be set to null when session is being destroyed?

Should values kept in Tomcat Session be set to null when session is being destroyed? Or they are automatically destroyed?

We had a problem with multiple .ser files in tomcat folder. Could that be because we do not set values kept in session to nul开发者_开发技巧l after using them ?


Should values kept in Tomcat Session be set to null when session is being destroyed? Or they are automatically destroyed?

When a session get invalidated, its attributes will just be dereferenced. When they aren't referenced by any other object, then they will be eligible for GC. Once GC runs, then they will be destroyed, yes.

We had a problem with multiple .ser files in tomcat folder. Could that be because we do not set values kept in session to null after using them ?

No. This sounds like as if Tomcat crashed during startup or shutdown. I'd read the logs.


When session is destroyed, any contained objects in the session are also destroyed (i.e. garbage collected if the session is the only one holding on to them). You don't have to set them to null after use.

Tomcat has a feature of serializing sessions on shutdown and trying to re-activate them on start up, called restart persistance. Are you referring to this? If it causes problems for you, it can be deactivated (see the attributes of the standard manager implementation in the same document).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜