Some additional thoughts before going to bed:

- I think the static synchronized WeakHashMap should be avoided. There's
a lot of synchronization that is performed. I suspect this will have a
bad effect on performance. It may make more sense to have a
FlyWeightFactory (per object) per rendering run. Somebody (don't
remember who, sorry) wrote that FOP cannot bring the CPU to 100%,
probably due to synchronization issues. Could be worth investigating
since this would mean we give away CPU cicles here.
- It's probably not the most effective way to use the Property itself as
the key into the Map, i.e. creating throw-away instances excessively.
Working with specialized FlyWeightFactories could be more efficient. See
http://en.wikipedia.org/wiki/Flyweight_pattern
- One of the easiest candidates for another flyweight is probably
CommonHyphenation (56K instances, 2.3MB in my example). The few member
variables could probably just be concatenated to a String (to be used as
the key).
- It could be worth looking into the difference between HashMap and
TreeMap. Maybe one is more suitable than the other. I haven't looked at
the difference, yet.

Jeremias Maerki

Reply via email to