4 Replies Latest reply on Oct 3, 2011 6:19 PM by jschellSomeoneStoleMyAlias

    How to set -Xmx on desktop computer when you dont know available memory

      We package a software with -Xmx512M, but then when people call and say "my program freezes up" and we investigate further and find they are collecting a ton of data we know the reason is that they have running too much stuff on the software and need more memory, so we direct them to increase the -Xmx to 1G or 2G or something more reasonable.

      We set it to -Xmx512M because we dont know if the PC has 2GB or 8GB, we cant just set it to 2G because then there is a risk we are consuming too much of the system's memory. 512M works for 99% of the users, but this seems so kludgy.......

      How do people set memory usage dynamically in java? It would be great if we could tell java "try to limit use 512M but if you absolutely must, go up to 2GB" and if the PC has only 1 GB at least it will run, and then throw some out of memory error later. But the flags dont work like that, I think this is effectively what -Xmx means but if you set -Xmx to 2G and the user only has 1G then the application wont even start. It would be great if java would at least start the JVM and crash later if it gets to 1.5G and the user only has 1.499G

      This has to be a common problem? What are people doing to workaround this?