AAShapePipe concurrency & memory waste (original) (raw)

Laurent Bourgès bourges.laurent at gmail.com
Fri Apr 5 12:20:20 UTC 2013


Dear java2d members,

I figured out some troubles in java2d.pipe.AAShapePipe related to both concurrency & memory usage:

Here are profiling screenshots:

Here is the proposed patch: http://jmmc.fr/~bourgesl/share/AAShapePipe/webrev-1/

I applied a simple solution = use a ThreadLocal or ConcurrentLinkedQueue (see useThreadLocal flag) to cache one AAShapePipeContext per thread (2K max). As its memory footprint is very small, I recommend using ThreadLocal.

Is it necessary to use Soft/Weak reference to avoid excessive memory usage for such cache ?

Is there any class dedicated to such cache (ThreadLocal with cache eviction or ConcurrentLinkedQueue using WeakReference ?) ? I think it could be very useful at the JDK level to have such feature (ie a generic "GC friendly"cache )

Regards, Laurent



More information about the core-libs-dev mailing list