resolve java.lang.OutOfMemoryError: Java heap space in NetBeans - netbeans

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.

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

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.

Related

Install4j JVM arguments

I'm using Install4j 7.0.12.
Installation process finished well, but when I have tried to run uninstall, I'm getting error:
"The JVM could not be started. The maximum heap size (-Xmx) might be too large or an antivirus or firewall tool could block the execution."
I have disabled firewall and antivirus, but without any success. Is there any way how to specify maximum heap size when the installer/uninstaller is already build? What is default size of this java argument?

What is the maximum number of files that can be built at once in Netbeans 7.2

I have a project that has approximately 2000 files (not including library files) that I want to build.
In netbeans 6.9, I was getting "out of memory" error even when I increased the heap to 1 GB. But I got by it by building few packages at a time.
But in netbeans 7.2, I am not able to do this. Even for packages containing 30 files, I sometime get the "out of memory" error.
So, what is the maximum number of files that can be build simultaneously?
How do I get over this problem?
The heap size is 1GB.
UPDATE:
My machine is running Windows 7, 32 bit on a 64-bit machine. Currently, I can't reinstall a 64-bit windows 7.
Other configurations, 4 GB RAM. Intel Core 2 quad CPU 2.66Hz.
netbeans conf.:
netbeans_default_options="-J-client -J-Xss2m -J-Xms384m -J-Xmx1024M -J-XX:PermSize=32m -J-Dapple.laf.useScreenMenuBar=true -J-Dapple.awt.graphics.UseQuartz=true -J-Dsun.java2d.noddraw=true -J-Dsun.zip.disableMemoryMapping=true"
I have a java project containing about 2400 source files and it builds fine within 50-60 seconds.
I don't expect Netbeans to have a limitation, Any limitation that you may have is probably hardware/setup related.
I start Netbeans with the following options:
netbeans_default_options="-J-client -J-Xss32m -J-Xms256m -J-Xmx1g -J-XX:PermSize=64m -J-XX:+UseConcMarkSweepGC -J-Dapple.laf.useScreenMenuBar=true -J-Dapple.awt.graphics.UseQuartz=true -J-Dsun.java2d.noddraw=true -J-Dsun.zip.disableMemoryMapping=true"
Those options are located in install_dir/etc/netbeans.conf
setup:
Core i7 with 10GB ram running jdk1.6.0_33 on Windows 7 64 bit
"out of memory" could be caused by heap size or permgen size. You could use jVisualVM in your jdk/bin to monitor the memory usage.
From your setting, "-J-XX:PermSize=32m" in addition to NetBeans behavior: "Note that default -Xmx and -XX:MaxPermSize are selected for you automatically.". I guess it could be due to PermGen size.
You can try to set "-J-XX:PermSize=128m"
(For my case, the startup of NetBeans is faster after I increased the permsize.)

DartEditor.exe and java exit code 1

I try to run DartEditor on Windows. I've downloaded the latest version from:
dartlang.org/docs/getting-started/editor/index-win.html
(i tried both the stable and untested latest version - same results)
At first Editor was facing problem with finding the java virtual machine, so I added the path to the "DartEditor.ini", which now looks like that:
-data
workspace
-vm
C:\Program Files\Java\jdk1.7.0_02\bin\javaw.exe
-vmargs
-Dosgi.requiredJavaVersion=1.6
-XX:MaxPermSize=256m
-Xms40m
-Xmx1024m
Now java is starting BUT it's returning following error:
(sorry for URLs, but i'm not yet allowed to post images)
and information:
I suppose that this error is connected with eclipse, but sadly I have no idea where exactly the problem is. Any help appreciated.
I don't see anything wrong with your posted .ini contents, it could be that you are seeing https://bugs.eclipse.org/bugs/show_bug.cgi?id=188968
Essentially the -Xmx1024m might be too large and the jvm can't find a contiguous block of memory that large. Shared libraries might be loaded in the middle of the address space fragmentin the available memory).
By removing the .ini file, you get the default Xmx args which are much lower. You could try changing to -Xmx512m or -Xmx768m.
I had the same issue until I upgraded my JRE from version 6 to 7. Though dartlang.org states that Dart Editor's minimum required Java version is 6, I believe they may have forgotten to update this info.
Additionally, dartlang.org states that Windows XP is not supported. FYI

Eclipse memory restricting

I am using a 32bit WinXP with no upgrade in sight, is there a way to limit how much memory Eclipse allocates throughout the day? I am also running Weblogic 10 server in debug mode inside eclipse. After a few hours I have an 700mb STS.exe (eclipse) and 400mb java.exe (server). Is there at least a way to force a GC on eclipse?
Here are the settings i surrently use, which seem to me are not being observed.
-vm
C:\bea\jdk160_05\bin\javaw.exe
-showsplash
--launcher.XXMaxPermSize
128M
-vmargs
-Dosgi.requiredJavaVersion=1.5
-Xms40m -Xmx512m
-Dsun.lang.ClassLoader.allowArraySyntax=true
EDIT: here's the monster of a project: Eclipse and Firefox 4.
is there a way to limit how much memory Eclipse allocates throughout the day?
The values of -Xmx and -XX:MaxPermSize place an upper bound on the memory that the JVM will use.
Is there at least a way to force a GC on eclipse?
AFAIK, no. Even if there was, it probably wouldn't help. The JVM is unlikely to give the memory back to the operating system.
Here are the settings i currently use, which seem to me are not being observed.
Based on what you've said (memory usage 700Mb for eclipse.exe), I'd say the settings ARE being observed.
What can you do to get Eclipse to use less memory?
Trim the values of -Xmx and -XX:MaxPermSize. However, if you do this too much you are liable to make Eclipse sluggish ('cos it has to GC more frequently) and ultimately flakey ('cos it will run out of memory and things will start failing with OOMEs)
Get rid of superfluous plugins.
Switch to a "smaller" Eclipse (e.g. the "Classic" distro) ... though you'll lose some of the J2EE support that you are probably using.
Close projects.
Close files.
Restart Eclipse more often.
But the best solution is to upgrade your platform:
Buy some more memory for your PC / laptop. You can probably max it out for a couple of hundred dollars. It is worth it.
Switch the OS to Linux. In my experience, Linux is a much better platform for doing Java software development than Windows XP. It seems to do a much better job in terms of both memory and file system management. The performance difference on identical hardware is significant.
You can always set up your machine to dual boot, so that you can still run XP for other things.
The 700MB of OS level process usuage is consistent with your memory settings. Take 512m for heap + 128m for permgen space + a bit of overhead for the JVM itself.
You cannot force GC. If memory was releasable, JVM would release it. Note that you cannot simply look at OS level process usage as that represents the point where the JVM memory usage peaked. JVM never releases heap or permgen space once it expands to a certain size. It is simply too expensive and not really necessary. The allocated space is in virtual address space of the JVM process. It doesn't represent actual physical memory usage. As physical memory gets tight, the OS will agressively swap out to disk memory pages that haven't been used recently.
So... You need specialized memory analysis tools to get accurate representation of Eclipse memory usage.
If you are seeing a lot of disk activity when there shouldn't be any, the OS may be indeed out of physical memory and doing a lot of swapping. Try closing a few projects or restarting Eclipse. It only takes one plugin with a memory leak to consume all of your available memory.
I'm assuming that you are running BEA JRockit judging by the path to javaw.exe. Note that the -X... options are JVM-specific, so they may not work the same way for JRockit as in Sun's JVM. This link seems to indicate that you should be using
... -Xms:40m -Xmx:512m ...
But setting a heap size limit will only cause Eclipse to fail once it reaches the limit, so you won't solve the real problem. Forcing a GC usually doesn't help; any sane VM will GC periodically or when needed.
Having a 700Mb Eclipse sounds like your Eclipse is either processing large amounts of data, or it is leaking memory. JRockit seems to have a memory leak detector which may be able to give you a hint of where the problem lies.
The ini file memory settings won't help for the Virtual machine. Change VM arguments, as here
Eclipse is very thirsty. Limiting it is most likely to crash it. You really need a new computer.

How to reduce Eclipse's memory usage?

The memory usage of Eclipse 3.4 is through the roof to the point where it's becoming an issue.
I have a simple BlackBerry project loaded and the usage skyrockets to nearly 400 MB, sometimes higher. Is there something that can be done to bring it down?
Eclipse 3.4 can consume a lot more memory than the previous versions, courtesy the spellchecker plug-in.
You can switch off the plug-in by going to Window -> Preferences -> General -> Editors -> Text Editors -> Spelling, and unchecking the box title 'Enable spell checking'.
Of course, the tips offered to use larger heap sizes and better garbage collectors would do you good as well.
Checking General -> Show heap status will enable this
in the bottom bar.
This way you can manually run the garbage collector whenever you want by clicking on the trash can. It's not a fix, more like a workaround, but it helped reduce massively my RAM / CPU usage.
Remove +UseG1GC option from eclipse.ini. I've read from here that It is only used for araound 6GB heap memory.
In Eclipse Luna 4.4.1
Was trying to cut my memory usage in Eclipse. I managed to shave mine from 600mb to 300mb. I did the following:
Turned off the plugins activated on startup that I wasn't using. Windows > Preferences > General > Startup and Shutdown
Closed projects I wasn't working on at the time.
Found the hints/tips here : http://blog.elijaa.org/2010/09/20/tricks-to-speed-up-eclipse-php-helios-pdt-2-2/
Modern versions of Eclipse do need quite a bit of RAM to do their thing. But should still run pretty fast on any modern machine.
Assuming you have enough physical memory (2GB is fine unless you have lots of other processes running, or you're using RAD), see this article on Eclipse's memory usage for some tips on tweaking the settings. The two most common culprits are Xmx and/or MaxPermSize being set too low (Xmx defaults to 256M and MaxPermSize defaults to 64M).
You modify the values by passing command line arguments or tweaking the eclipse.ini in the Eclipse install location.
You should end up with something like this:
...
-vmargs
-Xms128m
-Xmx1024m
-XX:MaxPermSize=128m
While you probably could tinker with the configuration, removing various plugins etc, it's likely to be more cost effective to buy more memory. How much do you currently have? I would consider a developer machine with less than 2GB of memory to be under spec, and I suspect many people would double that...
My Eclipse is taking over 800MB resident, and 2GB virtual (part of it swapped out perhaps).
Java can be a hog, it's giving Java bad press all the time.
However, there is a little something that many people don't know: the incremental garbage collector. -Xincgc
The side effect is that it hands memory back to the system from time to time.
By default Java just takes and takes, and when it doesn't need memory anymore, it keeps it for itself.
The incgc is a different strategy where it becomes more reasonable to assume that memory can be handed back the system without running into trouble.
This can however affect performance.
There are many garbage collection settings. You can also have multiple threads handle GC. The parallel GC does that. Not sure if that one hands memory back, don't think so.
If 400 Mb of RAM is a big issue for you, you might want to try another IDE. Eclipse stores a lot of state information, some or most of which you don't actually need. That's a design choice.
Right now, I have the same project open in both Eclipse and QtCreator: after a clean rebuild, Eclipse uses 156 Mb RAM, Qt Creator is happy with 66 Mb.
You can try the 64bit version of Eclipse with the 64bit version of JDK on Windows 7. Those both caused some odd issues with the 3rd party Framework I have to work with. The 32-bit of JRockit (free now) from Oracle seems to be faster and be a little better on memory. This is my Eclipse.ini settings:
This is my eclipse inn
-startup
plugins/org.eclipse.equinox.launcher_1.1.1.R36x_v20101122_1400.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.1.2.R36x_v20101222
-nosplash
org.eclipse.platform
--launcher.XXPermSize
512m
--launcher.XXMaxPermSize
512m
--launcher.defaultAction
openFile
-vm
C:/Program Files (x86)/Java/jrockit-jdk1.6.0_31-R28.2.3-4.1.0/jre/bin
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m
--launcher.defaultAction
openFile
-vmargs
-Xquickstart
-XX:+AggressiveHeap
-XX:+AggressiveOpts
-XX:+UseParallelOldGC
-XX:ParallelGCThreads=2
-XX:ThreadPriorityPolicy=1
-Xverify:none
-Xms1100m
-Xmx1100m
I switched to the 32 bit JRockit JDK which seems a little faster for Eclipse. I turn off and don't install more than I need. For each separate type of app development (Android, J2EE, just Spring, ...) I have different Eclipse installations. Hard drive space is cheap. Then I can have just the plugins I need for each one. I would never want all the Android tools loading if I wasn't using them. STS is also good for just the Spring stuff and I have one just for OpenShift Cloud work.
Try disabling your eclipse plugins. Eclipse was hogging half of my of my memory when I had the saros plugin open.