ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button
Article:
  10 Reasons We Need Java 3.0
Subject:   Reimplement WeakHashMap and "ObjectPool" in VM kernel
Date:   2002-08-06 14:11:04
From:   bezdar
1) sadly current WeakHashMap implementation is quite broken:


- the 'orphant' value becomes reclaimable by the garbage collector only when put(), remove(), or clear() is called
- even if such method is called this does not guarantee that the 'orphant' are reclaimed in the current java kits (both Sun and IBM - my tests show that)


This surely may be corrected if core VM and threading are refactored and WeakHashMap implemenataion is build into the VM - IMO its worth the trouble


2) Maybe I'm over-crazy about performance, but I like very much to keeping pooled objects ready for use (the alternative is to drop object as soon you no longer need it and new() a new one when you're in need of a similar one).


But of course I want such pool to get automatically freed if the VM runs low on memory.


Unfortunatly all the pools that I could imagine built with WeakReference-s in programmers (not VM) space were not perfect.


If the ObjectPool implementation will be built into the VM it may even have the propery of intellectual memory control - as soon as VM runs low on memory the objects among those kept only via WeakReference-s, WeakHashMap-s and ObjectPool-s that haven't been used for the longest time would get cleaned.


It would be even better to consider memery used but this sounds somewhat tricky due to possible interobject dependencies..