2

we use Java for our project www.aerospaceresearch.net/constellation and use Java diretcly out of an uninstalled java bin-folder.

We have some troubles with ram usage of this java differing between OS and even 32 and 64bit versions. Is it possible to set an upper limit for ram usage, so that Java does a dynamic rearranging of ram, that it is allways below 150mb for example?

That would really help us to solve some minor issues and to bring our app to systems with limited ram capabilities.

Thanks in advance, Andreas

2
  • "...and use Java diretcly out of an uninstalled java bin-folder." Huh? Commented May 8, 2011 at 12:56
  • @T.J.Crowder I guess OP meant they installed the JDK/JRE by simply unzipping the Oracle zip distribution without running any installers. Commented May 8, 2011 at 13:03

2 Answers 2

7

It's difficult to tell from your question, but you may be looking for the -Xmx option in Sun's Oracle's java tool, which sets a maximum size for the Java memory heap.

For details on the various non-standard features offered by that version of the java tool (including several related to the heap), type java -X at a command prompt. For my installed version, that gives me:

java -X
    -Xmixed           mixed mode execution (default)
    -Xint             interpreted mode execution only
    -Xbootclasspath:<directories and zip/jar files separated by :>
                      set search path for bootstrap classes and resources
    -Xbootclasspath/a:<directories and zip/jar files separated by :>
                      append to end of bootstrap class path
    -Xbootclasspath/p:<directories and zip/jar files separated by :>
                      prepend in front of bootstrap class path
    -Xnoclassgc       disable class garbage collection
    -Xincgc           enable incremental garbage collection
    -Xloggc:<file>    log GC status to a file with time stamps
    -Xbatch           disable background compilation
    -Xms<size>        set initial Java heap size
    -Xmx<size>        set maximum Java heap size
    -Xss<size>        set java thread stack size
    -Xprof            output cpu profiling data
    -Xfuture          enable strictest checks, anticipating future default
    -Xrs              reduce use of OS signals by Java/VM (see documentation)
    -Xcheck:jni       perform additional checks for JNI functions
    -Xshare:off       do not attempt to use shared class data
    -Xshare:auto      use shared class data if possible (default)
    -Xshare:on        require using shared class data, otherwise fail.

The -X options are non-standard and subject to change without notice.

If you're using a different implementation of Java, those options may vary; and note the warning at the end of the above.

Sign up to request clarification or add additional context in comments.

Comments

2

You could try using something like...

java -Xmx128m BigApp

But you may get out-of-memory errors if your app actually goes over the 128 MB heap limit.

[update] On the 64 bit side of things, there is a special parameter that makes 64 bit references take up less space but I can't find it right now. It is standard on one of the new JREs (1.6?).

2 Comments

XX:+UseCompressedOops will reduce the size impact of 64 bit references
I think you meant -Xmx128m rather than 128 bytes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.