I have a 8 GB RAM Server (Dedicated) and currently have KVM Virtual Machines running on there (successfully) however i'm considering moving to OpenVZ as KVM seems a bit overkill with a lot of overhead for what i use it for.

In the past i have used OpenVZ Containers, hosted by myself and from other providers and Java doesn't seem to work well with them.. One example is that if i give a container 2 GB RAM ( No burst) (with or without vswap doesn't matter) a java instance can only be tuned to use at very most 1500 MB of that RAM (-Xmx, -Xms).

Ideally, i wish to be able to create "Mini" containers with about 256MB, 512MB, 768 RAM and run some java instances in them.

My question is: I'm trying to find an ideal way to tune a OpenVZ container configuration to work better with Java memory.

Please, don't suggest anything related to Java settings, i'm looking for OpenVZ specific answers.. Though i welcome any suggestion if you feel it may help me.

Much Appreciated, Daniel


2 Answers 2


You have to use RHEL6 (aka 2.6.32-, aka 042stab) kernel and configure your containers with VSwap. See http://openvz.org/VSwap for more details. It is done so by default in new installs.

If you want mini containers, assign the RAM you need and then two-four times amount of swap, to enable some "stretching" for CT memory. For example, for 256M that would be

vzctl set $CTID --ram 256M --swap 1G --save

Make sure other beancounters (especially privvmpages) are set to unlimited. Again, see http://openvz.org/VSwap for more details.


Why ruling out java settings if the issue might just be a misunderstanding of -Xmx option ?

I would consider 2 GB or RAM for a 1.5 GB heap to be a correct sizing. The heap is only a part of the memory a JVM uses. Native code including the JVM code itself, memory used by native libraries, the code cache, stack based memory (each thread has its own stack) and the permanent generation are all stored outside the heap.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .