Look on CACHES field. /** * Maps ResourceContext caches to their associated TypeOracles. This is a weak * map and will not prevent TypeOracles from being gc'ed. */ private static final Map<TypeOracle, Map<String, Object>> CACHES = new WeakHashMap<TypeOracle, Map<String, Object>>();
Unfortunately I see in profiler that it _does_ prevent TypeOracle from being gc'ed. Look on screen shot from profiler. http://dl.dropbox.com/u/76691/images/2010/Screenshot_20100802_185831.png As you can see, there is ImageResourceDeclaration has strong reference on JMethod, it has reference on JRealClassType, which also has strong reference on TypeOracle. So, there is strong reference on TypeOracle from weak map value. As stated in WeakHashMap documentation this prevents entry from being gc'ed. See "Implementation note:" comment. "The value objects in a <tt>WeakHashMap</tt> are held by ordinary strong references. Thus care should be taken to ensure that value objects do not strongly refer to their own keys, either directly or indirectly, since that will prevent the keys from being discarded." I'm not sure what to do here. We probably can not use WeakReference on value, as recommended in WeakHashMap documentation, because there are no other link on cache. May be use WeakReference for "method" in ImageResourceDeclaration? -- http://groups.google.com/group/Google-Web-Toolkit-Contributors