Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Relieve database bean objects from heap

 
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.
 
Ranch Hand
Posts: 874
Android VI Editor Java
  • 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 ?
 
author & internet detective
Posts: 40035
809
Eclipse IDE VI Editor Java
  • 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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic