• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Relieve database bean objects from heap

 
Skanda Raman
Ranch Hand
Posts: 205
Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 874
Android Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



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
author & internet detective
Marshal
Posts: 34074
337
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Skanda Raman
Ranch Hand
Posts: 205
Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic