Bug 398599 - Memory leaks in ComponentImplManager class
Summary: Memory leaks in ComponentImplManager class
Status: RESOLVED FIXED
Alias: None
Product: WTP Common Tools
Classification: WebTools
Component: wst.common (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 3.6 M6   Edit
Assignee: Carl Anderson CLA
QA Contact: Carl Anderson CLA
URL:
Whiteboard:
Keywords: performance
Depends on:
Blocks:
 
Reported: 2013-01-20 17:40 EST by Snjezana Peco CLA
Modified: 2014-02-07 11:23 EST (History)
0 users

See Also:


Attachments
A patch (2.32 KB, patch)
2013-01-20 17:46 EST, Snjezana Peco CLA
ccc: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Snjezana Peco CLA 2013-01-20 17:40:53 EST
Steps to reproduce:
The issue can always be reproduced when rebuilding a Java EE Web project from JBoss Tools (http://jboss.org/tools).
I suppose it could also be reproduced in some other web dynamic project that includes more builders/validators.

Problem 1

The ComponentImplManager.createComponent() method caches a component using the ComponentCacheManager class.
The actions in the ComponentCacheManager class are synchronized, but the createComponent method isn't.

What can happen is the following:

- some thread calls the createComponent method that requires a component that is not in the cache
ComponentImplManager.java, line 208

IVirtualComponent component = ComponentCacheManager.instance().getComponent(project);

- a new component will be created and added to the cache using the following code:
ComponentImplManager.java, line 217

ComponentCacheManager.instance().setComponent(project, component);

- if some other thread calls the createComponent method between lines 208 and 217, it also won't find a component in the cache. As a result, two threads will create the same component. One of them will be leaked.

Problem 2

When the org.eclipse.wst.common.componentcore.internal.util.ComponentImplManager.ComponentCacheManager.getComponent() method removes components from componentsMap, it doesn't dispose the components of the VirtualComponent type. An object of the VirtualComponent.ResourceAdapter type is leaked.

Attached is a patch.
Comment 1 Snjezana Peco CLA 2013-01-20 17:46:40 EST
Created attachment 225871 [details]
A patch
Comment 2 Carl Anderson CLA 2014-02-07 11:22:55 EST
The patch did not apply cleanly to the file, so I redid the changes by hand.

Committed to master for WTP 3.6 M6