Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

We're having a lot of memory problems on a new OpenVZ box. It is supposed to have 1 gig of memory, I'm not sure how much of that is burstable or guaranteed memory. Programs in general seem to take up more virtual memory than they do on my box at home, and on our other OpenVZ box.

I wrote this simple C program:

#include <stdio.h>
#include <stdlib.h>

int main(){
  char *thingy = malloc(500);
  return 0;

So it simply allocates 500 bytes and then returns. I ran the program on 3 computers. On my home machine, and our other OpenVZ box it shows about 1k bytes of virtual memory being used. On the new problematic machine its about 3k.

I know this is just virtual memory and not resident memory, but why is this machine allocating so much virtual memory? Are there some settings I need to adjust to the OpenVZ memory settings?

I tried changing the stack size with ulimit -s 256 and restarting some demons, but I still saw the same results.

I'm doing all of my monitoring with htop, is this even a good program to use with a OpenVZ vps? I've read I should be parsing the output of /proc/user_beancounters intead or something.

I should note this memory usage appears to be leading to crashes. :\

share|improve this question

Because virtual memory is effectively free, nobody bothers to optimize the use of it. Most likely, it's just allocating a large amount to avoid having to allocate more later.

A larger allocation costs the same as a small allocation. But two small allocations cost more than one large one.

share|improve this answer
I've never seen this explained in such a simple manner before. +1 – Randolf Richardson Nov 12 '11 at 0:55
That makes sense. By "cost" you mean virtual memory usage, not CPU usage, right? – freedrull Nov 14 '11 at 18:15
Do you know anything about OpenVZ in particular? I'm not sure why this particular OpenVZ box uses more memory, our other box doesn't use this much virtual memory. I guess I should note in the original questions the system crashes that this memory usage seems to lead to.... – freedrull Nov 14 '11 at 18:17
@freedrull No, by "cost" I mean consumption of resources that are not effectively free, such as CPU usage. – David Schwartz Nov 14 '11 at 18:23

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.