Bug 150443 - [performance] Memroy leak - removed nodes/element does not get garbage collected
Summary: [performance] Memroy leak - removed nodes/element does not get garbage collected
Status: CLOSED FIXED
Alias: None
Product: WTP Webservices
Classification: WebTools
Component: wst.ws (show other bugs)
Version: 1.5   Edit
Hardware: PC Windows XP
: P2 major (vote)
Target Milestone: 1.5.1 M151   Edit
Assignee: Jeffrey Liu CLA
QA Contact: Chris Brealey CLA
URL:
Whiteboard:
Keywords: performance
Depends on:
Blocks:
 
Reported: 2006-07-12 16:46 EDT by Jeffrey Liu CLA
Modified: 2006-09-14 15:43 EDT (History)
3 users (show)

See Also:


Attachments
Patch for wst.ws.explorer (2.56 KB, patch)
2006-08-22 12:16 EDT, Jeffrey Liu CLA
no flags Details | Diff
New patch for wst.ws.explorer (2.85 KB, patch)
2006-08-22 12:45 EDT, Jeffrey Liu CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jeffrey Liu CLA 2006-07-12 16:46:11 EDT
Build: 1.5.0

Whenever you remove a node from the WSExplorer's naviagtor view. It is only removed visually, the underlying model hangs around in memory.

To reporduce:

Profile WTP with some profile tool (I used YourKit). Start up the WSExplorer, load a WSDL into the WSDL perspective. Remove the WSDL. Get a memory snapshot, you should see that the WSDL nodes/model are still in memory. For example, here's the GC stack for the WSDLOperationNode

org.eclipse.wst.ws.internal.explorer.platform.wsdl.perspective.WSDLOperationNode 
    [0] of  java.lang.Object[11] 
 
     elementData of  java.util.Vector 
 
      fListeners of  org.eclipse.wst.ws.internal.explorer.platform.wsdl.datamodel.WSDLOperationElement 
 
       value of  java.util.Hashtable$Entry 
 
        [2] of  java.util.Hashtable$Entry[23] 
 
         table of  java.util.Hashtable 
 
          fElements of  org.eclipse.wst.ws.internal.datamodel.BasicModel 
 
           model_ of  org.eclipse.wst.ws.internal.explorer.platform.wsdl.perspective.WSDLPerspective 
 
            currentPerspective_ of  org.eclipse.wst.ws.internal.explorer.platform.perspective.Controller 
 
             value of  java.util.HashMap$Entry 
 
              [7] of  java.util.HashMap$Entry[17] 
 
               table of  java.util.HashMap 
 
                attributes of  org.apache.catalina.session.StandardSession 
 
                 value of  java.util.HashMap$Entry 
 
                  [61] of  java.util.HashMap$Entry[65] 
 
                   table of  java.util.HashMap 
 
                    sessions of  org.apache.catalina.session.StandardManager [Stack Local]
Comment 1 Jeffrey Liu CLA 2006-07-12 16:49:05 EDT
Btw, the impact is pretty significant because this leaks the entire WSDL/XSD model.
Comment 2 Chris Brealey CLA 2006-07-13 08:35:20 EDT
Gil, please investigate. Thanks - CB.

Jeff, I don't have a good feel for how broad the issue is, or how simple a matter it is to remove the referenced models (assuming it has no state that needs to be kept, or other visual artifacts still referring to it). Is this problem specific to certain types of nodes, or to all of them?

Targetted to WTP 1.5.1 for now, but if the problem becomes complex, I'll defer it.
Comment 3 Jeffrey Liu CLA 2006-07-13 10:11:17 EDT
This problem applies to all nodes (UDDI, WSIL, WSDL and Favorites). My guess is the node/model framework that these nodes use is not properly disconnecting the nodes when they were removed. As I recall, when a node is removed, its reference model is no longer needed. Meaning there shouldn't be anything else that refers to it.
Comment 4 Gilbert Andrews CLA 2006-07-26 14:24:20 EDT
Ok Ive looked at this issue but havent made any changes as I wouldnt mind having suggestions about why the thing was designed this way and how we might handle this situation elegantly. 

I looked specifically at the wsdl perspective for starters. I am assuming the other perspectives follow the same pattern. The problem is that the different parts of the model are not related. For instance the WSDL Model has 5 main different parts. The WSDLMainNode, WSDLNode, WSDLServiceNode, WSDLBindingNode, WSDLOperationNode. So you would think that the WSDLServiceNode is the child of WSDLNode. This is not the case. Also you would think WSDLBindingNode is a child of WSDLServiceNode this is not the case. In actual fact they are added directly to the WSDLMainNode.

So when the WSDLNode is cleared from the navigator view it is being cleared properly and is being removed from the model. However since the WSDLServiceNode that was created by this wsdl is not under the WSDLNode it remains in the model along with the other aforementioned nodes. 

Upon deletion I cant just clear out the model as I might be killing services,bindings and operations from other wsdls. So the solution is to other link these up so that when I delete one they all get deleted which the model is designed to do. Unfortunately this is going to be a bigger and riskier change then anticipated. Or we could possibly create a table that keeps track of it which is less of a change but isnt that great looking. I guess there might also be a way to find something that all these nodes have in common like maybe i can grab the internal model object and find out what wsdl it belonged. Not really a fan of that either. 

Comment 5 Jeffrey Liu CLA 2006-07-27 13:08:08 EDT
The proper solution here is to hook up the parent-child relationship properly (instead of having all WSDL nodes hanging off the WSDL Main Node).
Comment 6 Chris Brealey CLA 2006-08-17 15:42:47 EDT
Jeff, thanks for taking this one.
Comment 7 Jeffrey Liu CLA 2006-08-22 12:11:36 EDT
There were 2 problems:

1. Model elements were not being removed from the model
2. Nodes where not being removed from the node manager

I have a fix, I'll submit a patch.
Comment 8 Jeffrey Liu CLA 2006-08-22 12:16:02 EDT
Created attachment 48389 [details]
Patch for wst.ws.explorer
Comment 9 Jeffrey Liu CLA 2006-08-22 12:45:02 EDT
Created attachment 48391 [details]
New patch for wst.ws.explorer
Comment 10 Jeffrey Liu CLA 2006-08-22 13:47:38 EDT
Fix committed into HEAD. Kathy/Peter, can you do the release? Thanks.
Comment 11 Peter Moogk CLA 2006-08-22 16:33:01 EDT
This patch has been released under version v200608222020.
Comment 12 Jeffrey Liu CLA 2006-09-14 15:43:13 EDT
Verified.
Comment 13 Jeffrey Liu CLA 2006-09-14 15:43:23 EDT
close.