When you run MongoDB in OpenVZ, you might see a warning that OpenVZ is not supported. Some web searching can tell you that OpenVZ has a different guest memory management approach than the host system that leads to mongod being unable to detect if it runs out of memory.
The temporary fix until this issue is worked out is to put a ulimit command in mongod start up script (usually /etc/init.d/mongod).
ulimit -v kbytes
where kbytes is the number of kilobytes of virtual memory that mongod can use.
Copied from http://hachiari.com/blog/2011/03/31/getting-mongodb-to-work-on-openvz-without-out-of-memory-problem/.