[jira] [Commented] (PIVOT-861) Memory leak: Window icon ImageListenerList retains reference to closed windows, preventing garbage collection
[ https://issues.apache.org/jira/browse/PIVOT-861?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13584181#comment-13584181 ] Sandro Martini commented on PIVOT-861: -- add toString and getLength in ListenerList, to simplify debugging its contents, in Committed revision 1448984. Roger, in a few days I'll redo many tests with many applications, to be sure that the current version is rock-solid, and after thing I think we can mark this issue as resolved. 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 Labels: cache, image, leak, listener, memory 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
[jira] [Commented] (PIVOT-861) Memory leak: Window icon ImageListenerList retains reference to closed windows, preventing garbage collection
[ https://issues.apache.org/jira/browse/PIVOT-861?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13583032#comment-13583032 ] Sandro Martini commented on PIVOT-861: -- ok, I like this new implementation of ListenerList even better (reuse standard collections where possible/makes sense). Today I'll put a toString method there to further simplify debugging. Then we can safely mark this issue as resolved, and see the remaining part (moved) in the other, related issue. 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 Labels: cache, image, leak, listener, memory 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
[jira] [Commented] (PIVOT-861) Memory leak: Window icon ImageListenerList retains reference to closed windows, preventing garbage collection
[ https://issues.apache.org/jira/browse/PIVOT-861?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13583290#comment-13583290 ] Roger Whitcomb commented on PIVOT-861: -- Hi Sandro, Last night while working on a totally unrelated issue in our code, there was thrown a ConcurrentModificationException from ArrayList$Itr from the ComponentKeyListenerList So, this issue isn't totally done yet. I could not reproduce the problem, but I think it was from the Tooltip skin adding itself to the key listener list while we were iterating through calling the keyPressed listeners. If that is the case, it would be a rare event (getting the keyPressed event at just the tooltip delay time) but I need to figure out a way not to have this happen. And I'm not completely sure this was the cause either. 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 Labels: cache, image, leak, listener, memory 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
[jira] [Commented] (PIVOT-861) Memory leak: Window icon ImageListenerList retains reference to closed windows, preventing garbage collection
[ https://issues.apache.org/jira/browse/PIVOT-861?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13582074#comment-13582074 ] Sandro Martini commented on PIVOT-861: -- Hi Roger, great fix (even for the implementation change with Listeners, now they should be better debuggable). Just for curiosity, with my workaround, using Eclipse MAT, weren't you seeing the leak before/after (much lower) ? I think that now I could mark this issue as resolved, and create a new one (linked with this) where to put the new test case (so we can commit the test as is fow and then update later), and see if we can resolve in 2.0.x, or wait for 2.1 for a more general solution (Renderers not to participate in the listener list) ... is it ok for you ? 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
[jira] [Commented] (PIVOT-861) Memory leak: Window icon ImageListenerList retains reference to closed windows, preventing garbage collection
[ https://issues.apache.org/jira/browse/PIVOT-861?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13582077#comment-13582077 ] Sandro Martini commented on PIVOT-861: -- A small update, is sources I found many places where there is something like this: Image iconLocal = (Image)ApplicationContext.getResourceCache().get(iconURL); then, if the resource/image is still null, try to load it in a try/catch block, then put it in cache, like: ApplicationContext.getResourceCache().put(iconURL, iconLocal); but I'd prefer to move the put in cache inside try blocks ... 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
[jira] [Commented] (PIVOT-861) Memory leak: Window icon ImageListenerList retains reference to closed windows, preventing garbage collection
[ https://issues.apache.org/jira/browse/PIVOT-861?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13582320#comment-13582320 ] Roger Whitcomb commented on PIVOT-861: -- Hi Sandro, Noel suggested privately just making ListenerListT use java.lang.ArrayListT as a base, and save even more code. So, I'm thinking about that. Using this code and your workaround #2, I was getting the error a lot, and I guess I didn't see the leak with the btn_grid test, but I didn't think that your workaround was actually getting to the root of the problem (plus getting the error messages). :) I guess I don't mind making a method to do the whole dance of the get from cache, then if not found, load the image and put into cache into a helper method. That seems fine as you suggest. But I don't think it is necessary to put the cache.put inside the try / catch since it doesn't throw any exceptions that would be caught . I will respond to the other part of the problem in PIVOT-894. But, I think I have a solution for that. 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 Labels: cache, image, leak, listener, memory 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
[jira] [Commented] (PIVOT-861) Memory leak: Window icon ImageListenerList retains reference to closed windows, preventing garbage collection
[ https://issues.apache.org/jira/browse/PIVOT-861?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13582449#comment-13582449 ] Roger Whitcomb commented on PIVOT-861: -- Recoded ListenerList again to use java.util.ArrayList as the implementation -- simplifies our code and eliminates what is basically duplicate logic already implemented in the core Java classes. [branches/2.0.x]: Sendingcore\src\org\apache\pivot\util\ListenerList.java Transmitting file data . Committed revision 1448356. [trunk]: Sending. Sendingcore\src\org\apache\pivot\util\ListenerList.java Transmitting file data . Committed revision 1448360. 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 Labels: cache, image, leak, listener, memory 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
[jira] [Commented] (PIVOT-861) Memory leak: Window icon ImageListenerList retains reference to closed windows, preventing garbage collection
[ https://issues.apache.org/jira/browse/PIVOT-861?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13581526#comment-13581526 ] Roger Whitcomb commented on PIVOT-861: -- After debugging through the new fail case, I don't see that clearing the image listener list inside ButtonData is going to help at all. I will change this locally and see if I can come up with a better solution. 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
[jira] [Commented] (PIVOT-861) Memory leak: Window icon ImageListenerList retains reference to closed windows, preventing garbage collection
[ https://issues.apache.org/jira/browse/PIVOT-861?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13581792#comment-13581792 ] Roger Whitcomb commented on PIVOT-861: -- Part of PIVOT-861: Lingering memory leak of ListenerList$Node objects when continuosly creating and destroying windows or buttons (from BXMLSerializer). It seemed like the basic problem was every time you use a ButtonRenderer, there is a call to ImageView.setIcon which takes the old image out of the ImageViewSkin listener list and puts the new one in, ending up creating a huge number of ListenerList$Node objects for every add to these lists. So, I rewrote the whole of ListenerList to use a small array for these lists instead of a real linked list. Empirically the lists don't usually grow very big, so the default size of 5 works well except for a handful of cases, and then the largest seen was 25. The result is that I don't see any long-term memory leak at all in the test applications and the overall memory thrashing seems less because we're creating far fewer of these little Node objects (just to add and remove a reference in a small list). Also reverted the last changes to ButtonData.java and Image.java to take out the earlier workaround that wasn't quite working. Sendingcore\src\org\apache\pivot\util\ListenerList.java Sendingwtk\src\org\apache\pivot\wtk\content\ButtonData.java Sendingwtk\src\org\apache\pivot\wtk\media\Image.java Transmitting file data ... Committed revision 1447977. 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
[jira] [Commented] (PIVOT-861) Memory leak: Window icon ImageListenerList retains reference to closed windows, preventing garbage collection
[ https://issues.apache.org/jira/browse/PIVOT-861?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13581828#comment-13581828 ] Roger Whitcomb commented on PIVOT-861: -- So, after using this new code and debugging through the PivotApp861.java program, there are several things I see here: 1) Each time you load the btn_grid.xml it creates 9 new ButtonDataRenderer objects, each with a new ImageView. 2) So, even though the same image is loaded from the Application's resource cache, there is a new ImageViewSkin that is added to the Image's ListenerList for each button. 3) If I remove the (nine) dataRenderer ... /dataRenderer blocks from the btn_grid.xml file then there is no longer a memory leak. 4) The real problem, then, is two-fold: a) The example is creating ButtonDataRenderer objects that it doesn't need to. b) There needs to be a way for a Renderer not to participate in the listener list for ImageView because it is not necessary (because the image is transient by definition, being set by every call to render). This will need some thought as to how to make ImageView work with transient images. 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
[jira] [Commented] (PIVOT-861) Memory leak: Window icon ImageListenerList retains reference to closed windows, preventing garbage collection
[ https://issues.apache.org/jira/browse/PIVOT-861?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13579640#comment-13579640 ] Roger Whitcomb commented on PIVOT-861: -- I'm now getting these errors periodically (sent to System.err): Nonexistent listener org.apache.pivot.wtk.skin.ImageViewSkin$1@99504b removed from org.apache.pivot.wtk.media.Image$ImageListenerList@1669e7f I'm not sure yet under what circumstances, but it seems this fix isn't quite right yet. 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
[jira] [Commented] (PIVOT-861) Memory leak: Window icon ImageListenerList retains reference to closed windows, preventing garbage collection
[ https://issues.apache.org/jira/browse/PIVOT-861?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13576499#comment-13576499 ] Sandro Martini commented on PIVOT-861: -- Hi, after some tests I confirm that still there is some leak (but luckily without an OutOfMemory) using latest sources, is it the same even for you ? Looking at your test application (I have to see if/how to integrate in ours ...) with eclipse MAT I get this: Class Name | Shallow Heap | Retained Heap org.apache.pivot.wtk.media.Image$ImageListenerList @ 0x27f4a5e0 | 16 |16 |- Java Local java.awt.EventDispatchThread @ 0x27ee0760 switcher-thread Thread| 128 |25.672 |- this$0 org.apache.pivot.util.ListenerList$Node @ 0x2e263c40 | 24 | 9.307.088 |- imageListeners org.apache.pivot.wtk.media.Picture @ 0x27f47868 | 24 |24 | |- image org.apache.pivot.wtk.ImageView @ 0x25188b68 | 200 | 864 | |- icon org.apache.pivot.wtk.content.ButtonData @ 0x2518f490 | 24 |24 | |- icon org.apache.pivot.wtk.content.ButtonData @ 0x25164b68 | 24 |24 | |- icon org.apache.pivot.wtk.content.ButtonData @ 0x25184cd0 | 24 |24 | |- icon org.apache.pivot.wtk.content.ButtonData @ 0x25046130 | 24 |24 | |- icon org.apache.pivot.wtk.content.ButtonData @ 0x24f50b10 | 24 |24 | |- value org.apache.pivot.collections.Dictionary$Pair @ 0x27f517a8 | 16 | 392 | '- Total: 7 entries | | '- Total: 3 entries | | 27.581 instances of org.apache.pivot.util.ListenerList$Node, loaded by sun.misc.Launcher$AppClassLoader @ 0x27ee07e0 occupy 108.498.168 (95,67%) bytes. Biggest instances: •org.apache.pivot.util.ListenerList$Node @ 0x2e263c40 - 9.307.088 (8,21%) bytes. These instances are referenced from one instance of java.awt.EventDispatchThread, loaded by system class loader Then some note: Image (with concrete subclasses Drawing and Picture) doesn't keep inside an attribute URL location, so we could know later from where it come (to match with cached images, etc) ... unless objections we could think to add this info in 2.1 . In your example (called by me PivotApp861) I see this difference: // PivotApp861: note that in the pure Java way, the used constructor of PushButton doesn't use ApplicationContext cache for images ... whick is used calling the setIcon(URL iconURL) ... row.add(new PushButton(new ButtonData(Image.load(new File(clock_icon.png).toURI().toURL()), Clock))); row.add(new PushButton(new ButtonData(Image.load(new File(clock_icon.png).toURI().toURL()), Clock))); row.add(new PushButton(new ButtonData(Image.load(new File(clock_icon.png).toURI().toURL()), Clock))); // TODO: I have to try to make some changes here, to ensure the problem if generated by images cache, or from another place ... Let's update after other tests ... 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
[jira] [Commented] (PIVOT-861) Memory leak: Window icon ImageListenerList retains reference to closed windows, preventing garbage collection
[ https://issues.apache.org/jira/browse/PIVOT-861?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=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 HashMapURI, Object resourceCache = new HashMapURI, 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
[jira] [Commented] (PIVOT-861) Memory leak: Window icon ImageListenerList retains reference to closed windows, preventing garbage collection
[ https://issues.apache.org/jira/browse/PIVOT-861?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13576764#comment-13576764 ] Sandro Martini commented on PIVOT-861: -- Workaround number 2 (simpler and better than number 1): leave resourceCache enabled (without change it, and without add a disable flag), and instead add a clearImageListeners() method in Image, and call it after get an Image instance from resourceCache, for example in the ButtonData.java, so we could have something like this: public void setIcon(URL iconURL) { if (iconURL == null) { throw new IllegalArgumentException(iconURL is null.); } Image iconLocal = (Image)ApplicationContext.getResourceCache().get(iconURL); if (iconLocal == null) { try { iconLocal = Image.load(iconURL); // TODO: move here ... ApplicationContext.getResourceCache().put(iconURL, iconLocal); } catch (TaskExecutionException exception) { throw new IllegalArgumentException(exception); } } else { // TODO: new ... iconLocal.clearImageListeners(); } setIcon(iconLocal); } In this way I get the same final result as workaround number 1, but to me this seems a little better. Then probably this could be applied even to all other similar classes ... Comments ? 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
[jira] [Commented] (PIVOT-861) Memory leak: Window icon ImageListenerList retains reference to closed windows, preventing garbage collection
[ https://issues.apache.org/jira/browse/PIVOT-861?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13552649#comment-13552649 ] Sandro Martini commented on PIVOT-861: -- Hi Łukasz, thanks for the new info. I can try to take a look at this (so if possible we could fix even this in 2.0.3 final), but please could you attach here a small sample so I can see the problem ? This would speedup a lot my tests ... If I remove icon form problematic button memory accumulates in another button or ImageView instance. Excuse me but it's not so clear ... could you post some screenshot ? Is there any fix or workaround for this problem that I can use before new version of pivot will be released? First I'd say you could try to not use icons in buttons, while not use other ImageView is not a good workaround ... so really we have to fix this. Your application run with Java 6 or 7 (where some tricks with Classloaders is now posible, like close) ? 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 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
[jira] [Commented] (PIVOT-861) Memory leak: Window icon ImageListenerList retains reference to closed windows, preventing garbage collection
[ https://issues.apache.org/jira/browse/PIVOT-861?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13553521#comment-13553521 ] Łukasz Hanusiak commented on PIVOT-861: --- I wrote simple application which should make my issue clear. It came to my attention that problem occurs only when I create widgets based on xml. Same widget created in pure java works just fine. I created memory heap dumps for both cases after about 1 minute from application start. Here are dropbox links: BXML sample - http://db.tt/IZjwE9L3 Java sample - http://db.tt/ybvkS5Vd I hope this will help you. Meanwhile I will try research this Classloader idea of yours. Big thanks. 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
[jira] [Commented] (PIVOT-861) Memory leak: Window icon ImageListenerList retains reference to closed windows, preventing garbage collection
[ https://issues.apache.org/jira/browse/PIVOT-861?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13423027#comment-13423027 ] Sandro Martini commented on PIVOT-861: -- Just for reference, some useful articles on eclipse and how to find memory leaks with its Memory Analyzer Tool (MAT): http://www.bonitasoft.org/blog/eclipse/acquire-heap-dump-from-mat/ http://www.bonitasoft.org/blog/eclipse/an-effective-way-to-fight-duplicated-libs-and-version-conflicting-classes-using-memory-analyzer-tool/ Note that FindBugs say nothing during analysis of sources ... 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 Priority: Minor Fix For: 2.0.3 Attachments: leaktest.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: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (PIVOT-861) Memory leak: Window icon ImageListenerList retains reference to closed windows, preventing garbage collection
[ https://issues.apache.org/jira/browse/PIVOT-861?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13423041#comment-13423041 ] Sandro Martini commented on PIVOT-861: -- From analysis with MAT (after a Test Run of Pivot861.java), some info: One instance of org.apache.pivot.wtk.media.Picture loaded by sun.misc.Launcher$AppClassLoader @ 0x27ee08d8 occupies 16.575.496 (75,66%) bytes. The memory is accumulated in one instance of org.apache.pivot.util.ListenerList$Node loaded by sun.misc.Launcher$AppClassLoader @ 0x27ee08d8. Accumulated Objects by Class: org.apache.pivot.util.ListenerList$Node , org.apache.pivot.wtk.skin.ImageViewSkin$1 Retained Heap: org.apache.pivot.wtk.media.Picture (16.575.496) , most of is inside its imageListeners (instance of org.apache.pivot.wtk.media.Image$ImageListenerList) 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 Priority: Minor Fix For: 2.0.3 Attachments: Pivot861.launch, leaktest.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: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (PIVOT-861) Memory leak: Window icon ImageListenerList retains reference to closed windows, preventing garbage collection
[ https://issues.apache.org/jira/browse/PIVOT-861?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13423269#comment-13423269 ] Sandro Martini commented on PIVOT-861: -- Just committed the fix for the second, smaller leak: Committed revision 1366096. Note that other (much smaller) memory leaks still seems to happen, but we can see them later if needed (some seems too much complex to track). To have an idea, after approx. 10.000 dialog open/close tests with Pivot861, now the memory still use near 40 / 45 MB (using the latest JRE 6 under Windows 32) , you can see this even from Task Manager, or for example VisualVM. David, thank you again very much for your help here. 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: Pivot861.launch, leaktest.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: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (PIVOT-861) Memory leak: Window icon ImageListenerList retains reference to closed windows, preventing garbage collection
[ https://issues.apache.org/jira/browse/PIVOT-861?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13422238#comment-13422238 ] Sandro Martini commented on PIVOT-861: -- Hi David, thank you very much, I'll try asap and say something. 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 Priority: Minor Fix For: 2.0.3 Attachments: leaktest.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: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (PIVOT-861) Memory leak: Window icon ImageListenerList retains reference to closed windows, preventing garbage collection
[ https://issues.apache.org/jira/browse/PIVOT-861?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13414995#comment-13414995 ] Sandro Martini commented on PIVOT-861: -- Hi David, thanks for the test case and for the info here (and sorry for the delay) ... I'll look at this in next days, and post some update. Thank you again for now. 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 Priority: Minor Fix For: 2.0.3 Attachments: leaktest.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: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira