0

I have some java application on windows 7 x64 and pass a parameters to it:

-Xms256m -Xmx256m

Then I run Process explorer and see columns (values) on java process: Private bytes (414 620K), Working Set (328 876K) and Virtual Size (1 890 352K). It is easy to see that after I specify max and min heap size java.exe process allocates more memory in virtual size. And this influence on Page file size on windows to grow.

So how to restrict java virtual memory usage?

P.S. If you want to reproduce this situaltion you can download cassandra, edit bin\cassandra.bat with -Xms256m -Xmx256m and after start you can see a difference between heap memory size and virtual. However cassandra is just a java program, so the question about how to run java program, not how to run cassandra.

Cherry
  • 31,309
  • 66
  • 224
  • 364

1 Answers1

0

Cassandra is designed to make heavy use of virtual memory space, and it does so very efficiently. It does this to avoid OS context switching, and to leverage the Operating Systems very efficient disk to memory paging systems. This mechanism can be used quite safely, even when the amount of virtual memory assigned exceeds physical memory. Cassandra has been designed for this case and I would recommend only tweaking the Cassandra config file when you have a verified problem.

-Xms and -Xmx configures the Java heap size only. It does not include the perm gen, memory needed by the JVM itself or use of off heap data allocated via memory mapped files or use of sun.misc.Unsafe.

Virtual memory usage however comes from the use of mmap(), that is memory mapped files. In Cassandra's case, that is memory mapping of the stables and from Cassandra's FAQ.

Chris K
  • 11,622
  • 1
  • 36
  • 49