Skip to main content

Java Heap Space Exception, One of Weired Issue for Java Developer

Running Java application requires a lot of memory to load, execute and running. When you run one of the Java application, it does not only your application need memory but the web container such as Tomcat also required.

It is more annoyed for you as a developer that you use many development tools that running on JVM such as Maven, Eclipse IDE, Tomcat and other stuffs.

The memory firstly is about your RAM, regularly, you might have only 8GB RAM as normal as mine that I though it's enough but usually, it's not.
Let's look to your Eclipse, the autocomplete code there, number of Java files and other automatic stuffs you do on the IDE that keeps you slowing everytimes; So that by theory, 8GB still not enough to go.

Java heap issue can be solved by setting the right use of the memory as following way:

-Xms<size> - Set initial Java heap size
-Xmx<size> - Set maximum Java heap size

Example:
java -Xms512m -Xmx1024m JavaApp

But never forget to calculate how much memory you need for your application but I just still get difficulty to find out how much I really need.

Time by time, I just adapt the Xmx parameter as example on my eclipse.ini that I have been using it to launch even the Tomcat there.
And more, I tried to put more option to track the heap dump so I added following parameters into my eclipse.ini

-XX:+HeapDumpOnOutOfMemoryError
-XX:HeapDumpPath=/home/abc/eclipse-luna/heapException

You might experience the same thing, let's share your though, solution or idea to get out easily on this matter together.
Or do I need to increase more RAM again?
Or how much memory setting do we need to set for around 100MB project source size of 3 projects on eclipse?

I just got stuff from my quick though during my stuck time...
Good luck on your side.

Comments

Popular posts from this blog

Java Web Frameworks Comparison: Spring MVC, Grails, Vaadin, GWT, Wicket, Play, Struts and JSF

Web Frameworks are all very different and have been typically created for different reasons and to achieve different goals. Which Java Web Framework will you use in your next project and why would you chose one over the other? Watch the video of this comparison: Thank to  http://zeroturnaround.com/

US warns on Java software as security concerns escalate

The U.S. Department  of Homeland Security urged computer users to disable Oracle Corp's Java software, amplifying security experts' prior warnings to hundreds of millions of consumers and businesses that use it to surf the Web. Hackers have figured out how to exploit Java to install malicious software enabling them to commit crimes ranging from identity theft to making an infected computer part of an ad-hoc network of computers that can be used to attack websites. "We are currently unaware of a practical solution to this problem," the Department of Homeland Security's Computer Emergency Readiness Team said in a posting on its  website  late on Thursday. "This and previous Java vulnerabilities have been widely targeted by attackers, and new Java vulnerabilities are likely to be discovered," the agency  said . "To defend against this and future Java vulnerabilities, disable Java in Web browsers." CERT's instructions on how to do so ...