How to set the maximum memory usage for JVM?

erotsppa picture erotsppa · Sep 29, 2009 · Viewed 306k times · Source

I want to limit the maximum memory used by the JVM. Note, this is not just the heap, I want to limit the total memory used by this process.

Answer

Prabhu R picture Prabhu R · Sep 29, 2009

use the arguments -Xms<memory> -Xmx<memory>. Use M or G after the numbers for indicating Megs and Gigs of bytes respectively. -Xms indicates the minimum and -Xmx the maximum.