Search code examples
javajava-8heap-memoryjava-web-startjnlp

Java Web Start (JWS) memory management seems to be different in 32 and 64 bits


We are working on a (big) system that runs as a Java Web Start application. Thus, the user downloads the JNLP file, and runs it on his or her computer.

We have had issues with some users claiming that the application hangs when they open a few windows. We have made some tests and the reason is clear and repeatable:

  • If a user opens the JNLP file using the 32 bit JVM, the max memory sticks to 256 MB, and once this threshold is surpassed, the application goes 0% free memory and hangs.
  • If the same user opens the same JNLP file using the 64 bit JVM, the max memory starts at 256 MB, but as the system needs more memory, the JVM reserves and uses it freely, up to more than 1 GB if needed.

We made several tests and the situation is always the same.

Is there any way for the 32 bit JVM to behave exactly as the 64 bit? I know we can set a max heap size, but the final user may have 1GB, 2GB or 3GB of free memory, and we would like him or her to be able to use them if needed, which is exactly what happens with the 64 bit.

We are using Java 8, update 201.

The application's memory needs depend on how many windows do you open. For a normal use, 256MB-512MB would be more than enough, but some users would benefit from being able to open 7-10 screens, and that could go up to 800MB-1GB of RAM.


Solution

  • You should specify the memory required by the application in the JNLP file using max-heap-size parameter and don't depend on the client system:

    <java version="1.8" initial-heap-size="256m" max-heap-size="1024m"/>
    

    In most cases default JVM heap is at most 25% of the available system memory. If some of the users have only 1GB RAM then they will never get more than 256 MB heap if you don't specify it yourself.

    Do note that since you are supporting 32 bit JVMs you can't go over 2 GB.