5

There are -Xmx and max-heap-size (jnlp) options to set maximum memory java application can use.
If these options are not specified application is permitted to use only small amount of available phisical memory in the system.
That is the reason people play with -Xmx to allow application to use more memory. But this is really a nightmare as for me because there could be different amont of memory on client machine and even OS should be taken into consideration.

Is there any way to alow java application to use maximum available memory in the system?

Thanks.

1

2 Answers 2

5
-XX:DefaultMaxRAMFraction=1

Doesn't work for web start.

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

Comments

3

Unfortunately, the best way I'm aware of is to write a simple launcher (possibly a shell script or batch file) that inspects the system, determines an appropriate value for -Xmx, and then launches the Java application. Once the JVM has initialized, it is not possible to change the values.

3 Comments

Is it correct that whatever memory you put in -Xmx will be taken by the JVM and not released until you quit? Because then you could end up with some massive memory hogs...
@Miquel: No, that's -Xms, the initial heap size. -Xmx is the maximum heap size.
once the JVM gets hold of memory it doesn't let it go. there are some technical situational arguments against this, but in practice those situations never actually happen, so memory that gets allocated to the heap, stays allocated. That doesn't mean that the host OS can't swap it out but that is an entirely different issue.

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.