On Jul 20, 2007, at 16:51, Jeremias Maerki wrote:

Want to find a memory leak? SAP's memory analyzer is great again to find
out all paths to GC roots:

<snip />
As a simplification here, let's assume "cache" (PropertyCache in static variable) is our GC root. Hard references are to "propCache", then "m" and "table". From there it goes to the WeakHashMap$Entry in the array with a
hard reference. From the Entry, you have a hard reference (!) to the
FixedLength instance through "value" and a weak reference through
"referent" (which you can find in java.lang.ref.Reference). QED.

Yep, I see the point. QED indeed.

If this were my current focus, I'd remove PropertyCache in favor of
specialized and optimized FlyWeightFactories and I'd attach those to the
rendering run so I can get rid of the need for thread synchronization
and weak references. I'd do some isolated timing experiments comparing
PropertyCache and the FlyWeightFactories. But since this has to wait
until later this year, I guess I'm happy enough if you guys trying out
Adrian's suggestion in order to get a quick solution.

Adrian's suggestion should be enough FTM, to guarantee that even in exotic cases with a huge amount of distinct property values in long series of subsequent and concurrent runs, there are no leaks. I just tried it out, and now, after finishing a run only the mentioned initial values referenced by the Makers, are retained in the Map. The specified values particular to the run are now correctly released after the run has finished.


Cheers

Andreas

Reply via email to