6

I'm using Eclipse to run java program class, while I run it i got this error

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

then i changed the VM from the Properties > Run > VM Options, and I run the program again i got a new error,

Error occurred during initialization of VM
Incompatible initial and maximum heap sizes specified

I'm trying to apply stanford libraries in my program, any idea how to solve this error .

7
  • That means you allocated too much memory. Without seeing the code, I can't tell you much more than that... Commented Feb 27, 2012 at 4:21
  • What did you changed in VM options? Commented Feb 27, 2012 at 4:23
  • 1
    i change the size of the memory, at the beginning I used 50m memory, then when the first msg comes to me i change the vm to 512m i got the second msg Commented Feb 27, 2012 at 4:31
  • can you add java program class Commented Feb 27, 2012 at 4:35
  • 1
    I added, all the classes can't run when i change the VM to 512m Commented Feb 27, 2012 at 4:36

3 Answers 3

7

to change the VM for Eclipse you can change the amount of the MV from Windows> Preferences> Java> Installed JREs from there select the JRE and click edit, then write in the Default VM Arguments: to -Xmx1024M or any other amount of memory ...

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

1 Comment

What is the max amount of memory I can add?
2

Error occurred during initialization of VM. Incompatible initial and maximum heap sizes specified

This probably means that you supplied both -Xms and -Xmx options, and the -Xms (initial heap size) value is larger than the -Xmx (maximum heap size) value.


netbeans provide to change the -Xms only from Properties > run > VM options

I'm not a NetBeans user. However, a brief search of the Using NetBeans 5.0 manual says this is not correct:

Setting JVM Arguments

You can specify JVM arguments for the project in the Project Properties dialog box. Open the Project Properties dialog box and click Run in the Categories pane and then type a space-separated list of JVM arguments in the VM Options field.

In other words, you can set any JVM option that your JVM supports.


here is the string that i changed -Xms512m

(Finally he tells us!!)

Add -Xmx512m as well.

For the record, the common JVM options (such as -Xmx and -Xms) are clearly documented in the manual page for the java command. You should READ it CAREFULLY.

3 Comments

I'll guess he/she forgot an 'm' suffix in the Xmx
netbeans provide to change the -Xms only from Properties > run > VM options, how i can change the -Xms in netbeans..
I'm trying to run a program which contain ENR stanford nlp, and wheni try to run the first error msg appear, so i change the VM to 512m and the other error comes which appears in the question ..
0

To enlarge the VM heap size use -Xmx option, this could solve the error. But it seems it's your coding problem. Perhaps code is in a dead loop to create new object, or a very large object is created in you code, so I suggest you to check code first.

1 Comment

the error comes when I try to run Entity Named Recognition "stanford NLP" for the other features, the program run smoothly

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.