Schnee (schnee) wrote,

java pitfalls

So, I've got a java program that needs a fair amount of memory (about 2.4 GiB). Just running it the regular way causes it to exit with an OOM error; the program is smart enough to catch this and suggest adjusting the heap size by running it as java -Xmx<size> -jar <program>.jar (at the same time, it's not smart enough to suggest a reasonable size there, instead defaulting to 512M, but eh).

This works, but it's less than satisfactory, so I looked into how to set java's default heap size. A quick search turns up this page; one of the answers states that "[a]ssuming that we have more than 1gb of physical memory(quite common these days), [the default heap size]'s always 1/4th of your physical memory".

Since that would work out to 4 GiB on this machine, it wouldn't be a problem. Another answer on the same page suggests that you can find the system default by running java -XX:+PrintFlagsFinal -version, which indeed prints "uintx MaxHeapSize := 4280287232 {product}", amont other things — about what you'd expect. So far, so good.

So why does the program in question not work with that default value? This is a 64-bit java (current version) on a 64-bit machine, FWIW. Any ideas?

Tags: help needed, java
  • Post a new comment


    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded