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 40504 - memory leak in search
Summary: memory leak in search
Status: RESOLVED FIXED
Alias: None
Product: utilities
Classification: Unclassified
Component: Search (show other bugs)
Version: 3.x
Hardware: PC Windows ME/2000
: P1 blocker (vote)
Assignee: Antonin Nebuzelsky
URL:
Keywords: PERFORMANCE
Depends on:
Blocks: 40229 40231
  Show dependency tree
 
Reported: 2004-02-26 06:16 UTC by bwl
Modified: 2009-11-07 11:38 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
patch to ResultModel (621 bytes, patch)
2004-02-26 06:17 UTC, bwl
Details | Diff
patch to ResultViewTopComponent (238 bytes, patch)
2004-02-26 06:17 UTC, bwl
Details | Diff
A patch for NB36 (trunk). (1.60 KB, patch)
2004-02-26 12:52 UTC, Antonin Nebuzelsky
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description bwl 2004-02-26 06:16:22 UTC
I've found that if you perform multiple searches 
the ResultModel objects and the associated 
ResultRootNode and FoundNode objects all get 
retained in memory.  Not only does this chew up 
memory, but it also impacts performance because 
all the FoundNode objects continue to listen on 
the data objects.  I found this in 3.5, and the 
patch is for 3.5.  I don't see any change in 
ResultModel in 3.6, but ResultViewTopComponent is 
gone so the behaviour may be different in 3.6 but 
I'd guess its still there.

The fix works by removing the references from 
ResultRootNode to the FoundNode objects (via the 
Children) and by making the FoundNodes only be 
weakly referenced by the data objects.  

Unfortunately, I still find that the 
ResultModel/ResultRootNode/FoundNode objects for 
the last search executed remain in memory.  That 
is until another search is executed.  Couldn't 
work out a nice clean way to resolve that.  Looks 
messy since it happens via ResultViewTopComponent 
having a reference to the explorer manager which 
references the result root node via its explored 
and root context.

Anyway, I hope that a variant of this patch will 
make it into 3.6.  It'd be nice if 3.6 didn't 
gradually slow down and consume more and more 
memory like all previous releases.
Comment 1 bwl 2004-02-26 06:17:23 UTC
Created attachment 13657 [details]
patch to ResultModel
Comment 2 bwl 2004-02-26 06:17:58 UTC
Created attachment 13658 [details]
patch to ResultViewTopComponent
Comment 3 Marian Petras 2004-02-26 10:04:59 UTC
I will not apply the patch in the current form - it causes that search
results are lost when the Search Results window is closed, which is
undesirable.

I appreciate your help with investigation of pending links to objects.
It seems that the cause of the memory leak is that property change
listener(s) are not unregestered.
Comment 4 Antonin Nebuzelsky 2004-02-26 10:12:06 UTC
I agree. IMHO the close() method on the model should be called in
setModel() of the ResultView component, not in componentClosed(). I am
currently building sources with the patch. I will let you know how it
works...
Comment 5 Antonin Nebuzelsky 2004-02-26 12:52:10 UTC
Created attachment 13666 [details]
A patch for NB36 (trunk).
Comment 6 Antonin Nebuzelsky 2004-02-26 12:57:17 UTC
Marian, please review my patch.

Profiler shows me that the resources are now cleaned correctly. I
started after searching filesystems for "er" substring with 13570kB
and after many searches (looking for "a", "e", "i", "o", ..., and at
the end again for "er") with 13575 kB.

And the number of TextDetail class instances, which used to grow and
grow and grow, is now stable.

Let me know, if you agree with the patch, and I will integrate it. THX.
Comment 7 Marian Petras 2004-02-26 13:05:08 UTC
Yes, the patch looks good. You may integrate it.

Thank you.
Comment 8 Antonin Nebuzelsky 2004-02-26 14:30:14 UTC
Fix integrated in trunk.

Brett, thanks for pointing this out and suggesting a fix!
Comment 9 Jaromir Uhrik 2004-02-27 11:27:58 UTC
There is no problem to search repeatedly in build 200402261900. Verified.
Comment 10 Marian Mirilovic 2009-10-01 14:48:46 UTC
reopen to fix status and resolution
Comment 11 Marian Mirilovic 2009-10-01 14:51:20 UTC
fix status and resolution