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