To check used and unused ram and swap space on XEN or OpenVZ VPS is easy. The free command provides information about ram usage on VPS running Linux or another Unix-like operating system.
The basic syntax of free is
Free accepts no arguments (i.e., input data) and is commonly used without any options.
Below is the example of free command on a XEN VPS
free total used free shared buffers cached Mem: 1015876 969688 46188 0 58876 679356 -/+ buffers/cache: 231456 784420 Swap: 1048568 912 1047656
Another example of free command on a OpenVZ VPS
free total used free shared buffers cached Mem: 1048576 223836 824740 0 0 78060 -/+ buffers/cache: 145776 902800 Swap: 1310720 8752 1301968
Some people might question Xen ram usage. Is XEN VPS used up most of the ram? No worry, your ram is fine! XEN VPS is more like a real dedicated Linux server. Linux system will borrow unused ram for disk caching. This makes it looks like you are low on ram.
Xen in their work makes a connection between the environment of OS and the server hardware. OpenVZ creates a virtual server as a layer that runs on another operating system.The model of ram allocation between XEN VPS and OpenVZ is different. Xen provides better isolation and dedicated ram, OpenVZ uses a shared kernel approach so resources are more shared.
To put it in simple, for OpenVZ VPS, the most important information for free ram is the first row's free value
For XEN VPS, the free ram available is the second row's free value, - buffers/cache is the "used", + buffers/cache is "free"
Several options are available to change the unit of display for free from its default kilobytes, including -b for bytes, -m for megabytes and -g for gigabytes. Of these, -m is usually the most useful. Thus, for example, to show all of the data in megabytes, the following would be used: