1

Hi I am partially testing an application and It has a problem with heap space. Here is sample code

public class Test {


Test()
{
    byte[] b = new byte[744678306];
}


public static void main(String[] args) {
    // TODO Auto-generated method stub
    Test t=new Test();
}

}

Error

Exception in thread "main" java.lang.OutOfMemoryError: Java heap space

Here is eclipse ini configuration

-startup
plugins/org.eclipse.equinox.launcher_1.3.0.v20130327-1440.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.gtk.linux.x86_1.1.200.v20130807-1835
-product
org.eclipse.epp.package.jee.product
--launcher.defaultAction
openFile
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m
--launcher.defaultAction
openFile
--launcher.appendVmargs
-vmargs
-Dosgi.requiredJavaVersion=1.6
-XX:MaxPermSize=256m
-Xms800m
-Xmx999m

Working env : ubuntu 12 on vBox.

Thanks advance.

1
  • You're welcome in the past. Commented Nov 6, 2013 at 19:22

4 Answers 4

4

You are asking for space for about 750MB, but your program starts with a maximum allowed of 256,

Take a look at this

Just add -Xmx2048M (for 2048 MB, you can change that number) in the list of VM arguments in the corresponding run configuration.

Sign up to request clarification or add additional context in comments.

3 Comments

so should I change -XX:MaxPermSize=800m ?
No. Eclipse memory configuration has nothing to do with executed program heap.
Sorry, I hadn't pasted the link correctly. Take a look at it now, there you will find an explanation on how to increase the heap size permitted.
2

The Eclipse startup configuration which you have pasted has nothing to do with your problem. Eclipse does not execute your code in its own JVM; it starts a separate JVM with the arguments you explicitly specify within Eclipse.

After you run the application once, a Run Configuration entry will be created for it. Go to that entry (Run -> Configurations...) and, under VM arguments, specify more memory with -Xmx. By default, Java 7 sets mx to 1 GB or a quarter of the total RAM, whichever is less.

Comments

1

For avoiding the out of memory error do the following steps. Eclipse -> run -> run configuration -> arguments. Then in VM arguments type as below.

-XX:MaxHeapSize=1024m 

You can specify your own memory size.

Comments

0

I think you don't have many parameter in eclipse.ini

This is the best configuration for Eclipse NEON and o.s. Windows 10 with 4GB of Ram:

-startup
plugins/org.eclipse.equinox.launcher_1.3.201.v20161025-1711.jar
–launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.401.v20161122-1740
-product
org.eclipse.epp.package.jee.product
–launcher.defaultAction
openFile
–launcher.XXMaxPermSize
256M
-showsplash
org.eclipse.platform
–launcher.XXMaxPermSize
256m
–launcher.defaultAction
openFile
-vm
C:/Program Files/Java/jdk1.8.0_121/bin/javaw.exe
–launcher.appendVmargs
-vmargs
-Dosgi.requiredJavaVersion=1.8
-Xms256m
-Xmx512m
-XX:PermSize=256m
-XX:MaxPermSize=512m

If you have 8GB of Ram modify -XX:PermSize=512m and -XX:MaxPermSize=1024m. For complete example see here.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.