[ 
https://issues.apache.org/jira/browse/PIVOT-861?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=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 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

Reply via email to