[
https://issues.apache.org/jira/browse/PIVOT-861?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13576707#comment-13576707
]
Sandro Martini commented on PIVOT-861:
--------------------------------------
Ok, after other tests I have more info: it's really something related to the
resourceCache, in ApplicationContext.java:
private static HashMap<URI, Object> resourceCache = new HashMap<URI,
Object>();
private static ResourceCacheDictionary resourceCacheDictionary = new
ResourceCacheDictionary();
for 2.1 we could think to add some injection way to let users set a different
kind of resourceCache,
backed by something like a WeakHashMap (using WeakReferences) ... but in Pivot
currently we haven't a collection like this, and now it's static, etc, so for
now I propose the following workaround:
add a flag to disable ApplicationContext resourceCache,
but implementing it directly in methods of ResourceCacheDictionary for a
cleaner/backwards compatible approach ... I have to verify but should be
possible.
In this way I get a result like when running your pure Java version:
Biggest Objects By Retained Size: sun.awt.image.BufImgVolatileSurfaceManager @
0x28364e98 , Shallow Size: 40 B Retained Size: 4 MB
Some info:
http://stackoverflow.com/a/6639894 , http://stackoverflow.com/a/4948789 ,
http://weblogs.java.net/blog/2006/05/04/understanding-weak-references
Probably a long-term solution requires more changes in many classes (even
incompatible ones), so I think that for now the proposed solution should be
enough. Tell me what you think.
> Memory leak: Window icon ImageListenerList retains reference to closed
> windows, preventing garbage collection
> -------------------------------------------------------------------------------------------------------------
>
> Key: PIVOT-861
> URL: https://issues.apache.org/jira/browse/PIVOT-861
> Project: Pivot
> Issue Type: Bug
> Components: wtk, wtk-media
> Affects Versions: 2.0.2
> Environment: Windows XP, Java 1.7.0_05
> Reporter: David Keen
> Assignee: Sandro Martini
> Fix For: 2.0.3
>
> Attachments: leaktest.zip, Pivot861.launch, PivotSample.zip
>
>
> When a window or dialog is opened which has an icon, after it is closed it
> cannot be garbage collected because a reference is retained to it through the
> icon. Removing the icon resolves the issue.
> As far as I've investigated, the issue appears to the in the
> ImageListenerList which each Image contains. I've done a heapdump of my
> application and used the IBM HeapAnalyzer which shows this list containing a
> reference to the window/dialog through the ImageViewSkin, but I don't know
> the Pivot internals well enough to see where or how it should be released.
> I'll attach a simple test application to show the issue.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira