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 129557 - Find may consume a lot of memory when searching large unrecognized files
Summary: Find may consume a lot of memory when searching large unrecognized files
Status: RESOLVED FIXED
Alias: None
Product: utilities
Classification: Unclassified
Component: Search (show other bugs)
Version: 6.x
Hardware: All All
: P2 blocker (vote)
Assignee: Marian Petras
URL:
Keywords: PERFORMANCE
: 145383 (view as bug list)
Depends on: 134558 155380
Blocks:
  Show dependency tree
 
Reported: 2008-03-07 15:51 UTC by tboerkel
Modified: 2009-07-30 11:35 UTC (History)
7 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
log (32.02 KB, text/plain)
2008-03-07 15:53 UTC, tboerkel
Details
messages.log related to the heap dump (38.07 KB, text/plain)
2008-04-16 17:34 UTC, tboerkel
Details
stacktrace (1.74 KB, text/plain)
2009-04-01 11:45 UTC, avp
Details
stacktrace (3.02 KB, text/plain)
2009-07-29 10:39 UTC, mohhmekk
Details
stacktrace (8.95 KB, text/plain)
2009-07-29 13:43 UTC, mohhmekk
Details
stacktrace (8.95 KB, text/plain)
2009-07-30 11:35 UTC, mohhmekk
Details

Note You need to log in before you can comment on or make changes to this bug.
Description tboerkel 2008-03-07 15:52:00 UTC
I have a 2 GB RAM machine and I was able to use "Find Usages" without problems in our large project with NB 6.0.

With NB 6.1 Beta, I get OutOfMemory.

Attaching log.
Comment 1 tboerkel 2008-03-07 15:53:15 UTC
Created attachment 57982 [details]
log
Comment 2 Jan Becicka 2008-03-12 14:07:31 UTC

*** This issue has been marked as a duplicate of 129864 ***
Comment 3 tboerkel 2008-04-16 06:58:26 UTC
OK, I am pretty sure that this is no duplicate of the other issue with parsing.

I got this OOM again in NB 6.1 RC1, but this time during Find. So I guess, it is not parsing and not Find Usages, but
the display of the result in the output window (same in Find Usages and Find).

I have a heap dump of this situation:
2 small projects and 1 large project open, 38 sources open. Memory is at 116 MB. Then a Find over the large project.
When the number of matches is about 100 in about 60 files, I get the OOM, because then about 300 MB is allocated.

How can I upload the heap dump? It's 31 MB even when heavily packed with bzip2.
Comment 4 Jan Pokorsky 2008-04-16 10:01:30 UTC
Try to upload the file to some file sharing service like www.zupload.com and leave the link here.

Please do not change issue priority if you are not willing to fix the issue.
Comment 5 tboerkel 2008-04-16 13:20:05 UTC
I raised the priority, because I see this as a showstopper for NB 6.1.

Here is the link to the heap dump: http://www.mediafire.com/?fcmsmitxujy

zupload did not work, but mediafire does.
Comment 6 Jan Pokorsky 2008-04-16 16:18:24 UTC
Thanks for the file. In the heap dump you sent there are two big char arrays (128MB + 67MB). Unfortunately it is
impossible to find who created them since there was some GC and arrays contain only binary data.

According to messages.log this should really relate to parsing of java files. Are you able to reproduce this OOM? There
is D:\P2plus\Trunk\AppServer\P2Java\com\apag\p2plus\p2core\Tool.java in your messages.log. Could you check the file content?
Comment 7 tboerkel 2008-04-16 17:33:53 UTC
This messages.log was old. I am attaching a recent one, that is related to the heap dump.

Is there anything else I can check, when it happens?
Comment 8 tboerkel 2008-04-16 17:34:40 UTC
Created attachment 60297 [details]
messages.log related to the heap dump
Comment 9 Jan Pokorsky 2008-04-16 17:40:16 UTC
As I wrote before. Is it reproducible? Is D:\P2plus\Trunk\AppServer\P2Java\com\apag\p2plus\p2core\Tool.java or other
file you search broken?

How did you create the dump file? With -J-XX:+HeapDumpOnOutOfMemoryError?
Comment 10 tboerkel 2008-04-16 17:52:10 UTC
If you want, I can mail you Tool.java (NDA).

I used jmap to get the heap dump.
Comment 11 Jan Pokorsky 2008-04-16 18:38:45 UTC
In case the file content is OK it is not necessary to send. I thought it could be some kind of cross-linked file issue.

If it is reproducible a new heap dump using -J-XX:+HeapDumpOnOutOfMemoryError would be helpful. It should prevent GC.

Strange is that the issue occurs always when the IDE reads from a stream. It looks like some layer (file content
provider) provides incorrect content.
Comment 12 tboerkel 2008-04-17 07:50:43 UTC
I got it reproducable at the moment with a search in a large project. 

Here is a new automatic dump with -J-XX:+HeapDumpOnOutOfMemoryError: http://www.mediafire.com/?nznzmsjhy1v

This was the stacktrace:

java.lang.OutOfMemoryError: Java heap space
	at java.util.Arrays.copyOf(Arrays.java:2882)
	at java.lang.AbstractStringBuilder.expandCapacity(AbstractStringBuilder.java:100)
	at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:515)
	at java.lang.StringBuffer.append(StringBuffer.java:306)
	at java.io.BufferedReader.readLine(BufferedReader.java:345)
	at java.io.LineNumberReader.readLine(LineNumberReader.java:182)
	at org.netbeans.modules.search.BasicSearchCriteria.checkFileContent(BasicSearchCriteria.java:642)
	at org.netbeans.modules.search.BasicSearchCriteria.matches(BasicSearchCriteria.java:575)
	at org.netbeans.modules.search.SpecialSearchGroup.processSearchObject(SpecialSearchGroup.java:108)
	at org.netbeans.modules.search.SpecialSearchGroup.doSearch(SpecialSearchGroup.java:88)
	at org.openidex.search.SearchGroup.search(SearchGroup.java:178)
	at org.netbeans.modules.search.SearchTask.run(SearchTask.java:124)
	at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:561)
	at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:986)
Comment 13 Petr Nejedly 2008-04-17 11:01:19 UTC
So the problem is not with a large project, but rather with a large binary file inside the project (or generally under
the search root) and the fact that utilities/search module tries to load the file at once (as it has no newlines).
Try to find that file and check searching without it.

Utilities/search module should probably try text search only on text/* files, and certainly don't try to count lines
(readLine) on binary files.
Comment 14 Marian Petras 2008-04-17 12:12:09 UTC
There are two issues in the Utilities module related to the described problem:
  - the algorithm for distinguishing text files from binary files is far from perfect
  - reading by lines - the problem is when the lines are very long

None of the above has changed since NB 6.0 so it cannot be a regression in the Utilities module.
Comment 15 tboerkel 2008-04-17 13:23:44 UTC
OK, I had large heap dumps in the project main folder. After I deleted them, the OOM during Find is gone.

So, maybe this was not the same problem as the initial Find Usages problem after all.
Comment 16 Marian Petras 2008-04-17 13:38:58 UTC
Thanks for the additional information.

It seems that the heap dump files generated for fighting with the original bug caused that you discovered another bug in
the Utilities module. Because the last comments in this bug report are about the issues in the Utilities module, I will
not change the category back to "refactoring" and I will track the bugs in the search feature. If you find a way to
reproduce the original issue in Find Usages, please file a separate bug report against module "refactoring".

This bug will not be fixed in NB 6.1. It will be fixed in the next release.
Comment 17 Marian Petras 2008-08-21 15:34:05 UTC
Because I do not know of any reliable detection of binary files, I will make a quick fix - not search large files of
unknown type (MIME-type "content/unknown").
Comment 18 Marian Petras 2008-08-27 07:44:20 UTC
Fixed.

Changeset Id:
39af3e9658b4
(http://hg.netbeans.org/main/rev/39af3e9658b4)
Comment 19 Quality Engineering 2008-08-28 06:27:49 UTC
Integrated into 'main-golden', available in build *200808280201* on http://bits.netbeans.org/dev/nightly/
Changeset: http://hg.netbeans.org/main/rev/39af3e9658b4
User: Marian Petras <mpetras@netbeans.org>
Log: fixed bug #129557 - "Find may consume a lot of memory when searching large unrecognized files"
Comment 20 Marian Petras 2008-08-28 10:19:39 UTC
*** Issue 145383 has been marked as a duplicate of this issue. ***
Comment 21 Exceptions Reporter 2008-10-23 16:30:56 UTC
Reopening - reproduced in NetBeans IDE 6.5 RC1 (Build 200810171318)
http://statistics.netbeans.org/exceptions/detail.do?id=132581
Comment 22 Marian Petras 2008-11-03 14:49:17 UTC
I do not of any other fix than the one described in issue #134558, i.e. search FileObjects instead of DataObjects.
FileObjects are lightweight (fast to initialize, do not hold much memory), DataObjects are heavyweight.
Comment 23 Andrey Yamkovoy 2009-02-04 09:56:14 UTC
Removed blocker 155379 because it's blocking (not prevent DataObject creation) only searching for xml files but regular
projects mostly have java files.

So since issues 134558 and 155380 were fixed and blocker 155379 was removed (as described above) now search for java
files should use less memory and performance should be better. 
Comment 24 avp 2009-04-01 11:45:22 UTC
Build: NetBeans IDE Dev (Build 200903310200)
VM: Java HotSpot(TM) 64-Bit Server VM, 11.0-b16, Java(TM) SE Runtime Environment, 1.6.0_11-b03
OS: Linux, 2.6.27.7-9-default, amd64

User Comments: 


Stacktrace: 
java.lang.OutOfMemoryError: Java heap space
        at java.util.Arrays.copyOf(Arrays.java:2882)
        at java.lang.AbstractStringBuilder.expandCapacity(AbstractStringBuilder.java:100)
        at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:390)
        at java.lang.StringBuffer.append(StringBuffer.java:224)
        at org.netbeans.core.startup.TopLogging$LgStream.write(TopLogging.java:726)
        at sun.nio.cs.StreamEncoder.writeBytes(StreamEncoder.java:202)
Comment 25 avp 2009-04-01 11:45:26 UTC
Created attachment 79214 [details]
stacktrace
Comment 26 mohhmekk 2009-07-29 10:39:42 UTC
Build: NetBeans IDE 6.7 (Build 200906241340)
VM: Java HotSpot(TM) Client VM, 14.0-b16, Java(TM) SE Runtime Environment, 1.6.0_14-b08
OS: Linux, 2.6.28-14-generic, i386

User Comments: 


Stacktrace: 
java.lang.OutOfMemoryError: Java heap space
        at java.util.Arrays.copyOf(Arrays.java:2882)
        at java.lang.AbstractStringBuilder.expandCapacity(AbstractStringBuilder.java:100)
        at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:390)
        at java.lang.StringBuffer.append(StringBuffer.java:224)
        at org.netbeans.modules.xml.wizard.XMLGeneratorVisitor.printModel(XMLGeneratorVisitor.java:217)
        at org.netbeans.modules.xml.wizard.XMLGeneratorVisitor.visitChildren(XMLGeneratorVisitor.java:163)
Comment 27 mohhmekk 2009-07-29 10:39:47 UTC
Created attachment 85427 [details]
stacktrace
Comment 28 mohhmekk 2009-07-29 13:43:11 UTC
Build: NetBeans IDE 6.7.1 (Build 200907230233)
VM: Java HotSpot(TM) Client VM, 14.0-b16, Java(TM) SE Runtime Environment, 1.6.0_14-b08
OS: Linux, 2.6.28-14-generic, i386

User Comments: 


Stacktrace: 
java.lang.OutOfMemoryError: Java heap space
        at java.util.Arrays.copyOf(Arrays.java:2882)
        at java.lang.AbstractStringBuilder.expandCapacity(AbstractStringBuilder.java:100)
        at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:390)
        at java.lang.StringBuffer.append(StringBuffer.java:224)
        at org.netbeans.modules.xml.wizard.XMLGeneratorVisitor.printModel(XMLGeneratorVisitor.java:217)
        at org.netbeans.modules.xml.wizard.XMLGeneratorVisitor.visitChildren(XMLGeneratorVisitor.java:163)
Comment 29 mohhmekk 2009-07-29 13:43:21 UTC
Created attachment 85446 [details]
stacktrace
Comment 30 mohhmekk 2009-07-30 11:35:07 UTC
Build: NetBeans IDE 6.7.1 (Build 200907230233)
VM: Java HotSpot(TM) Client VM, 14.0-b16, Java(TM) SE Runtime Environment, 1.6.0_14-b08
OS: Linux, 2.6.28-14-generic, i386

User Comments: 


Stacktrace: 
java.lang.OutOfMemoryError: Java heap space
        at java.util.Arrays.copyOf(Arrays.java:2882)
        at java.lang.AbstractStringBuilder.expandCapacity(AbstractStringBuilder.java:100)
        at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:390)
        at java.lang.StringBuffer.append(StringBuffer.java:224)
        at org.netbeans.modules.xml.wizard.XMLGeneratorVisitor.printModel(XMLGeneratorVisitor.java:217)
        at org.netbeans.modules.xml.wizard.XMLGeneratorVisitor.visitChildren(XMLGeneratorVisitor.java:163)
Comment 31 mohhmekk 2009-07-30 11:35:19 UTC
Created attachment 85526 [details]
stacktrace