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 145255 - numerous OutOfMemoryError while using the IDE
Summary: numerous OutOfMemoryError while using the IDE
Status: RESOLVED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: Output Window (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: t_h
URL: http://statistics.netbeans.org/except...
Keywords:
: 150032 160318 (view as bug list)
Depends on:
Blocks: 146914
  Show dependency tree
 
Reported: 2008-08-27 09:30 UTC by nleck
Modified: 2009-03-26 14:46 UTC (History)
5 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter: 48588


Attachments
screen out when out of memory (108.57 KB, image/png)
2008-08-28 03:38 UTC, nleck
Details
messages.log (234.37 KB, text/plain)
2008-08-28 03:42 UTC, nleck
Details
jmap -histo pid (362.22 KB, text/plain)
2008-08-28 03:44 UTC, nleck
Details
message log (788.31 KB, text/plain)
2008-09-01 12:42 UTC, nleck
Details
message log from Build 200809021401 (532.95 KB, text/plain)
2008-09-03 09:06 UTC, nleck
Details
message log after lowering memory (55.95 KB, text/plain)
2008-09-03 23:33 UTC, nleck
Details
pmap (166.55 KB, text/plain)
2008-09-05 00:31 UTC, nleck
Details

Note You need to log in before you can comment on or make changes to this bug.
Description nleck 2008-08-27 09:30:48 UTC
Build: NetBeans IDE 6.1 RC1 (Build 200804100130)
VM: Java HotSpot(TM) Client VM, 1.5.0_14-b03, Java(TM) 2 Runtime Environment, Standard Edition, 1.5.0_14-b03
OS: Linux, 2.6.11-1.1369_FC4smp, i386
User comments: running tests.
STACKTRACE: (first 10 lines)
java.lang.OutOfMemoryError
        at java.util.zip.ZipFile.open(ZipFile.java:0)
        at java.util.zip.ZipFile.<init>(ZipFile.java:203)
        at java.util.jar.JarFile.<init>(JarFile.java:132)
        at java.util.jar.JarFile.<init>(JarFile.java:112)
        at org.netbeans.JarClassLoader$JarSource.getJarFile(JarClassLoader.java:379)
        at org.netbeans.JarClassLoader$JarSource.resource(JarClassLoader.java:407)
        at org.netbeans.Archive.getData(Archive.java:193)
        at org.netbeans.JarClassLoader$JarSource.doGetResource(JarClassLoader.java:395)
        at org.netbeans.JarClassLoader$Source.getResource(JarClassLoader.java:303)
        at org.netbeans.JarClassLoader.findResource(JarClassLoader.java:251)
Comment 1 Peter Pis 2008-08-27 09:34:25 UTC
Reassigning to "java".
Comment 2 Jan Lahoda 2008-08-27 09:47:32 UTC
Why was this assigned to java/*? There is no data that would suggest that java (and much less java/compiler) is using
unreasonable amount of memory, or leaks. There is not stack trace that would point to java (wouldn't mean anything
anyway - the OOME can occur anywhere, not necessarily for the piece of code that uses too much memory/leaks).
Comment 3 nleck 2008-08-27 10:11:06 UTC
The only reason that I blamed it on the background compile was that the IDE was idle at the time ( I was using a
different application ) and there were no documents open. The only think the IDE appeared to be doing was the background
compile.
Comment 4 Tomas Pavek 2008-08-27 10:49:21 UTC
Could you please create a histogram (at least; full heap dump would be ideal) if you see the OOME happen again?
jmap -histo <pid>  (where pid is id of the java process running NetBeans)
Comment 5 nleck 2008-08-28 03:38:23 UTC
Created attachment 68499 [details]
screen out when out of memory
Comment 6 nleck 2008-08-28 03:42:03 UTC
Created attachment 68500 [details]
messages.log
Comment 7 nleck 2008-08-28 03:44:52 UTC
Created attachment 68501 [details]
jmap -histo pid
Comment 8 nleck 2008-08-28 03:47:22 UTC
logs and screen shots attached as requested. The full heap dump will be huge.. not sure if that's something you want me
to upload.

PS. Do I remove the "incomplete" keyword ? 
Comment 9 nleck 2008-08-28 04:41:26 UTC
The full heap dump is far too big to upload over the web. 

[nigel@localhost ~]$ ls -l heap.bin 
-rw-rw-r-- 1 nigel nigel 839503704 Aug 28 13:03 heap.bin
Comment 10 nleck 2008-08-28 06:25:54 UTC
I'm getting OOME while running tests also ( so *NOT* background compile).

This is really odd and causing issues all over the place the memory log shows ~400m of the allocated 1024m for the IDE
is used so I'm not sure why we are getting this error. 
Comment 11 Petr Nejedly 2008-08-28 07:53:05 UTC
Well, _reduce_ your -Xmx to some reasonable value and you'll be fine.
Explanation: There are several distinct memory pools in Java process - code segments, native heap, java heap, mmaped
areas. But there's only so much virtual address space available for a 32bit process, 2-3GB, depending on the setup of
your kernel. All the memory areas have to fit in that space, and if you cut out 2GB just for the heap, other requests
may come short. As you're running on JDK1.5, the OOME from ZipFile.open means there wasn't enough address space for
mmapping given jar. It has nothing to do with the heap or lack thereof.

Out of curiosity, what lead you to setting up -Xmx2048? Was anybody anywhere suggesting this? With CMS on, the IDE might
even work OK (as long as it has enough address space), but will hardly need that much memory.

Now, the heap histogram looks really weird, but this might be caused by the fact that there was no pressure on the GC,
so it left all the debris where it was so far. Pressing the memory bar (i.e. forcing GC) before generating
histogram/dump would help to answer this question, but the top 5 or so lines are suspicious anyway
(600.000 RP tasks were scheduled over the time!?)
Comment 12 nleck 2008-08-28 08:04:20 UTC
This machine has 4gigs of ram. The other machine that I work on has 32 gigs of RAM. The machines themselves aren't
running out of Ram. 

If we use the *default* values Netbeans will run out of memory fairly quickly as we have a large source base. The reason
we are adjusting the memory setings is that we are having large performance issues see #144131 for example. 

I'll set -Xmx1024m and -Xms512m and see if we get the error again. 
Comment 13 nleck 2008-08-28 08:56:26 UTC
This is working, THANK YOU. 
Comment 14 nleck 2008-09-01 12:40:18 UTC
Sorry, I'm getting the out of memory error again even after setting -Xmx1024m and -Xms512m 
Comment 15 nleck 2008-09-01 12:42:49 UTC
Created attachment 68785 [details]
message log
Comment 16 nleck 2008-09-01 12:47:22 UTC
sorry... i must be on drugs. It was using the old settings again.
Comment 17 nleck 2008-09-01 23:02:16 UTC
sorry, I'm still getting the Out Of Memory issue when we run test cases which produces a far amount of output.

The memory settings are -Xmx1024m -Xms512m
Comment 18 nleck 2008-09-02 06:31:43 UTC
Just looking at the associated exception, there are over 110 duplicates from a number of different people. This problem
seems to be occuring on a number of different systems. 
Comment 19 nleck 2008-09-02 06:57:25 UTC
While running the same tests cases under Netbeans 6.1 using the same memory parameters, I DO NOT get the out of memory
error. 
Comment 20 nleck 2008-09-03 09:04:50 UTC
Do you need more information on this ? I've downloaded and tried on the latest build 200809021401
memory settings are :- 
        -Xss2m
        -Xmx1024m
        -Xms512m
        -XX:+UseConcMarkSweepGC
        -XX:+CMSClassUnloadingEnabled
        -XX:PermSize=64m
        -XX:MaxPermSize=200m
        -Xverify:none
        -XX:+CMSPermGenPrecleaningEnabled
 
Comment 21 nleck 2008-09-03 09:06:07 UTC
Created attachment 68934 [details]
message log from Build 200809021401
Comment 22 Tomas Pavek 2008-09-03 09:51:45 UTC
There's a lot of "Cannot allocate memory" failures in the output view, reassigning for evaluation.
Comment 23 Tomas Pavek 2008-09-03 15:59:40 UTC
There could be a problem in output in case it repeatedly allocates memory mapped space - there is no control in java 
to free the previously allocated space.

BTW how big is the printed output? Still can't believe it could be that big it eats so much memory even if it was 
allocated several times. You could also try to make Xmx even smaller - more memory would be available for m-mapping 
and also there would be greater chance that the objects holding the m-mapped space are garbage collected and the space 
freed.
Comment 24 nleck 2008-09-03 23:33:15 UTC
Created attachment 68990 [details]
message log after lowering memory
Comment 25 nleck 2008-09-03 23:37:20 UTC
same issue after lowering to -Xmx512m -Xms256m

This issue doesn't occur in 6.1 with -Xmx1024m -Xms1024 

The output isn't that huge just a number of Log4j outputs from 16 test cases.
Comment 26 Petr Nejedly 2008-09-04 15:30:00 UTC
Could you please attach the output of "pmap <pid>" (or "cat /proc/<pid>/maps") just after the output window related OOME?
Comment 27 nleck 2008-09-05 00:31:09 UTC
Created attachment 69113 [details]
pmap
Comment 28 Petr Nejedly 2008-09-05 10:16:08 UTC
This is what I was afraid of. The output window backing file is mapped many times and fills the whole remaining virtual
address space. How large the output file (/tmp/output1220570513950) was? (too late for such a question, isn't it? ;-))

There might be a bug in the output window implementation, but generally, the problem is that unless there is heap space
pressure (that is, something generating enough java heap garbage), the old and already abandoned memory mapped regions
(that is, a completely unrelated scarce resource - virtual address space) are not freed by the JVM.

It is also possible that the output window buffer implementation remaps too frequently, and it may in fact benefit from
exponential preallocation, but I don't recall details of the output window implementation.

Note: Output window used to behave very well even for ridiculously huge outputs as it was specifically designed so.
Maybe latest few changes Tomas did broke it... 
Comment 29 nleck 2008-09-05 10:54:09 UTC
I've run the test again ( see below) it's only 2.9m.  This problem did not occur in nb6.1 reguardless of the memory
settings I use.

[nigel@dev1 tmp]$ ls -lt |more
total 119568
-rw-r--r--  1 nigel developer  2937204 Sep  5 19:48 output1220607867797

Comment 30 t_h 2008-09-10 13:53:59 UTC
4a95b819da11
Comment 31 nleck 2008-09-10 13:55:22 UTC
Will that be in tomorrow's build ? I'll download and test if you like.
Comment 32 t_h 2008-09-10 13:59:16 UTC
It should propagate, message will be added here automatically once the changeset is in build. Verification would be
appreciated.
Comment 33 Petr Nejedly 2008-09-10 16:35:54 UTC
Tomasi,
What if you overallocated the backing file (by the means of RandomAccessFile.setLength) in an (limited) exponencial manner?

Then you could memory map also the overallocated portion and don't need to change the mapping after every additional
line-to-be-displayed. and if done well, you'll never need more than 2 times the size of the output in the virtual
address space, not even if you really displayed every line of the output and no GC ever.
Comment 34 t_h 2008-09-11 09:00:20 UTC
OW mmaps only part of backing file, so it works up to 2GB limit (swing components) quite well. If user scrolls in OW you
still need remap. However, reported problem was due to frequent remapping at the end of the file (if OW auto-scrolled)
so I agree it might be good idea to map preallocated portion of file to minimize remapping at the end of the file.
Comment 35 Quality Engineering 2008-09-11 17:43:18 UTC
Integrated into 'main-golden', will be available in build *200809111401* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/4a95b819da11
User: Tomas Holy <t_h@netbeans.org>
Log: #145696 and #129099: using single RandomAccessFile for both writing and memory mapping. #145255 firing changes less often to avoid abusing AWT thread and reduce chance to run out of address space by mmaping
Comment 36 ulfzibis 2008-09-17 10:12:22 UTC
Fixing this issue also fixed issue 146914, which was result of JDK bug.

You can monitor this bug on the Java Bug Database at
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6748784.
Comment 37 nleck 2008-09-17 10:27:38 UTC
cool... just download the lastest daily build. This issue is fixed. 
Comment 38 t_h 2008-11-22 21:27:16 UTC
*** Issue 150032 has been marked as a duplicate of this issue. ***
Comment 39 t_h 2009-03-26 14:46:05 UTC
*** Issue 160318 has been marked as a duplicate of this issue. ***