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 242567 - IDE keeps all Maven projects in memory indefinitely causing a memory leak
Summary: IDE keeps all Maven projects in memory indefinitely causing a memory leak
Status: NEW
Alias: None
Product: platform
Classification: Unclassified
Component: Filesystems (show other bugs)
Version: 8.0
Hardware: PC Mac OS X
: P2 normal with 2 votes (vote)
Assignee: Jaroslav Havlin
URL:
Keywords: 8.0_WAIVER_APPROVED, 8.1_WAIVER_APPROVED, PERFORMANCE
Depends on:
Blocks:
 
Reported: 2014-03-05 08:29 UTC by Milos Kleint
Modified: 2016-08-18 08:44 UTC (History)
8 users (show)

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 Milos Kleint 2014-03-05 08:29:49 UTC
steps to reproduce:

1. open a bunch of maven projects, after scanning finishes, close them again.
2. create a basic ant j2se project (to clean up any context residue)
3. click GC a few times
4. create a heap dump. 

In the heap dump, look for NbMavenProjectImpl (the project implementation for maven projects), all of them are still referenced. See screenshot for the nearest GC root found in all instances.

http://screencast.com/t/u79FO8Hh

adding tzezula on CC - according to him it's not clear why the DeepListener is held.

P1 as the leak is fairly big (projects have a lot of other objects associated with them). I haven't tested non maven projects but I assume the problem is not project specific

heap dump: https://s3-eu-west-1.amazonaws.com/mkleint-parachute-test/heapdump-1394006171934.hprof.gz



Product Version: NetBeans IDE Dev (Build 20140303-876539d8b52d)
Java: 1.7.0_40; Java HotSpot(TM) 64-Bit Server VM 24.0-b56
Runtime: Java(TM) SE Runtime Environment 1.7.0_40-b43
System: Mac OS X version 10.8.5 running on x86_64; UTF-8; en_US (nb)
User directory: /Users/mkleint/src/core-main-backup/nbbuild/testuserdir
Cache directory: /Users/mkleint/src/core-main-backup/nbbuild/testuserdir/var/cache
Comment 1 Marian Mirilovic 2014-03-05 09:56:03 UTC
Tomas/Jirka, 
could you please investigate how big impact it has on the memory, also check other project types ... thanks in advance. based on your findings we will decide to fix/reject this for 8.0.
Comment 2 Tomas Hurka 2014-03-05 13:17:48 UTC
We did some testing with Jirka and similar problem exists in NB 7.4 too. In the heap dump from NB 8.0 we saw two different paths to GC root holding maven projects, none of them are similar to the one reported by Milos. There is a similar test for j2se projects and unfortunately during NB 8.0 development cycle, we were not able to fix all the project oriented leaks so this test never passed. I think, if someone has the easy fix than we can put it in, but I am afraid that there is several problems on different levels and it cannot be fixed easily.
Comment 3 Jaroslav Havlin 2014-06-13 10:44:24 UTC
If I understand correctly, a recursive listener is registered by RepositoryUpdater.RootListeners when a source root is added, and unregistered when a source root is removed.
There are 25 listeners in DeepListener.keep list, and there are 23 items in RepositoryUpdater.RootListeners.sourceRoots, corresponding to the listeners.

So it seems that some source roots were not removed from the RepositoryUpdater.RootListeners, and thus the recursive listeners kept registered.
Comment 4 Jaroslav Havlin 2015-07-16 16:01:15 UTC
One place where a reference is held is navigator panel for Maven project.
Underlaying JTree of BeanTreeView holds a VisualizerNode with o.n.m.maven.execute.navigator.GoalsPanel$PluginChildren, even if the node is not in explorer manager's context.
Expanding the "mock" node currently contained in the tree view seems to fix this problem.

http://hg.netbeans.org/core-main/rev/f9c16934f1f5
Suggestions for some cleaner fix are welcome.
Comment 5 Quality Engineering 2015-07-18 01:47:04 UTC
Integrated into 'main-silver', will be available in build *201507180001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/f9c16934f1f5
User: Jaroslav Havlin <jhavlin@netbeans.org>
Log: #242567: Refresh tree view which holds reference to closed Maven project
Comment 6 Jaroslav Havlin 2015-07-20 15:07:23 UTC
In some cases, projects were referenced from SetMainProject action (some Swing component indirectly holding project root node).
http://hg.netbeans.org/core-main/rev/0e2f6ddbd376
Comment 7 Quality Engineering 2015-07-22 04:37:58 UTC
Integrated into 'main-silver', will be available in build *201507220303* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/0e2f6ddbd376
User: Jaroslav Havlin <jhavlin@netbeans.org>
Log: #242567: Reference projects from SetMainProject weakly
Comment 8 Jaroslav Havlin 2015-09-03 13:05:21 UTC
Adding 8.1_WAIVER_REQUEST keyword.

Some places where projects were held are already fixed.

The last unresolved case seems to be related to background scanning or filesystems. Any reliable solution for it hasn't been found yet.

Thank you for understanding.
Comment 9 Jiri Kovalsky 2015-09-07 10:47:25 UTC
Bug waiver for 8.1 approved.
Comment 10 dip.sweng 2016-07-19 10:32:39 UTC
I confirm that multi module JEE projects consumes 90% of my RAM

Product Version: NetBeans IDE 8.1 (Build 201510222201)
Updates: NetBeans IDE is updated to version NetBeans 8.1 Patch 1
Java: 1.7.0_21; Java HotSpot(TM) 64-Bit Server VM 23.21-b01
Runtime: Java(TM) SE Runtime Environment 1.7.0_21-b11
System: Windows 7 version 6.1 running on amd64; Cp1253; en_US (nb)
Comment 11 dpintint 2016-08-18 08:44:14 UTC
I don't know if this is relevant but: in maven projects having a mirror of * (look above) in settings.xml file, leads to halting the system as it consumes all memory

<mirrors>
 <mirror>
  <id>some-public-group</id>
  <mirrorOf>*,!some-snapshots</mirrorOf>
  <url>https://url.of.some.com/groups/public</url>
 </mirror>
</mirrors>

if i comment out the whole mirror and restart Netbeans it does not lead to a halting system