Torsten Erler wrote:
You can also try to use WeakHashMap for m_urlMap
Unless I got something wrong with the WeakHashMap semantics
it would be rather pointless to do as proposed.
An entry in a WeakHashMap is reclaimed as soon as the GC
runs after any non-weak reference to the key is released.
For the cache, the key is the href. There are two possiblities:
1. The href string for the key is the unprocessed string taken
from the fo:external-graphics src attribute. This means the
cache entry is kept as long as the FO tree object representing
the fo:external-graphic, i.e. until the end of the page
sequence which contains the fo:external-graphic is reached.
For the typical use case with a page sequence for the bulk of
the document, this is no improvement over the current code at
all.
Note that there is an unconditional href=href.trim() in the code.
I'm not sure whether the original String object is returned if
there is nothing to trim.
2. The href string used for the key is build in FOPImageFactory.Make().
This means the last non-weak reference goes out of scope just after
the routine ends, which in turn means the cache entry may be
reclaimed by the next GC run right after this. This makes it
somewhat pointless to put it into the cache the first place.
The correct approach seems to be to wrap the FOPImage in a
SoftReference, which releases the memory only if the JVM runs
short.
J.Pietschmann
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]