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 183941

Summary: JVM creation failed
Product: platform Reporter: fr3sh
Component: Launchers&CLIAssignee: Antonin Nebuzelsky <anebuzelsky>
Status: RESOLVED FIXED    
Severity: normal CC: christianlerch, drmandarin, js-java, jtulach, masaki, mmirilovic, musilt2, Nox, NullPointer, pjiricka, rlilly, scanti, thurka, ynov
Priority: P1    
Version: 7.0   
Hardware: PC   
OS: Windows XP   
Issue Type: DEFECT Exception Reporter:
Attachments: netbeans conf file
jmap creation failed
original netbeans conf file

Description fr3sh 2010-04-12 16:54:36 UTC
Hi I cant run netbeans when I try to run the error is pop up and I see something like this 

JVM creation failed

How can I solve the problem?
Comment 1 Yulia Novozhilova 2010-04-13 10:00:56 UTC
Hi,

1) which jdk do you use?
2) please, attach here etc/netbeans.conf file
3) please, try to play with -J-Xmx (run NetBeans with -J-Xmx128m, -J-Xmx256m, -J-Xmx512m). Does it help?
Comment 2 fr3sh 2010-04-13 11:52:18 UTC
This is fresh install of netbeans I have JDK 1.6. On other computer it's works ok with the same instalation of netbeans and JDK. 

When I try to run netbeans with this parametr -J-Xmx256m its runs yupi
When I try to run netbeans with this parametr -J-Xmx512m its give me this: Could not reserve enough space for object heap


Why its so when I have 2 gb of ram ??

Can I run it normaly ever??



This is conf 

# ${HOME} will be replaced by JVM user.home system property
netbeans_default_userdir="${HOME}/.netbeans/6.8"

# Options used by NetBeans launcher by default, can be overridden by explicit
# command line switches:
netbeans_default_options="-J-Dorg.glassfish.v3ee6.installRoot=\"C:\Program Files\sges-v3\" -J-client -J-Xverify:none -J-Xss2m -J-Xms32m -J-XX:PermSize=32m -J-XX:MaxPermSize=200m -J-Dapple.laf.useScreenMenuBar=true -J-Dsun.java2d.noddraw=true"
# Note that a default -Xmx is selected for you automatically.
# You can find this value in var/log/messages.log file in your userdir.
# The automatically selected value can be overridden by specifying -J-Xmx here
# or on the command line.

# If you specify the heap size (-Xmx) explicitely, you may also want to enable
# Concurrent Mark & Sweep garbage collector. In such case add the following
# options to the netbeans_default_options:
# -J-XX:+UseConcMarkSweepGC -J-XX:+CMSClassUnloadingEnabled -J-XX:+CMSPermGenSweepingEnabled
# (see http://wiki.netbeans.org/wiki/view/FaqGCPauses)

# Default location of JDK, can be overridden by using --jdkhome <dir>:
netbeans_jdkhome="C:\Program Files\Java\jdk1.6.0_19"

# Additional module clusters, using ${path.separator} (';' on Windows or ':' on Unix):
#netbeans_extraclusters="/absolute/path/to/cluster1:/absolute/path/to/cluster2"

# If you have some problems with detect of proxy settings, you may want to enable
# detect the proxy settings provided by JDK5 or higher.
# In such case add -J-Djava.net.useSystemProxies=true to the netbeans_default_options.
Comment 3 Yulia Novozhilova 2010-04-13 13:36:56 UTC
Jaroslav, do you have any guess what is the reason for such a strange behavior? There are another users who have the same problem: 

http://www.java-forums.org/netbeans/24956-jvm-creation-failed.html
http://www.coderanch.com/t/474816/IDEs-Version-Control-other-tools/Netbeans-Heap-Space-error
Comment 4 Jaroslav Tulach 2010-04-15 14:58:43 UTC
The heap space error is different. If the user produces histogram with: 
$ jmap -histo <pid> 
we can say more.

I have little idea what is wrong with the JVM creation crash. I suggest to modify platform*/lib/nbexec to print the actual arguments it is using to start the Java VM in case it fails and in case it succeeds:

diff -r 15b6f8ac6c4a nbexec
--- nbexec	Thu Apr 15 09:31:44 2010 +0200
+++ nbexec	Thu Apr 15 16:59:14 2010 +0200
@@ -526,6 +526,8 @@
     #
     delete_new_clusters_file
     rm -f "${restart_file}"
+    echo ${_NB_PROFILE_CMD} "\"${jdkhome}/bin/java\"" -Djdk.home="\"${jdkhome}\"" -classpath "\"$cp\"" \
+        "$jargs" org.netbeans.Main "$args" '<&0' '&'
     eval ${_NB_PROFILE_CMD} "\"${jdkhome}/bin/java\"" -Djdk.home="\"${jdkhome}\"" -classpath "\"$cp\"" \
         "$jargs" org.netbeans.Main "$args" '<&0' '&'
     PID=$!

Without such information we can hardly do anything.
Comment 5 raviparekh 2011-05-16 12:33:44 UTC
C:\Documents and Settings\raviparekh>jmap -dump:format=b,file=heap.bin 3348 > dumpjmap

AND

C:\Documents and Settings\raviparekh>jmap -histo 3348 > dumpjmap1
Exception in thread "main" java.lang.InternalError: Remote thread failed for unk
nown reason
        at sun.tools.attach.WindowsVirtualMachine.enqueue(Native Method)
        at sun.tools.attach.WindowsVirtualMachine.execute(WindowsVirtualMachine.
java:78)
        at sun.tools.attach.HotSpotVirtualMachine.executeCommand(HotSpotVirtualM
achine.java:195)
        at sun.tools.attach.HotSpotVirtualMachine.heapHisto(HotSpotVirtualMachin
e.java:167)
        at sun.tools.jmap.JMap.histo(JMap.java:201)
        at sun.tools.jmap.JMap.main(JMap.java:118)
Comment 6 raviparekh 2011-05-16 12:45:02 UTC
Created attachment 108318 [details]
netbeans conf file

this is my conf file for netbeans 

i have intel 
Core2 duo 2.93GHz
3.24 GB RAM 

netbeans_default_options="-J-client -J-Xss2m -J-Xms32m -J-Xmx600m -J-XX:PermSize=32m -J-XX:MaxPermSize=600m -J-Dapple.laf.useScreenMenuBar=true -J-Dapple.awt.graphics.UseQuartz=true -J-Dsun.java2d.noddraw=true"
Comment 7 raviparekh 2011-05-16 12:46:38 UTC
(In reply to comment #6)
> Created an attachment (id=108318) [details]
> netbeans conf file
> 
> this is my conf file for netbeans 
> 
> i have intel 
> Core2 duo 2.93GHz
> 3.24 GB RAM 
> 
> netbeans_default_options="-J-client -J-Xss2m -J-Xms32m -J-Xmx600m
> -J-XX:PermSize=32m -J-XX:MaxPermSize=600m -J-Dapple.laf.useScreenMenuBar=true
> -J-Dapple.awt.graphics.UseQuartz=true -J-Dsun.java2d.noddraw=true"

i REstated my PC and problem GONE
Comment 8 Jaroslav Tulach 2011-05-16 16:26:21 UTC
Works for the reporter, right?
Comment 9 raviparekh 2011-05-26 09:09:07 UTC
Created attachment 108518 [details]
jmap creation failed

jmap creation failed
Comment 10 raviparekh 2011-05-26 09:37:09 UTC
(In reply to comment #8)
> Works for the reporter, right?

sorry i'm not getting,  'reporter'?
Comment 11 drmandarin 2011-05-27 21:55:20 UTC
Created attachment 108563 [details]
original netbeans conf file
Comment 12 drmandarin 2011-05-27 21:58:12 UTC
I got the same error after installing Netbeans 7. Running Windows 7 64-bit, 4GB RAM. The error persisted over restarts. I've attached my original netbeans.conf file ("original netbeans conf file") with which I was causing the error.

After reading the links in an earlier post on this bug, I changed netbeans.conf to contain -J-Xmx512m

Then, Netbeans started OK. Strangely enough, I then removed -J-Xmx512m from netbeans.conf (i.e. I reverted to the original netbeans conf file which was causing an error) and Netbeans still starts fine!
Comment 13 drmandarin 2011-05-27 22:09:37 UTC
Correction to my previous post.

I thought that reverting to the original netbeans.conf resulted in Netbeans starting, but I was wrong. The reason I though this, was because after I reverted, the Netbeans splash/loading image showed up. But after I few seconds, I again got "JVM creation failed".

So here is a summary:

After first installation, no modification to config file
No splash image, "JVM creation failed".

Added -J-Xmx512m
Starts fine.

Removed -J-Xmx512m
Splash image, "JVM creation failed".

I get the same error with values of 533m and greater. Up to 532m, the Netbeans GUI starts up fine. From 533m onwards, "JVM creation failed".
Comment 14 kjtan 2011-06-01 08:25:33 UTC
Hi there, I have this JVM creation error too.

It works fine for the first installation, but will appear after i reopen the studio.

Somehow I trace the problem occurs due to this splash.png that reside in the USERPATH/.netbeans/7.0/var/cache. If you delete this image file, the studio starts normally. However, once you close your studio, the image file is generated again and the problem persist till you delete it again.

I hope this help the developer in getting a fix for this.
Comment 15 Antonin Nebuzelsky 2011-06-01 16:31:39 UTC
*** Bug 197593 has been marked as a duplicate of this bug. ***
Comment 16 Antonin Nebuzelsky 2011-06-01 16:35:01 UTC
*** Bug 195114 has been marked as a duplicate of this bug. ***
Comment 17 Antonin Nebuzelsky 2011-06-01 17:33:10 UTC
Can people who are able to reproduce the "Could not reserve enough space for object heap" JVM initialization failure do the following?

* make sure netbeans.conf is unmodified (does not contain any custom values for heap or perm gen sizes)

* run NetBeans 7.0 on command-line with -J-XX:+PrintCommandLineFlags parameter, like:

C:\Program Files\NetBeans 7.0\bin> netbeans.exe -J-XX:+PrintCommandLineFlags

* if the failure happens, put a comment in this issue with the following information:

- physical RAM reported by Windows (in Properties action on Computer icon)
- physical memory occupation reported in Windows Task Manager
- Page File value in Windows Task Manager (e.g. I see "1159M / 5335M")
- Windows version and if 32/64bits
- Java version string (output of "java -version") of Java used by NetBeans (the one referenced in netbeans.conf)
- the output in the console produced by the extra option, like this example:

-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=C:\Users\Tonda\.netbeans\7.0\va
r\log\heapdump.hprof -XX:InitialHeapSize=33554432 -XX:MaxHeapSize=1073741824 -XX
:MaxPermSize=402653184 -XX:PermSize=33554432 -XX:+PrintCommandLineFlags -XX:Thre
adStackSize=2048 -XX:-UseLargePagesIndividualAllocation

Thanks!
Comment 18 Antonin Nebuzelsky 2011-06-03 13:26:10 UTC
trunk: http://hg.netbeans.org/core-main/rev/a0e43dd2955e
7.0.1: http://hg.netbeans.org/releases/rev/cf3f1eeb5ea7

Both -Xmx and -XX:MaxPermSize are now set automatically - not statically in netbeans.conf but computed by launcher if not specified by user in netbeans.conf or on command-line.

On Linux - no change:
-Xmx is RAM/5, min 96m, max 768m
-XX:MaxPermSize is 384m

On Windows 64-bit - no change:
-Xmx is RAM/5, min 96m, max 768m
-XX:MaxPermSize is 384m

On Windows 32-bit - changed to:
-Xmx is RAM/5, min 96m, max 384m (previously max 409m = 2GB/5)
-XX:MaxPermSize is 256m (previously 384m)

This should fix the problem for the users on 32-bit windows where under (unfortunatelly) unknown conditions for some users the 2GB of process virtual space is sometimes not available (largely occupied by uknown DLLs most probably).

The users on 64-bit windows who encounter this problem, need to switch from 32-bit Java to 64-bit Java where this problem should not occur because 64-bit process will have much larger virtual space available and it should not get exhausted by any way.

Note that the mechanism cannot reliably depend on version of JDK, so it differentiates based on 32/64-bits of the system. For Windows 64-bit system, there is no reason to use 32-bit JDK, so users should be using 64-bit JDK  (especially in the rare case when they are running into the lack of virtual process space issue).
Comment 19 js-java 2011-06-03 17:55:34 UTC
If 64 bit JDK runs with 32 bit JRE because of 32 bit web browser, that's true.
Comment 20 Quality Engineering 2011-06-04 19:15:08 UTC
Integrated into 'main-golden', will be available in build *201106041000* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/a0e43dd2955e
User: Antonin Nebuzelsky <anebuzelsky@netbeans.org>
Log: #183941: JVM creation failed (on Windows)
Comment 21 mhazlewood 2011-07-29 14:06:35 UTC
Not sure if this helps resolve the issue:  I started experiencing this problem as well and it turns out it was directly after installing Techsmith Morae Recorder 3.2.1.  

I did not immediately make the connection.  I tried the suggestions from this bug report, tried (un-)(re-)installing both JRE/JDK and NB 7.0.  Didn't work.  

Only after uninstalling Morae Recorder did the problem go away.  I am running 32-bit JDK on Windows 7 64-bit (this is a requirement for me, I cannot use the 64-bit JDK for other reasons).
Comment 22 KevinEngauge 2011-08-10 15:19:25 UTC
I just had the same issue but found that having Visual Studio opened was the issue for me.  Once I closed Visual Studio and then re-opened NetBeans 7.0.1, everything worked properly.
Comment 23 Miguel_Fontes 2011-08-12 16:53:39 UTC
The same happened to me but it was related to the current user access level. Running Netbeans as 'Administrator' solved the issue.
Comment 24 dbmuller 2011-09-09 00:04:44 UTC
(In reply to comment #22)
> I just had the same issue but found that having Visual Studio opened was the
> issue for me.  Once I closed Visual Studio and then re-opened NetBeans 7.0.1,
> everything worked properly.

I had the error and when eclipse was open, and after closing eclipse the error went away.  Starting as administrator didn't fix it for me.
Comment 25 towronjo 2011-09-10 12:43:31 UTC
I just had the same error pop up so I closed Dragon NaturallySpeaking 10 which was a program I had just opened prior to Netbeans.  So, by closing Dragon NaturallySpeaking, Netbeans was able to start without a problem. I was also able to reopen Dragon NaturallySpeaking without a problem.
Comment 26 chaos1 2011-09-27 20:02:46 UTC
I wanted to report this issue with my observations.

I noticed this error come up after installing EA's Origin. After reading through the thread, I decided to exit Origin completely. Now that Battlefield 3 beta is done downloading, I can safely close Origin and continue with my Netbeans. :P
Comment 27 Antonin Nebuzelsky 2011-10-05 22:35:51 UTC
*** Bug 202201 has been marked as a duplicate of this bug. ***
Comment 28 jbrocky 2011-10-26 18:57:23 UTC
Had this issue installing Netbeans IDE 7.0.1 on my 64-bit Windows 7 machine. Fixed it by changing the linked 32-bit JDK to the 64-bit JDK.
Comment 29 johnyjj2 2011-11-21 19:23:36 UTC
I had the same problem. Editing the shortcut to the following:
"...\bin\netbeans.exe" -J-Xmx256m
(where ... is the path to directory) helps in my case.
Regards!
Comment 30 qasman 2011-12-22 14:07:40 UTC
I found a solution (hopefully) to this problem. 

I am current running a 64bit windows 7 os. Now when I installed netbeans and ran it, i was presented with this error and it did not go away, regardless of restarts, reinstalls etc. I then realised I had a 32bit version of the java JDK installed. So, what I did was install the 64bit JDK (http://www.oracle.com/technetwork/java/javase/downloads/jdk-7u2-download-1377129.html) and reinstalled netbeans, but setting the JDK to the 64bit one instead of the 32bit, (i.e. setting JDK dir to "C:\Program Files\Java\jdk1.7.0" instead of "C:\Program Files (x86)\Java\jdk1.7.0_01"). This was done DURING the installation phase. After installation succeeded, I ran netbeans and it ran error free and has been running without errors so far. 

If you are running a 64bit machine and are getting this error, please give this possible solution a try and post your results. 

Hope this helps,
Regards.
Comment 31 _ gtzabari 2011-12-27 18:55:44 UTC
I get this problem fairly regularly under Windows 7 64-bit running a 32-bit JVM. I believe that this patch actually made the problem worse on my system because you're using a larger max-heap setting than you did in the past under the false assumption that I am running a 64-bit JVM.

Product Version: NetBeans IDE Dev (Build 201112250601)
Java: 1.7.0_01; Java HotSpot(TM) Client VM 21.1-b02
System: Windows 7 version 6.1 running on x86; Cp1252; en_US (nb)
User directory: C:\Users\g.tzabari\.netbeans\dev
Cache directory: C:\Users\g.tzabari\.netbeans\dev\var\cache

Switching to a 64-bit JVM is not an option because I am debugging an application dependent on a 32-bit DLL (by way of JNI).

Please amend this patch to use 32-bit heap settings if a 32-bit JVM is used (regardless if the OS is 64-bit).
Comment 32 _ gtzabari 2011-12-27 19:00:39 UTC
Sorry, I filed a separate bug report (206751) because version 7.0.1 has already been released.
Comment 33 lunalilo 2012-07-03 04:36:52 UTC
I would like to add that Stopping one of these services fixed my issue, and I am running windows 7 64bit.

Things I didn't have to do:
 restart computer
 reinstall netbeans or anything else

Things I've tried that didn't work: 
 run in administrator - just froze
 reinstalled java environment

What worked:
task manager--->processes

stopped:javaw.exe, netbeans.exe, firefox.exe, (firefox)plugin-container.exe - restarted netbeans NOW WORKS.
Comment 34 markosaurus 2014-11-14 14:06:24 UTC
Turns out it was firefox for me too.

Closed firefox down and it worked first time.  Now it works even with FF running too?
Comment 35 hardyheroin 2014-12-17 00:39:31 UTC
Just adding my 2 cents as there seems to be a lot of confusion what exactly the cause of the error is and it does show up quite high in search engines.

As far as I understand, the problem is that the default JVM for obscure and archaic reasons requires a contiguous heap (of memory). On a typical 32-bit OS or 64-bit OS but 32-bit JVM such a contiguous block of memory cannot always be allocated (your millage varies per OS type due differences in memory management). This is especially the case when memory is fragmented because of other applications running in the background (which explains why sometimes killing other applications, or a fresh restart can resolve the issue).
On the command line you might see errors such as:
Error occurred during initialization of VM
Could not reserve enough space for <some size in kB> object heap.

The solution is to tweak the sum of -J-Xmx and -J-XX:MaxPermSize usch that your OS under normal conditions can still swallow it. Even if you have a 64-bit OS, but 32-bit VM, under Windows this will amount to less than 1.1GB (Linux a bit more, and Solaris a bit more still). You can also not specify these options, in which case the default -XX:MaxRAMFraction=4 will put -J-Xmx at the default of 1/4th of your RAM. 

For the interested reader, some links below:

1) On contiguous memory
http://stackoverflow.com/questions/171205/java-maximum-memory-on-windows-xp
2) On out of memory errors
http://www.kdgregory.com/index.php?page=java.outOfMemory
3) On the dynamic tuning of Xmx:
http://stackoverflow.com/questions/19712446/how-does-java-7-decide-on-the-max-value-of-heap-memory-allocated-xmx-on-osx