Eclipse + GWT -> Out of memory in development mode - java

If I run my GWT application in eclipse in development mode and click around in the browser for some time, I always get an "out of memory" error in eclipse. My computer has 16 GB Ram, and there is never used more than 8GB.
I tried several config parameters. The VM-arguments in my Run configuration contain these parameters: "-Xms8192m -Xmx8192m"
Even in the eclipse.ini I tested several config parameters and now it looks like this:
--launcher.XXMaxPermSize
8192M
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
8192m
--launcher.defaultAction
openFile
--launcher.appendVmargs
-vmargs
-Dosgi.requiredJavaVersion=1.6
-Xms8192m
-Xmx8192m
But I still get the error. Is there any way to prevent this?

If the browser application is throwing the OutOfMemoryError, then you don't need to change the Eclipse settings (eclipse.ini), that's only for Eclipse itself (more memory, usually faster workbench).
To increase an app's memory (any Java app launched from Eclipse), go to the Run/Debug configurations... in the Run menu and set the VM arguments on the Arguments tab of the app's run config:
-Xms128M -Xmx1024M -XX:MaxPermSize=256M

put this in vm arguments in your run configurations:
-Xmx2048M -XX:MaxPermSize=512m

If I run my GWT application in eclipse in development mode and click around in the browser for some time, I always get an "out of memory" error in eclipse.
Not exactly sure what the problem is but I do see some issues with your current arguments.
You have 2 launcher args that are the same. You don't need the 2nd entry of:
--launcher.XXMaxPermSize
8192M
I really doubt that you want 8g of PermSize. Something like 512m is probably much better. You can use jconsole to see how much memory is in the perm space bucket. In the below image taken from jconsole's memory tab, the bar highlighted at the bottom right shows the "Perm Gen" space. Right now it is using 26,906kb (or around 27mb). That's where code goes and it often has to be increased if you have many JSP pages which get compiled as well.
If you run your application with the following params you should be able to connect with jconsole to see how it's doing:
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.authenticate=false
I suspect that you are going to see that you are using far, far less in the "Perm Gen" space. The -Xmx8192m (or -Xmx8g) is all you need typically. It will give 8gb of memory to the heap in general which is typically short lived objects. It also scales the various different memory partitions accordingly.
For more information about various heap spaces see the Java hotspot documentation.

Related

Is there some way to recover Eclipse IDE extra used memory?

on what Eclipse uses so much extra memory? could it be a bug?
on starting eclipse IDE Oxigen rc2/rc3, it uses about 600mb of ram.
after about 30h non stop using it (suspended the notebook many times in between, without closing eclipse). It raises to 2.5Gb.
a few more hours it will be about 3.2Gb and then the machine memory will end and will start swapping making everything slow requiring restart eclipse, that will be 600Mb again.
eclipse's heap garbage collector does nothing, wont help on that.
any preferences option or startup commandline java options that could help on eclipse releasing some of that memory? if it remained in about 1Gb it would help a lot. using jdk 8 here.
ini file useful info (none of these helps btw):
--launcher.appendVmargs
-vmargs
-Dosgi.requiredJavaVersion=1.8
-Dosgi.instance.area.default=#user.home/eclipse-workspace
-XX:+UseG1GC
-XX:+UseStringDeduplication
-Dosgi.requiredJavaVersion=1.8
-Xms256m
-Xmx1024m
edit: at oxygen RC3, the trashcan worked from 2.3GB to 1.9GB. Before I be sure, I will keep rc3 open for many days and see if it will continue working well with the trashcan click. Til now is working as I needed!

"insufficient memory for the Java Runtime Environment " message in eclipse

When I run my Java code in Eclipse, I get the following message:
There is insufficient memory for the Java Runtime Environment to continue.
Native memory allocation (malloc) failed to allocate 4088 bytes for AllocateHeap
An error report file with more information is saved as:
E:\Eclipse_Workspace\BTest\hs_err_pid1888.log
I have 4GB RAM in my computer. I have changed my JRE from 1.7 to 1.8 too. But the issue seems un-resolved. I use a Win 8 system with i3 Processor and have around 20gb of free disk space in my C Drive.
Eclipse version: Eclipse Juno Service release 2
I also get this message while starting Eclipse. I have attached the error message screen shot.
What is causing this issue?
Memory parameters in "eclipse.ini" file:
-startup
plugins/org.eclipse.equinox.launcher_1.3.0.v20120522-1813.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.200.v20120913-144807
-product
org.eclipse.epp.package.java.product
--launcher.defaultAction
openFile
--launcher.XXMaxPermSize
256M
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m
--launcher.defaultAction
openFile
-vmargs
-Dosgi.requiredJavaVersion=1.5
-Dhelp.lucene.tokenizer=standard
-Xms40m
-Xmx512m
Resolution:
Re-installing eclipse fixed the problem.
The message above means that you're running so many programs on your PC that there is no memory left to run one more. This isn't a Java problem and no Java option is going to change this.
Use the Task Manager of Windows to see how much of your 4GB RAM is actually free. My guess is that somewhere, you have a program that eats all the memory. Find it and kill it.
EDIT You need to understand that there are two types of "out of memory" errors.
The first one is the OutOfMemoryException which you get when Java code is running and the Java heap is not large enough. This means Java code asks the Java runtime for memory. You can fix those with -Xmx...
The other error is when the Java runtime runs out of memory. This isn't related to the Java heap at all. This is an error when Java asks the OS for more memory and the OS says: "Sorry, I don't have any."
To fix the latter, close applications or reboot (to clean up memory fragmentation).
How to diagnose this error even when running the simple command:
java -version
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Cannot create GC thread. Out of system resources.
# An error report file with more information is saved as:
# /home2/ericlesc/code/java/c2/hs_err_pid23944.log
Check the amount of free memory you have:
free -m
total used free shared buffers cached
Mem: 28119 26643 1475 189 2391 15368
-/+ buffers/cache: 8884 19235
Swap: 5117 34 5083
Check the max number of user processes, make sure you are not over limit:
ulimit -a
ps -ef | wc -l
For me, the reason this happened was because PHP had consumed too much memory allocated to me on bluehost, and the way I was able to fix it, without restarting PHP or the server ( I can't ) was to take the public_html directory and rename it. And give it a minute for PHP to see the change, then rename it back.
A bug in the php engine itself. I found a clever way to give the PHP engine a swift kick.
(update Feb 2016) (I'm getting a spike of up-votes on this because Bluehost instance PHP engines are reserving all the memory and leaving none for the JVM. In their defense, PHP is evolving into an unholy rube Goldberg machine. Bluehost as a service is on the decline.
If you are on ec2 and wanted to do mvn build then use -T option which tells maven to use number of threads while doing build
eg:mvn -T 10 clean package
If you are using Virtual Machine (VM), allocate more RAM to your VM and your problem will be solved.
In your Eclipse installation directory you should be able to find the file eclipse.ini. Open it and find the -vmargs section. Adjust the value of:
-Xmx1024m
In this example it is set to 1GB.
Try to modify your eclipse.ini with below
-startup
plugins/org.eclipse.equinox.launcher_1.3.0.v20120522-1813.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.200.v20120913-144807
-product
org.eclipse.epp.package.jee.product
--launcher.defaultAction
openFile
--launcher.XXMaxPermSize
512M
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
512m
--launcher.defaultAction
openFile
-vmargs
-Dosgi.requiredJavaVersion=1.5
-Dhelp.lucene.tokenizer=standard
-Xms2G
-Xmx3G
-XX:MaxPermSize=2G
-XX:+UseCompressedOops
-XX:+UseParallelGC
Once you open your eclipse you can try below
Looks like your application consumes more memory than allocated (Default). I will try two things
As suggested by Harmlezz increase your memory allocation to JVM to -Xms2g -Xmx2g (If needed increase it more and try it out)
Download eclipse memory analyzer and check for what causing memory leak OR even you can use JConsole to see JVM memory utilization in order to figure out application memory leak issue.
It is quite simple to fix, I am not sure why no one mentioned the actual working solution.
Firstly, make sure, Wireless Hotspot is Turned Off. That's most important, while building the Project, the Hotspot must not be On.
Do this, and Thanks me later đź’–
Secondly, set the Environment Variables into your system, and Thirdly disable the firewall or antivirus for Android Studio & Java VM. It will definately fix your issue.
Starting Gradle Daemon...
Gradle Daemon started in 4 s 291 ms
Starting Gradle Daemon...
Gradle Daemon started in 5 s 664 ms
Starting Gradle Daemon...
Gradle Daemon started in 2 s 210 ms
Starting Gradle Daemon...
Gradle Daemon started in 7 s 258 ms
In my case it was that I manually set the Windows virtual memory too low to save space in the system SSD.
You need to diagnosis the jvm usages like how many process is running and what about heap allocation. there exists a lot of ways to do that for example
you can use java jcmd to check number of object, size of memory (for linux you can use for example "/usr/jdk1.8.0_25/bin/jcmd 19628 GC.class_histogram > /tmp/19628_ClassHistogram_1.txt", here 19628 is the running application process id). You can easily check if any strong reference exists in your code or else.
I know the question talking about eclipse but i got the similar issue many times with Intellij as well and the solution for it was easy .. Just run the 64 bit exe not the 32 one which is always the default one.
In my case it was that the C: drive was out of space. Ensure that you have enough space available.

Eclipse crashing, getting heap exceptions - Out of Memory when trying to deploy an Android applicaiton

I have one Android project that crashes when it is deployed. Other projects in the same workspace work fine. I increased the RAM usage on the AVD that I'm using to 1 GB. I don't think there is a memory leak because it seems to work on other peoples computer.
I'd like to use the Memory Profiler, but the project crashes before launching, and I can't reach the Logcat files.
Right now I'm using eclipse, is there a way for me to launch it using ANT or the command line, where I can execute it step by step and find where the crash is happening?
Any help would be greatly appreciated.
Thank you,
David
david
Try to increase heap size of the eclipse in vm arguments from eclipse.ini file for example by default it will like
-vmargs
-Dosgi.requiredJavaVersion=1.5
-Xms40m
-Xmx512m
You can change something like
-vmargs
-Dosgi.requiredJavaVersion=1.5
-Xms512m
-Xmx1024m
-XX:PermSize=256M
-XX:MaxPermSize=512M

Program throws OutOfMemoryError: Java heap space when run in Mac but not in Ubuntu

This is frustrating. I'm trying to run a program which loads into memory a 4000x3000 image. It runs fine in Ubuntu but not in Mac, throwing an OutOfMemoryError: Java heap space. Here's my eclipse.ini in Ubuntu
-startup
plugins/org.eclipse.equinox.launcher_1.0.201.R35x_v20090715.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.gtk.linux.x86_1.0.200.v20090520
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m
-vmargs
-Xms128m
-Xmx512m
-Dorg.eclipse.equinox.p2.reconciler.dropins.directory=/usr/share/eclipse/dropins
As for Mac
-startup
../../../plugins/org.eclipse.equinox.launcher_1.2.0.v20110502.jar
--launcher.library
../../../plugins/org.eclipse.equinox.launcher.cocoa.macosx_1.1.100.v20110502
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m
--launcher.defaultAction
openFile
-vm
/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home/bin/java
-vmargs
-Xms128m
-Xmx512m
-Xdock:icon=../Resources/Eclipse.icns
-XstartOnFirstThread
-Dorg.eclipse.swt.internal.carbon.smallFonts
Note that I've tried increasing the PermSize memory Xmx and Xmx of Mac to around 1024m but Mac still throws OutOfMemoryErrors. I only tried making them similar because, well, it runs in Ubuntu just fine.
Any suggestions?
Thanks!
These are your settings for eclipse, not for your program (I'm assuming you're not building it as an Eclipse component). Your program will run with the default settings unless you specify differently in your Run configuration.
The defaults java starts with depend on multile factors, like architecture, OS, and available RAM. So it's entirely possible that it would start with a lower memory limit on your mac.
To fix this, set Xmx to be the same on both systems (Also make sure they're on the same architecture, 64 bit apps might require more memory to do the same thing).
First, your error is about heap space, so changing Perm space isn't going to affect it.
Second, as Joeri pointed out, the eclipse.ini file affects how Eclipse itself runs, not programs that you write and run from inside Eclipse.
On your Launch Configuration, go to the Arguments tab and enter the -Xmx argument in the box labeled VM Arguments.
If you know for certain that you always want all your Launch Configurations to run with certain heap space arguments, you can assign them to the JRE. Open Eclipse Preferences and find Java > Installed JREs. From there, select the JRE that you want to work with, click the Edit button, and there you'll find a Default Vm Arguments field. If you set -Xmx there (or any other JVM arguments), they will affect any Launch Configuration that uses that JRE.
Increase the value of -Xmx parameter

Java - OutOfMemoryError: PermGen space

I'm currently developing a tool allowing me to get statistics from anyware simply by going on a website I also created.
For those who don't know, Birt is a reporting tool, and an eclipse plugin.
My problem is the following :
I installed tomcat on the server hosting my website, and installed the Birt ReportEngine on it, and on my website, I call the online viewer to get my reports.
The problem is that since yesterday, when I launch a report, I have this error :
javax.servlet.ServletException: L'exécution de la servlet a lancé une exception
org.eclipse.birt.report.filter.ViewerFilter.doFilter(ViewerFilter.java:68)
Caused by :
java.lang.OutOfMemoryError: PermGen space
I don't really know which config file to modify to avoid this error. I found some examples online that tell to modify the eclipse.ini file, but as for mty website, I don't use eclipse, I didn't found any usefull post.
Can someone help me please ?
Thanks
As said by Thomas, the parameter to set is -XX:MaxPermSize. One way of setting this parameter for Tomcat is to use the CATALINA_OPTS environment variable.
For Windows :
set CATALINA_OPTS=-Xms512m -Xmx512m -XX:MaxPermSize=256m
For Linux (bash) :
export CATALINA_OPTS="-Xms512m -Xmx512m -XX:MaxPermSize=256m"
Check the startup.bat and catalina.bat or startup.sh and catalina.sh files in your tomcat/bin directory and add the above commands there.
(The Xmx and Xms parameters set the minimum and maximum size for the Java heap - where objects are stored. This is not the problem you have but I included them for the sake of completeness.)
You need no add the following line to eclipse.ini
-XX:MaxPermSize=128m
If the problem occurs again try to increase the value. You can also add the following optional lines:
-XX:+UseConcMarkSweepGC
-XX:+CMSClassUnloadingEnabled
-XX:+CMSPermGenSweepingEnabled
-XX:+UseParNewGC
This changes the Garbage Collector of the JVM to a more optimized one, and can also improve the performance and memory usage.
You may also want to tweak the values of the -Xmx and Xms options. Try small increases (same to the -XX:MaxPermSize) as this will increase the memory footprint of your JVM.
For a more explained details see here:
http://www.eclipsezone.com/eclipse/forums/t61618.html
For a complete list of the JVM parameters and options:
http://www.oracle.com/technetwork/java/javase/tech/vmoptions-jsp-140102.html
Use that JVM option: -XX:MaxPermSize=256m (of course you are free to choose the amount of memory, but IIRC the default would be 64m so you'd need to increase that). - Note that this is for Oracle's JVM (formerly SUN's :) ) , other JVM's might have different options.
Other than that, try not hot deploying too much, since that might also increase the PermGen space usage (JBoss which includes Tomcat as has that problem, but I'm not sure whether that is true for a standalone Tomcat).
This can be solved by allocating more heap memory.
this can be done as:
steps:
double click on your eclipse server->open launch configuration->Arguments->paste this line in vm arguments text area:-
-XX:MaxPermSize=512M -Xmx1024M
This will solve your outofmemory error.
I added the below line line to eclipse.ini and working fine for me.
-startup
plugins/org.eclipse.equinox.launcher_1.0.201.R35x_v20090715.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.0.200.v20090519
-product
org.eclipse.epp.package.jee.product
--launcher.defaultAction
openFile
--launcher.XXMaxPermSize
256m
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m
--launcher.defaultAction
openFile
-vmargs
-Dosgi.requiredJavaVersion=1.5
-Xms40m
-Xmx512m
-XX:MaxPermSize=256m

Categories

Resources