aspose file tools
The moose likes Beginning Java and the fly likes Garbage collection of domain objects Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Software Craftsman this week in the Agile forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Garbage collection of domain objects" Watch "Garbage collection of domain objects" New topic

Garbage collection of domain objects

Sidharth Pallai
Ranch Hand

Joined: Apr 21, 2008
Posts: 134


I would like to know , how would we GC the domain objects / value objects that are retrived from the database to be displayed in JSP. How/when we can make sure that those objects , after they are done with the display will be GC'd.

The domain objects are large in number that are retreived from the database. Say for example , 1000 Person objects or 1000 rows of Person data. or 1000 Persons.

Thanks & Regards
Sidharth Pallai
Stephan van Hulst

Joined: Sep 20, 2010
Posts: 3680

Make sure there are no more references to them. Usually, when you don't need them anymore, local references to them go out of scope an they are collected without any more work on your part. However, you have to be careful if you save references to them in some sort of list field, or have static references to them. In these cases, you will have to make sure you delete them from the list, or null out the reference.
Sidharth Pallai
Ranch Hand

Joined: Apr 21, 2008
Posts: 134

Hi Stephen,

Thanks for the explanation.i would like to how could i decide if the objects are no longer needed or they need to be retrieved from the database again.I mean when could i decide that i dont need them anymore and how , once they are presented to the user in listing table of HTML. Or when i could take the decision to save the references.

Take for example , once i've the List of <Person> from the database, i set it to request attribute for display in the listing JSP. So, once the request forwards the list to the JSP and the JSP draws all the listing elements. So once i set it to request attribute, is that the next line i would do something like this ...

wood burning stoves
subject: Garbage collection of domain objects