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:
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.
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.
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 * |