Eclipse and Java heap space (plus .dll)!!!

来源:互联网 发布:mysql数据库搭建 编辑:程序博客网 时间:2024/05/16 05:34

I got this problem "java.lang.OutOfMemoryError: Java heap space" a lot and search a lot these days, just because there are recursive calls in my program. Many people have suggested the options:

 

1, change file "eclipse.ini" for the values of this part "-Xms40m-Xmx256m";

 

2, command line input: "eclipse -vmargs-Xms256m-Xmx50g".

 

(See how much memory I specified? 50g!)

 

I once thought they worked, especially the second one. I just realized that the second one did not, because eclipse never complains, even if I set 50g for the heap size (while my slow machine only has poor 2g memory). I remember that some lab machines do say that it cannot create JVM because the heap size I specified is too big when I use command line setting. Maybe that is the version problem. The eclipse in my machine is 3.2 while the  lab one is latest (), which you do can set the size in command line.

 

I switch to the setting in the Run configuration window of the program I want to run (The second text field special for "VM arguments"). It worked, and complained when I set even over 1208m, considering my physical memory is just 2g. It seems really to be the place to specify the heap size of JVM for the program that you are running, instead of every program in eclipse. And I think it is better to specify it here instead of setting the whole eclipse or the "default" JVM for your whole system.

 

=====================================

 

I got another problem for a ".dll" used in eclipse. Mostly when writing Java program, I just import the ".jar" package. But there is an old program that uses a ".dll" and when I imported the whole program as a projuect, there are some reference error. I did not know where to specify the position of this ".dll" file until I googled.

 

In the "Java Build Path"--"Libraries", click the ".jar" file you added before. There is a Native library location. That is the place to enter the location of the ".dll" file, with such a prompty "Enter the location of a folder containning the native libraries used by 'xxx.jar':"!!