How does garbage collection work with a Session object in Java?

How does garbage collection work with a Session object in the JSP? Does every garbage collection session get after the session ends? What is the best way to handle memory using Session objects in JSP?

+3
source share
2 answers

The garbage collector will only collect objects that no longer contain any hard links in the code. Objects HttpSessionreference the servletcontainer internal code. When the session expires, the internal servletcontainer code will dereference it, and the GC will sweep it when that time.

You do not need to worry about it. This is already done for you.


/ , - -. , , .

+7

reset , . , .

, , , .

0

All Articles