"Go" increases Eclipse's running memory--good!!

Source: Internet
Author: User

Original URL: http://blog.csdn.net/qa962839575/article/details/43605241

The following error was reported when testing the conversion of a document to a picture in eclipse today:

Java.lang.OutOfMemoryError:Java Heap Space

As you can see from the exception above, the amount of memory that the JVM needs to use exceeds the maximum memory we can allocate to the virtual machine. So the question turns into how to set the maximum memory for the JVM in Eclipse.

First, try to modify the Eclipse.ini file (this method does not work)

Locate the Eclipse.ini file under the Eclipse directory and modify the following:

-xms40m

-xmx512m

After modification, restart Eclipse, and the discovery does not work at all. After looking at some of the information, the original set of the minimum memory and maximum memory is not used for the JVM, this memory value contains the memory used by eclipse itself.

Second, modify the JDK to use memory (this method is feasible)

Locate the window->preferences->java->installed JRE in Eclispe, click the Edit button on the right, and in the "Default VM Arguments" option in the Edit interface, fill in the values below.

-xms64m-xmx128m

Third, modify the run configurations (this method is feasible)

Right-click on "Run as" and "Run Configurations" in the code and fill in the following values in "VM arguments:" In the arguments parameter.

-xms64m-xmx128m

Your own operation:-xms512m-xmx1024m

Iv. querying current JVM memory code

The following is the code that queries the current JVM's memory size and can test whether the JVM's memory changes after the above settings. After adding configuration items for JVM memory, you do not need to restart eclipse. The specific code is as follows:

Public class testmemory {

/**

* @param args

*/

Public static void main (string[] args) {

System. out. println ("Memory Information:" + Tomemoryinfo());

}

/**

* Gets the memory information of the current JVM

*

* @return

*/

Public Static String Tomemoryinfo () {

Runtime currruntime = runtime. GetRuntime ();

int nfreememory = ( int ) (currruntime.freememory ()/1024/1024);

int ntotalmemory = ( int ) (currruntime.totalmemory ()/1024/1024);

return nfreememory + "m/" + ntotalmemory + "M (free/total)";

}

}

"Go" increases Eclipse's running memory--good!!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.