1

Currently I am using NetBeans-8.1 in 32-bit Windows 10. I'm getting the following error:

java.lang.OutOfMemoryError: Java heap space.

I already changed the memory size to -Xmx1024m in netbeans.conf file, added environment variables -Xms1024m -Xmx1024m -XX:PermSize=64M -XX:MaxPermSize=256m but still getting same error. Are there any problems with NetBeans on 32-bit operating systems? My system has 4GB of RAM.

jotik
  • 17,044
  • 13
  • 58
  • 123

2 Answers2

0

Make sure that you have correctly set the flags for NetBeans, otherwise it will not be recognized: NetBeans requires the -J prefix for arguments to the JVM. So you need to use

-J-Xms1024m -J-Xmx1024m

Also you should be aware that Oracle states that Windows 32 bit is capable only of about 1.4GB - 1.6GB of heap. See http://www.oracle.com/technetwork/java/hotspotfaq-138619.html#gc_heap_32bit

Thomas
  • 11,272
  • 2
  • 24
  • 40
  • Thanks for the response. I tried with that. I used -J-Xms1024m -J-Xmx1024m this same arguments. and also added netbeans_default_options="-J-client -J-Xss2m -J-Xms512m -J-Xmx1024m -J-XX:PermSize=512m -J-Dapple.laf.useScreenMenuBar=true -J-Dapple.awt.graphics.UseQuartz=true -J-Dsun.java2d.noddraw=true -J-Dsun.zip.disableMemoryMapping=true -J-XX:+UseConcMarkSweepGC -J-XX:+CMSClassUnloadingEnabled -J-XX:+CMSPermGenSweepingEnabled" in netbeans.conf But still same problem. I thought its bcz of OS 32 bit and 4GB RAM. if any other solutions please suggest me – user6285640 May 03 '16 at 12:25
  • You can try to increase it even further until the JVM will tell you that it can not reserve memory for the heap. (It will fail on startup then) ```-J-Xms1400m -J-Xmx1400m``` – Thomas May 03 '16 at 12:26
  • If that does not solve your problem it will be hard to fix on 32bit OS. Is NetBeans itself using so much memory or is it the application you are launching? In the later case you must add the JVM arguments to the project / "run" configuration, not to NetBeans of course. (These will then not have a -J prefix.) – Thomas May 03 '16 at 12:29
  • for more than 2GB (-J-Xmx2048m) netbeans not starting... Its not opening only – user6285640 May 03 '16 at 12:30
  • Yes that it because of the 32bit memory limit. Therefore try 1400m ... and see me previous comment regarding the question if NetBeans or your application runs OOM – Thomas May 03 '16 at 12:31
  • I tried with -J-Xmx1800m, -J-Xmx1500m... Netbeans not opened for this. When i changed to -J-Xmx1024m its opened – user6285640 May 03 '16 at 12:32
  • You can try to remove the memory allocated to the PermSize to sqeeze out a little more usable heap, so PermSize=256m, Xmx1400m – Thomas May 03 '16 at 12:33
  • netbeans_default_options="-J-client -J-Xss2m -J-Xms512m -J-Xmx1024m -J-XX:PermSize=512m -J-Dapple.laf.useScreenMenuBar=true -J-Dapple.awt.graphics.UseQuartz=true -J-Dsun.java2d.noddraw=true -J-Dsun.zip.disableMemoryMapping=true -J-XX:+UseConcMarkSweepGC -J-XX:+CMSClassUnloadingEnabled -J-XX:+CMSPermGenSweepingEnabled" – user6285640 May 03 '16 at 12:42
  • sir check this one – user6285640 May 03 '16 at 12:42
  • When does the OOM occur? Inside NetBeans or as part of your application? – Thomas May 03 '16 at 12:43
-1

You should increase the -Xmx value, which is the maximum amount of memory the JVM can allocate for the heap. See this answer for details about the flags.

For example, you could use -Xmx4G to allow it to use up to 4GB of memory on your system.

Community
  • 1
  • 1
jotik
  • 17,044
  • 13
  • 58
  • 123