Skip to main content

skip to main content

developerWorks  >  Java technology  >

Gems from e-BIT: Better object management

developerWorks
Document options

Document options requiring JavaScript are not displayed


Rate this page

Help us improve this content


Level: Introductory

Mark Bluemel (dwinfo@us.ibm.com), Software engineer, IBM Hursley Lab

01 Jan 2002

Heap exhaustion and excessive garbage collection are often the result of poor object management. Here are a few tips to ensure you're not falling into this trap.
  • Remember that objects are held in the heap as long as they are "reachable" (loosely speaking) -- if an in-use object has a reference to an out-of-use object, the out-of-use object cannot be garbage collected and will waste space. Vectors, HashTables, linked lists, and similar data structures can often be misused such that they hold references beyond an appropriate time for their release. Profiling tools can be helpful in identifying this sort of problem.

  • Garbage collection is not free; other processing will be paused. Try to reuse objects in preference to discarding and re-creating them when possible. Object pool mechanisms can be helpful in this respect.



About the author

Mark Bluemel is a software engineer at the IBM Hursley Lab.




Rate this page


Please take a moment to complete this form to help us better serve you.



YesNoDon't know
 


 


12345
Not
useful
Extremely
useful
 


Back to top