On Windows, I could change how much RAM Java could use by typing something like -Xincgc -Xmx2048M in the Java Runtime Parameters. How can I do that in Ubuntu?
If I am not mistaken they are the same in Linux. With the Java command you have the 2 options:
- Xmx sets the maximum memory heap size.
- Xms sets the minimum memory heap size.
-Xmx1024m -Xms128m should work.
Here is an extract from doing a
man java in the terminal
-Xmsn Specify the initial size, in bytes, of the memory allocation pool. This value must be a multiple of 1024 greater than 1MB. Append the letter k or K to indicate kilobytes, or m or M to indicate megabytes. The default value is chosen at runtime based on system configuration. For more information, see HotSpot Ergonomics Examples: -Xms6291456 -Xms6144k -Xms6m -Xmxn Specify the maximum size, in bytes, of the memory allocation pool. This value must a multiple of 1024 greater than 2MB. Append the letter k or K to indicate kilobytes, or m or M to indicate megabytes. The default value is chosen at runtime based on system configuration. For more information, see HotSpot Ergonomics Examples: -Xmx83886080 -Xmx81920k -Xmx80m
So that basically sums it up about doubts using the same parameters.
To use this go to a terminal and type it with a jar program. In my example I am using the minecraft server:
java -Xms1024M -Xmx2048M -jar minecraft.jar.
Here is an image of what happens:
I should note that the parameters are Case Sensitive. So xmx1024M is not the same as Xmx1024M.
The same applies on Linux. If you want to make the options permanent, you can export the
JAVA_OPTS environment variable.
I recommend to do it on a per-user basis. Modify the
.profile file in your home directory (or
.bash_profile if it exists and you use bash) to include this line:
export JAVA_OPTS='-Xincgc -Xmx2048M'
After setting this, you need to restart shell sessions for it to apply.
Alternatively, you can also modify the system-wide profile in /etc/profile.
Edit: Settings for the Java Browser Plugin are defined in the Java Control Panel: http://docs.oracle.com/javase/1.4.2/docs/guide/plugin/developer_guide/control_panel.html.