|  | 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
|  |
|