When running a Java program in eclipse, an outofmemory error is often generated. This error is caused by insufficient memory of the Java Virtual Machine. How to configure Java Virtual Machine memory?
You can use either of the following methods:
1. Directly configure the JRE parameters as follows:
Find eclipse Windows> preference> JAVA> installed jres to view the JRE file used by eclipse. Double-click the installed JRE file to edit the installed JRE file. For example:
The setting affects the memory of the Java Virtual Machine of the project in exlipse.
Ii. settings of the current running program
The setting of the memory of the virtual machine of the currently running program only affects the current running program, not global.
The procedure is as follows:
Method 1: Right-click the main program class of the running program and choose run> runconfigurations> arguments> vmarguments to set the memory size of the Java Virtual Machine. As follows:
-The xmx parameter is used to set the maximum memory size.
-XMS is the minimum memory used.
The two parameters can be used at the same time or separately.
Method 2: set from the eclipse shortcut key:
Right-click the eclipse shortcut, select properties, and add-vmargs-xmx192m to the target text to set the maximum memory usage for Java Virtual Machine initialization to 192 MB, or set it to another value.
As follows:
2. Set from the project
Right-click the project and choose Properties> JAVA editor> Run/debug settings> double-click the project master program. The configuration editing box is displayed. :
As follows: