Out of memory exception while compiling GWT project - java

As I didnt get any solution from previous similar question,I am raising this issue.
I have 8GB RAM,32 bit window 7 os,32 bit eclipse and 32 bit JVM. I used to compile my GWT project successfully.But after adding some uploading and mobile-related jars,I get this Out of memory exception while compiling this project.
I have tried to change the VM arguments,but got no success.Then I moved to 64 bit OS,64 bit eclipse,64 bit JVM, and tried to assign more Xmx parameter in the vm argument,but its not taking more than 1.5GB where as I have 8 GB RAM,Hence no success while compiling. Need Help!!

This is because, you may be using lots of servlets or GWT files.
As far as you are using 64bit OS this should work with -Xmx 4096m. Try
checking the path sometimes the JRE path will be pointing to x86 if
so change to JRE installed on x64.
If the VM arguments is not working for more than 2048m then probably
it will be a issue with JRE(for x86) or OS architecture(x86).

If you are using maven to compile your gwt code :
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
...
<configuration>
<extraJvmArgs>-Xmx2048m</extraJvmArgs>
</configuration>
</plugin>
I hope this can help you.

Changing to 64 bits was the right thing to do, but you have to make sure that Eclipse is using the right version of Java.
Check if you're pointing to the right version of Java in Window > Preferences > Java > Installed JRE

I have 8GB RAM,32 bit window
Fail. 32-bit operating system can technically only managed a maximum of 4 GB of RAM

Related

Eclipse intermittently fails to create the Java Virtual Machine

I am using Windows 7 32-bit OS. I am using Eclipse 3.7 (Indigo) 32 bit. I have jdk1.7.0_07 32-bit installed. And sometimes when I go to run Eclipse as administrator, I get the following error message,
And when I tap "OK", I get the following error message,
And sometimes I get this error message. And at other times, Eclipse will launch, but fail when Gradle goes to initialize its VM when attempting to start its daemon process.
What's happening? I realize it's a memory issue, but why am I able to launch Eclipse once in a while and run everything just fine? And at other times, why I am able to launch Eclipse but not able to run anything, or unable to launch Eclipse at all?
As a developer, this behavior is a nuisance.
Try -Xmx900m. The problem might be with the eclipse.ini file.
I've had this problem with JDK7. I've found that i do better with eclipse if it runs under Java 6, and then you add JDK7 as the runtime environment for your project.
Make sure that your eclipse matches your jre/jdk bitwise. If you are using 32-bit eclipse, you must use 32-bit jdk.
Your -vm param is wrong. The arg must start on the next line like this:
-vm
c:\Program Files\java... etc
When the JVM (Sun's JVM) starts it allocates the heap as a single malloc, a single contiguous block of memory. If, for any reason, that much contiguous memory is not available then the JVM will not start. Without debugging your machine is hard to know what could be blocking a big malloc. Note that some viruses recently have been taking shelter inside the jvm.
you said that your's is a 32 bit os is you your eclipse is 32 bit compatable or 64 bit if it is 64 bit remove the java related folder in your eclipse and replace it with 64 bith java sdk this will work i got this problem and i got it solved in this way.

“Error occurred during initialization of VM; Could not reserve enough space for object heap” using -Xmx3G

First of all, I have a box with 8gb of ram, so I doubt total memory is the issue.
This application is running fine on machines with 6gb or less.
I am trying to reserve 3GB of space using -Xmx3G under "VM Arguments" in Run Configurations in Eclipse.
Every time I try to reserve more than 1500mb, I get this error:
“Error occurred during initialization of VM; Could not reserve enough space for object heap” using -Xmx3G
What is going on here?
Could it be that you're using a 32-bit jvm on that machine?
Here is how to fix it:
Go to Start->Control Panel->System->Advanced(tab)->Environment Variables->System
Variables->New:
Variable name: _JAVA_OPTIONS
Variable value: -Xmx512M
Variable name: Path
Variable value: ;C:\Program Files\Java\jre6\bin;F:\JDK\bin;
Change this to your appropriate path.
This is actually not an Eclipse-specific issue; it's a general
Java-on-Windows issue. It's because of how the JVM allocates memory on
Windows; it insists on allocating a contiguous chunk of memory, which
often Windows can't provide, even if there are enough separate chunks to
satisfy the allocation request.
There are utilities that will try to help Windows "defrag" its memory,
which would, in theory, help this situation; but I've not really tried
them in earnest so can't speak to their effectiveness.
One thing that I've heard sometimes that might help is to reboot Windows
and, before starting any other apps, launch the Java app that needs the
big chunk of memory. If you're lucky, Windows won't have fragmented its
memory space yet and Java will get the contiguous block that is asks for.
Somewhere out on the interwebs there are more technical explanations and
analyses of this issue, but I don't have any references handy.
I did find this, though, which looks helpful: https://stackoverflow.com/a/497757/639520
First the JRE of 32bits can't use more ~1.5Gb of ram. So if you want more, use a 64bits JRE.
Second, When a new JVM starts, this sum the -Xmx property of the all JVM that are running, and check if there is enough memory left on the system to run at their own -Xmx, if is not enough then the error occurs.
I was using Liferay with Tomcat server from eclipse IDE.
I was stuck with this same error on click on server start up.
Double click on server from eclipse.
it open up Server Overview page. Updated memory arguments from -Xmx1024m -XX:MaxPermSize=256m to -Xmx512m -XX:MaxPermSize=256m.
Then it was working for me.
Make sure that Eclipse is actually running the same JVM you think it's running. If you use java in your web browser ever, you likely have a 32-bit version floating around too that might be taking precedence if it installed or updated lately.
To be absolutely sure, I recommend adding these two lines to your eclipse.ini file at the top:
-vm
C:/Java/jdk1.6.0_27/bin
...where on my machine C:/Java/jdk1.6.0_27/bin where the JVM I know is 64-bit is located. Be sure to have the bin folder there.
(As a bonus, on Windows 7, this also allows you to actually "pin the tab" which is why I had to do this for my own usage)
This is the issue of Heap size. Edit your .bat (Batch file). It might be showing Heap size 1024. Change it to 512 Then it should work.
Just put # symbol in front of org.gradle.jvmargs=-Xmx1536m in gradle.properties
# org.gradle.jvmargs=-Xmx1536m
I also had the same problem while using Eclipse which was 32 bit and the JVM used by it was 64 bit.
When I routed the Eclipse to 32 bit JVM then it worked
I know that i am a bit late, but here my answer comes:
I just installed the Java online Version from Oracle(not the offline 64-Bit one).
After having added the JAVA_HOME ENV variable, it just worked!
Hope I could help :)
Probably you are trying wrong options anyways.
I got a similar error with supporting error log:
Java HotSpot(TM) Client VM warning: ignoring option PermSize=32M; support was removed in 8.0
Java HotSpot(TM) Client VM warning: ignoring option MaxPermSize=128M; support was removed in 8.0
Im my case, the software did not support java 8 yet(script was using old JVM arguments) but I had had java 8 by default.
One of the reason for this issue is no memory available for Tomcat to start. Try to delete the unwanted running software from windows and restart the eclipse and tomcat.
Solution is simple. No need to go deep into this issue.
If you are running on 64bit machine then follow below steps:
Unistall 32 bit java first (check in C:\Program Files (x86) for its existence)
Install the newer version JDK kit 64 bit (includes JRE)
Set the environment path (To avoid conflict error if you have two different 64bit JRE)
Check in command prompt by typing javac command.
Restart / Done
You can have two different Java installed but don't forgot to set path.
Please set JAVA_OPTS=-Xms256m -Xmx512m in environment variables, it should solve the issue, it worked for me.
Find out if you are using a 32bit version or 64bit version of Java. To know that use the command
java -version
The 3rd line of the output should give you if it 32bit or 64bit.
If it is 32bit uninstall and install a 64bit version.

Known Tomcat 6.0 and JDK 1.7.0_02 issues?

Are there known Tomcat 6.0 and JDK 1.7.0_02 issues?
I know this is a hard question to answer, if the answer is no. But I need to ask just in case the answer is yes. Also I will accept any solutions to the issues below as answers. Please just share whatever issues you have had, and I will update this question if need be.
Issues:
Some issues I have run into since upgrading from JDK 1.7.0 to 1.7.0_02 (which I did to avoid the Eclipse's help menus from crashing, due to a Java 1.7.0 bug.):
Tomcat server takes much longer to start, I need a 120 second timeout to handle it.
FATAL ERROR in native method: JDWP No transports initialized, jvmtiError=AGENT_ERROR_TRANSPORT_INIT(197) error, which disappeared the next day and then reappeared the third day, with no changes other than reloading Eclipse.
Tomcat server takes much longer to shut down. I need a 60 second timeout to handle it, from 15 second default.
Eclipse itself appears to crawl to a halt (figuratively speaking) upon building the workspace and validating the project at hand. Everything within Eclipse appears to take longer, even opening an unopened file.
Everything seems suspicious.
P.S. JDK 1.7.0_02 is also known as 1.7.0u2, Java SE 7u2, Java SE 7 Update 2, etc.
Versions:
JDK = Oracle, 64-bit, downloaded from http://www.oracle.com/technetwork/java/javase/downloads/index.html. Exact file downloaded and installed was jdk-7u2-windows-x64.exe.
Tomcat = Tomcat 6.0.33, downloaded separately from Eclipse
Eclipse = Eclipse Java EE IDE for Web Developers., Version: Indigo Release, Eclipse Platform, Version: 3.7.0.v20110530-9gF7UHNFFt4cwE-pkZDJ7oz-mj4OSEIlu9SEv0f, Build id: I20110613-1736.
64-bit Windows 7 machine, 8GB RAM, Intel Core i7-2600 CPU # 3.4GHz (4 cores)
Eclipse, Tomcat, Apache HTTP Server, are all on the same (development) computer.
EDIT: Added system specs above.
When running 64 bits Java with default options (references compaction is off by default), it requires almost twice the amount of memory than with 32 bits.
For Eclipse, open the eclipse.ini file and double/increase a lot the -Xmx option.
Of course, your physical memory may not be enough when running some JVMs.
So I recommend you to test the -XX:+UseCompressedOops HotSpot option with 64 bits JVM and monitor memory usage thanks to jconsole for instance. You can also read details about that recent option. That option
For Tomcat, create the file bin/setenv.bat with content:
set JAVA_OPTS="-Xmx1024M -XX:+UseCompressedOops"
Well, perhaps it's all about the new JVM released in that update. It alledgedly improves performance but... well, who knows. JDT on Tomcat6 interacts with JDK 1.7 so unexpected things could happen.
Other than that, there're few things to check.

java heap space

do you have any idea why I could get a 'Exception in thread "main" java.lang.OutOfMemoryError: Java heap space' error when building my android app, even though I added -vmargs -Xmx1024M -Xms512M to the eclipse arguments ?
I would like to know what error could I have made that would trigger such an error at build time, as it would appear to me that only a bug in eclipse or maven could produce such an error at build time.
I am using run as maven install to build my application (with the maven android eclipse plugin). Run as-> 'maven package' also produces the same build failure, after waiting roughly 1min30.
I have a desktop computer with 3GB of memory, and my application isn't nearly that big.
Thanks.
Add -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/some/path to your jvm args so that when it runs out of memory it will dump out the heap. You can then use Eclipse Memory Analyser or jhat to browse the heap and diagnose where the problem might be.
Update: Try increasing the memory of your maven android plugin. In your pom.xml, add a JVM argument for Xmx to the plugin configuration:
<plugin>
<artifactId>maven-android-plugin</artifactId>
<configuration>
<jvmArguments>
<argument>-Xmx1500m</argument>
</jvmArguments>
</configuration>
</plugin>
Your Eclipse JVM arguments do not matter. You have to increase the heap of the compiler.
I am quoting http://javahowto.blogspot.com/2006/06/fix-javac-java-lang-outofmemoryerror.html
If [...] you're running Eclipse, go into your "run As" dialog for your Build.xml and add -Xms256m -Xmx256m to the "VM Arguments" text box
I experienced this Conversion to Dalvik format failed: Unable to execute dex: Java heap space. increasing the all of the values in the eclipse.ini file didn't help. This happened to me after I upgraded my ADT plugin from 12 to 16. I changed the Android SDKs that were pointed to my existing projects prior to the upgrade (from the android sdks that were connected on my previous adt I changed them to the android sdks that were connected to my new adt) and it solved the issue for me. hope this helps. and if it helps someone please vote for plus 1 this.
If increasing does not respond then I would suggest to you that check the line count for each class you wrote. It can be a compiler problem if there are a lot of objects so try to partitioning methods and/or copy them into new classes if one or more of the classes have 3000+ lines.

JVM terminates when launching Eclipse MAT on Mac OS with J2SE 6.0

I have recently discovered the incredibly useful Eclipse Memory Analysis Tool, which makes quick work of finding memory leaks in Java applications. Unfortunately, after switching my JDK to 1.6 (under Mac OS 10.5), the JVM terminates immediately upon startup. All that appears is a dialog stating "JVM terminated" with "Exit code = -1".
Anyone else encounter this one? Perhaps there is a way to configure it to use a different JDK? (such as 1.5: which it was shown to be compatible with)
To configure Eclipse to use another VM use this command line:
eclipse -vm <path to java>
You can also specify the path in Eclipse.app/Contents/Info.plist. There is a section like this:
<!-- to use a specific Java version (instead of the platform's default) uncomment one of the following options:
<string>-vm</string><string>/System/Library/Frameworks/JavaVM.framework/Versions/1.4.2/Commands/java</string>
<string>-vm</string><string>/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Commands/java</string>
-->
For the Memory Analyzer the you can find the Info.plist file under MemoryAnalyzer.app/Contents.
The official Java 6 for the Mac only has a 64 bit data model. Unfortunately, Eclipse uses Carbon on the Mac which is only available in 32 bits. In short, it is impossible to run Eclipse with the official Java 6 distribution.
The classical solution to this is to set the default VM to Java 5, and then choose Java 6 as the JRE/JDK within Eclipse.
If you really need to run Eclipse with Java 6, then you could take a look at SoyLatte which is a build of OpenJDK which both supports 32 and 64 bit modes.

Categories