Set JVM memory in eclipse

Source: Internet
Author: User
Tags xms

First, modify the jdk to use memory :

  find eclispe window-> Preferences->java->installed JRE, click on the edit button on the right, in the edit interface " specific:

The settings here affect the memory of the Java Virtual machine for the entire Exlipse project.

-xms is the minimum allocated memory for setting up a Java Virtual machine;-xmx is the maximum allocated memory;512m is the memory space

The General-xmx is set to 1/4 of your computer's physical memory, and the-XMS and-XMX are set to the same

In fact, you can set up a little more, as long as the system can allocate enough memory, if you set a large system will prompt you.

Second, Modify the Run configurations

1. 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

2. Set up from the project

Right-click the project, select Properties->java editor->run/debug settings-> Double-click the project main program. The configuration edit box is displayed:

1 and 22 methods are equivalent

Note: TheJDK and run configurations are set up in two places, and the function is run configurations, which is equivalent to parent- child inheritance, with subclasses overriding the parent class's configuration

Third, query the 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:

 package   com.springTest.reference;  public  class   jdkmemorytest { public  static  void   main (string[] args) {        Runtime currruntime  = Runtime.getruntime ();  long  nfreememory = currruntime.freememory ()/1024/1024;  long  ntotalmemory = currruntime.totalmemory ()/1024/1024; SYSTEM.OUT.PRINTLN ( Memory Information: freememory= "+ nfreememory +" M, totalmemory= "+    Ntotalmemory); }}

This article is from the "bit accumulation" blog, please be sure to keep this source http://tianxingzhe.blog.51cto.com/3390077/1651525

Set JVM memory in eclipse

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.