• Post Reply Bookmark Topic Watch Topic
  • New Topic

Newbie question: dereference objects  RSS feed

 
Ray Yung
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

If my action generates a collection of Java objects, and this collection is
attached to the pageContext and forwards to a jsp page, do I need
to worry about to dereference this collection when the page goes out
of scope?

On the same token, if this collection is attached to the session, do I
need to worry about deferencing the objects when session times out?

If I set the collection to the session using:
session.setAttribute("mylist", mycollection);

does subsequent call
session.setAttribute("mylist", myothercollection);
will automatically deference all the existing objects in mycollection?

I am running into some memory leaks and I need some clarification
on how to get rid of this problem. Appreciate any explanation on this
issue.

Thanks,
Ray
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 36446
454
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ray,
Welcome to JavaRanch!

Yes, the objects are not referenced anymore in both of those scenarios (assuming you don't have references to them elsewhere.) You could see what appears to be a memory leak if garbage collection has not run yet.

Also, keep in mind that the default session timeout is 30 minutes. So if you have a lot of sessions at once, they can tie up a lot of memory.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!