This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 191040 - Memory leak in ProjectWebServiceView
Summary: Memory leak in ProjectWebServiceView
Status: RESOLVED FIXED
Alias: None
Product: webservices
Classification: Unclassified
Component: Code (show other bugs)
Version: 7.0
Hardware: PC Linux
: P2 normal (vote)
Assignee: Denis Anisimov
URL:
Keywords: PERFORMANCE
Depends on:
Blocks:
 
Reported: 2010-10-15 19:31 UTC by Jesse Glick
Modified: 2010-10-25 09:24 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jesse Glick 2010-10-15 19:31:13 UTC
I observed a memory leak of several open projects, and the heap dump pointed me to ProjectWebServiceView as the culprit in a couple of cases.

ProjectWebServiceView.views is a WeakHashMap<Project,ProjectWebServiceView> and thus effective only so long as the ProjectWebServiceView and thus the ProjectWebServiceViewImpl's hold no strong reference to the Project. Indeed AbstractProjectWebServiceViewImpl attempts to enforce this. But ProjectJaxWsWebServiceView holds a strong reference to a JaxWsModelImpl, which holds a strong reference to a Project. Therefore neither the ProjectWebServiceView nor its Project can ever be collected.

Probably safer for views to be a WeakHashMap<Project,WeakReference<ProjectWebServiceView>> and stipulate that the ProjectWebServiceView must hold only recoverable state. It's not even obvious that the views need to be cached at all; ProjectWebServiceNodeFactory would better just create a new view from scratch when requested, without any attempt at a static cache.
Comment 1 Denis Anisimov 2010-10-19 12:01:15 UTC
I agree with absence of necessity to cash views at all.
There could be only to web services nodes per project : root web services node which aggregates all available web services and root references node which 
aggregates all available references to web services.
Currently ProjectJaxWsWebServiceView handles both types of such nodes:
services and clients: existed code uses the same view for both root nodes.
But project couldn't have more than two such views for each type of node.
So there is no really need to cache view references .
Avoidance to cache will clarify of ProjectJaxWsWebServiceView usage also.
So I'm going to remove cache and rewrite ProjectJaxWsWebServiceView 
(it should depend on view type ).
Comment 2 Denis Anisimov 2010-10-19 12:46:56 UTC
Actually the situation is even more simple.
Both types of web service nodes ( clients and services ) are created via 
ProjectWebServiceNodeFactory . This nodes are created via WsNodeList instance
which has 1:1 relation to project.
The latter class instance keeps reference to ProjectWebServiceView which is 
used for both ws root nodes : services and clients.
So there is absolutely no need to cache views per project.
As result there is 1:1 between view and project and no need to know view for
other project. So view will be instantiated only when it will be requested.

changeset:   179935:fa33ff9e4a77
user:        Denis Anisimov <ads@netbeans.org>
date:        Tue Oct 19 16:45:04 2010 +0400
summary:     Fix for BZ#191040 -  Memory leak in ProjectWebServiceView
Comment 3 Quality Engineering 2010-10-25 09:24:05 UTC
Integrated into 'main-golden', will be available in build *201010210000* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/210d16078964
User: Denis Anisimov <ads@netbeans.org>
Log: Fix for BZ#191040 -  Memory leak in ProjectWebServiceView