Now when i try to start other java based app (like hudson server) i get following error:

There is insufficient memory for the Java Runtime Environment to continue.
Native memory allocation (malloc) failed to allocate 664080 bytes for Chunk::new
An error report file with more information is saved as:
/server/hs_err_pid26476.log

It seems as if system could not allocate 650KB of memory, but it should have like 1.2 GB
free.

I found somewhere that i should also check /proc/user_beancounters, which shows failcnt on privvmpages. I have no clue what that means (does the provider give 4GB of memory as he is supposed to? or is he cheating?)

This question came from our site for computer enthusiasts and power users.

2

Don't use OpenVZ. Java doesn't play well with OpenVZ.
–
Michael Hampton♦Nov 25 '12 at 23:55

You're confusing physical memory and virtual memory. You have 1.2GB of physical memory free and the process was unable to allocate 650KB of virtual memory. These things have very, very little to do with each other.
–
David SchwartzNov 26 '12 at 3:34

2 Answers
2

OpenVZ providers typically sell RAM capacity of their virtual machines as two numbers: "guaranteed" and "burst" RAM. You are supposed to always get the "guaranteed" amount of RAM, and may use up to the "burst" amount if host resources permit. For example a VPS might be sold as "512MiB guaranteed 1GiB burst RAM".

You should always have a successful memory allocation below the "guaranteed" amount, but memory allocations may sometimes fail above that amount, if other virtual machines on the host are consuming RAM as well, or if the provider has oversubscribed the machine (almost always).

To learn what these numbers are, look at the barrier for vmguarpages which represents the "guaranteed" RAM, and the limit for privvmpages which represents the "burst" RAM. Each of these numbers is expressed in a number of 4KiB pages.

So in your case, we can see that you have 1GiB (262144) "guaranteed" RAM, and 4GiB (1048576) "burst" RAM. (If these aren't the numbers you were promised, you need to have a very unpleasant talk with your VPS provider.)

Since you are already well over 2GiB used in the VM, your memory allocation may fail, because it is above the "guaranteed" amount.

Your provider very likely only guarantees 2 GB of memory and two more if available, that is, if the other costumers currently need less (which rarely will be the case). You would hence be better off to assume a maximum of 2 rather than 4 GB.

The failcount on privvmpages shows how often your system failed to allocate some memory (roughly speaking).