Beginners are very easy to confuse the role of the Eclipse.ini file, this file is the Eclipse software configuration file, configured Eclipse boot, Eclipse is written in Java, only with the IBM own SWT (Standard Widget Toolkit is an open-source GUI programming framework that has similar uses to Awt/swing, and the minimum memory and maximum memory set here are reserved for the virtual machine that started the Eclipse program. We want to modify the JVM memory size of Java programs in eclipse This setting is not working.
There are two ways to do this:
First, Modify the JDK to use memory :
Find eclispe in window->pref erences->java->installed JRE , click edit on the right button, in the edit interface, in the "-xms64m-xmx128m , specific:
650) this.width=650; "Width=" 606 "height=" 381 "src=" http://hi.csdn.net/attachment/201006/24/0_12773490526E60.gif "/ >
The settings here affect the memory of the Java Virtual machine for the entire Exlipse project.
Second, Modify the Run configurations
code right-click on "run as "-> " run configurations "in arguments parameter" VM Arguments: "Fill in the following values.
-xms64m-xmx128m
650) this.width=650; "width=" 558 "height=" 517 "src=" http://hi.csdn.net/attachment/201006/24/0_1277349607P12F.gif "/ >
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:
650) this.width=650; "Width=" 554 "height=" 439 "src=" http://hi.csdn.net/attachment/201006/24/0_1277349916kYnP.gif "/ >
650) this.width=650; "width=" 670 "height=" 404 "src=" http://hi.csdn.net/attachment/201006/24/0_1277349945cU4s.gif "/ >
1 and 22 methods are equivalent
Note: Thejdk and run configurations two places are set, the function is Run configurations, the equivalent of a parent-child inheritance relationship, Subclass overrides the configuration of the parent class
third, query the current JVM memory code
below is the code that queries the current JVM memory size. You 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 ()); } /** * get current jvm memory information * * @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)" ; } }
This article is from the "dream belongs to the brave-Skywalker" blog, please be sure to keep this source http://tianxingzhe.blog.51cto.com/3390077/1651525
Set JVM memory in eclipse