Privacy guaranteed - Your email is not shared with anyone.

Designating more RAM to Java in Linux?

Discussion in 'Tech Talk' started by nathanours, Jun 1, 2010.

  1. nathanours

    nathanours Texan

    I am running some java intense programs and want to designate more of my RAM to Java. I know how to do it in Windows, but how do you do it in linux? I am running the latest Ubuntu version.


  2. IndyGunFreak


    Jan 26, 2001
    I have absolutely no idea on that one... Never had anyone ask that question, or even saw it discussed.


  3. kc8ykd


    Oct 6, 2005
    i'm intrigued on how that would work under windows as well.

    I'm only familiar with how to change the proc priority and affinity, I've never seen anything with regards to amount of ram designated to a singular process/program. perhaps i've been missing out all these years :(
  4. nathanours

    nathanours Texan

    This is how its done with Windows (from a popular gaming site my brother is a member of)

    Allocate more memory to Java

    1.When running Java look for the small Java 'Coffee mug' icon that appears in the bottom right of the Windows taskbar (the system tray).

    2. Right click this icon and select the 'Open Control Panel' option.

    3. Select the 'Java' tab on the window that appears. You should see two panes.

    4. Select 'View' under the first pane, which will be labeled 'Java Applet Runtime Settings'.

    5. You will now see your installed Java versions. In the fourth column (titled 'Java Runtime Parameters') double click, and you will have a text entry box.

    6. Type -xmx128m into the box. The 128 part tells Java to use up to 128mb of RAM instead of the default, which is much lower. To allocate more or less, just change the number. It is not recommended to go for any more than 60% of your total RAM!

    7. Click Apply and OK, then close your browser (if open) and re-open.
  5. tous

    tous GET A ROPE!

    Jan 7, 2001
    Plano, Texas, Republic of
    Java browser plugins (add ons) exist to 1) interpret JavaScript and 2) execute Java applets. A Java applet is somewhat like a Windows ActiveX control (it gets downloaded from the server to the local machine and is executed locally,) is usually quite small and executes in the browser's memory space. You shouldn't have memory problems with the JavaScript or applets unless they're malformed.

    A Java application is a program or collection or related programs that execute in a local Java Virtual Machine. Thus, you launch the JVM, tell it where the application files are, the application is loaded by the JVM and away we go!

    E.g. % java package/myapp

    If you get out-of-memory exceptions (it will show up as a text error message in the terminal window after the JVM abends) you can alter the default initial and maximum memory usage of the the JVM via:

    % java -Xms512m - -Xmn1024m package/myApp

    the -Xms option tells the Java Virtal Machine how much memory to use initially, in the above example, 512 megabytes. the -Xmn option tells the Java Virtual Machine what the maximum memory available is, in this case 1024 megabytes.

    Note that you only need to specify the initial memory size if you are getting out-of-memory exceptions during application loading, when the JVM loads all of the packages referenced in the application. Not usually a problem for trivial applications.

    Note well that the Java JVM spends about 80% of its time and energy with garbage collection. Simply specifying a huge maximum memory number won't necessarily make the application execute faster or more efficiently.
  6. kc8ykd


    Oct 6, 2005
    ah, gotcha, i thought it was an adjustment that could be made on a per program basis in windows.