I've observed OOM from javac, where a half of the heap was held by com.sun.tools.javac.code.DeferredCompletionFailureHandler instances. DeferredCompletionFailureHandler$Handler has WeakHashMap<ClassSymbol, FlipSymbolDescription> class2Flip field, where FlipSymbolDescription has a strong reference to ClassSymbol, which is always the same as a key. j.u.WHM guarantees that keys are weakly referenced, but doesn't give any guarantees on how values are referenced, in fact, there is an implementation note which states that values are held by strong references.
|