Set JVM memory __eclipse in eclipse

Source: Internet
Author: User

800x600 Normal 0 7.8 lb 0 2 false false en-US ZH-CN x-none

Eclipse set JVM memory in

Today, in Eclipse, when you test a document into a picture, the following error is reported:

Java.lang.OutOfMemoryError:Java Heap Space

As you can see from the above exception information, the JVM needs to use more memory than we can use to allocate to the virtual machine. So the question translates to how to set the maximum memory for the JVM in Eclipse.

One, attempt to modify the Eclipse.ini file (this method is not possible)

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

-xms40m

-xmx512m

After the modification, restart Eclipse and find that it doesn't work at all. After looking at some data, the minimum and maximum memory set here is not intended for use by the JVM, which contains the memory that eclipse itself uses.

Second, Modify JDK usage memory (this method works)

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 editing interface, fill in the following values.

-xms64m-xmx128m

 

Third, Modify Run configurations (this method works)

Right-click on the code, clicking "Run as"-> "Run Configurations", and in the arguments parameter "VM arguments:" Fill in the following values.

-xms64m-xmx128m

Four, querying the current JVM memory code

The following is a code that queries the current JVM memory size to test whether the JVM's memory will change after the above settings. After you increase the configuration entries for the JVM memory, you do not need to restart eclipse. The specific code is as follows:

public class testmemory {

 

&nbs p;  /**

      * @param args

      * /p>

    public static void main (string[] args) {

       System. Out. println ("Memory Information:" + tomemoryinfo ());

   }

 

   /**

      * Get memory information for the current JVM

      *

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.