This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JDBC and the fly likes Relieve database bean objects from heap Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Relieve database bean objects from heap" Watch "Relieve database bean objects from heap" New topic
Author

Relieve database bean objects from heap

Eshwar Prasad
Ranch Hand

Joined: Mar 21, 2008
Posts: 202
I am getting the user details from database using the following code



Here I am creating the object of UserInfoBean inside the while loop, so that I can set the UserName for every user record coming from database. Actually I have 10589 users in database. So since the bean is getting instantiated inside the loop, does 10589 objects be created on the Heap?

If it is so, how should i garbage collect and relieve these objects from the heap for better performance.

Please let me know.
Balu Sadhasivam
Ranch Hand

Joined: Jan 01, 2009
Posts: 874




Generally speaking, the local objects are garbage collected efficiently by modern days JVM. So there is no point of concern here. But in your case , the local object is being reference again by List object, so there is no point to garbage collect it ? isnt it ?
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30057
    
149

Eshwar,
What are you doing with a list of 10 thousand usernames? The answer to that will help with performance/memory. It is hard to give advice out of context.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Eshwar Prasad
Ranch Hand

Joined: Mar 21, 2008
Posts: 202

The idea of adding data to list is that i can set this as an attribute and get the same in JSP to display records.

Please let me know if doing this way is correct. Will this have any performance/memory problem
 
jQuery in Action, 2nd edition
 
subject: Relieve database bean objects from heap
 
Similar Threads
Getting Problem in Delete operation in Struts application
Closed Statement issue
Displaying a ResultSet Problem
Help with this code!
A Very little problem in h:dataTable implementation