5

I'm using Ubuntu 11.10, virtualized by OpenVZ. That output of free -m shows that buffers is always equal to used.

             total       used       free     shared    buffers     cached
Mem:          2048       1079        968          0          0          0
-/+ buffers/cache:       1079        968
Swap:            0          0          0

Is that the reason I can't run a java virtual machine, although there's 968mb of free memory?

2
  • 3
    OpenVZ isn't really virtualization, it's a container. Think of it as a security-enhanced chroot. You're fooled by the output as the kernel is telling you lies about the memory usage. Ask for the real memory usage from within in the host.
    – gertvdijk
    Dec 29, 2012 at 17:08
  • That's consistent with OpenVZ, mine do the same!
    – slm
    Dec 29, 2012 at 17:21

2 Answers 2

4

It is due to OpenVZ. You can see the limits applied in /proc/user_beancounters, and there is some explanation here: http://wiki.openvz.org/Privvmpages

Although I have not had memory problems in a container, I think the suggestion here:

http://www.moeding.net/archives/20-Optimizing-virtual-memory-in-OpenVZ-I.html

to start by setting the stack size with ulimit is a good one. Just note that the implication there that OpenVZ uses the same metric as you find in top's VIRT column is wrong; the "privvmpages" is I believe virtual pages marked writable and private, thus significantly less than the entire address space of a process. There is some other misinformation in there too ("Unfortunately running out of memory is an error condition that most programs fail to handle properly." -- on linux, running out of memory is by default not an error condition, so programs do not get a chance to handle it properly). But setting the stack size down is probably still worth trying.

Slm's suggestion seems like a good solution to finding the fat cats, but if your slice is like mine, there is no /proc/bc to work with. You can, however, get the writable and private stat for a process via pmap -d, or look at numbers in top.

1 gig might seem like enough to run a JVM, but there is a complication: since the amount of memory used and available is not a simple figure (see some discussion of why here), the total may be more than the machine can actually provide at a given point in time.

1

I do it like this with a bash function.

vzr_mb () 
{ 
    ( printf "vm feature held(MB) maxheld(MB) barrier(MB) limit(MB) failcnt\n";
    grep privvm /proc/bc/1*/resources | awk '{sub($3,$3*4096/2^20) sub($4,$4*4096/2^20) sub($5,$5*4096/2^20) sub($6,$6*4096/2^20)}1' ) | column -t
}

Running it looks like this:

% vzr_mb
vm                       feature      held(MB)  maxheld(MB)  barrier(MB)  limit(MB)  failcnt
/proc/bc/101/resources:  privvmpages  184.422   300.129      300          310        2
/proc/bc/102/resources:  privvmpages  473.703   861.078      900          950        13
/proc/bc/103/resources:  privvmpages  184.457   579.941      300          350        238
/proc/bc/104/resources:  privvmpages  307.961   700.473      400          450        70
/proc/bc/105/resources:  privvmpages  477.828   773.586      700          750        1730347
/proc/bc/106/resources:  privvmpages  637.801   981.281      1000         1050       511
/proc/bc/108/resources:  privvmpages  167.777   580.102      285          295        1
/proc/bc/109/resources:  privvmpages  202.055   308.969      395          425        0
/proc/bc/110/resources:  privvmpages  212.492   625.324      295          325        326
/proc/bc/111/resources:  privvmpages  189.539   535.492      295          325        5
/proc/bc/112/resources:  privvmpages  239.617   407.766      468.75       488.281    0
/proc/bc/180/resources:  privvmpages  195.605   601.602      200          225        3049321
/proc/bc/181/resources:  privvmpages  967.027   1304.82      1500         2000       3
/proc/bc/183/resources:  privvmpages  0         1087.72      1115         1150       0
2
  • What does these values stands for? {sub($3,$3*4096/2^20) sub($4,$4*4096/2^20) sub($5,$5*4096/2^20) sub($6,$6*4096/2^20)}
    – Kenshin
    Sep 8, 2016 at 20:33
  • what is 4096 referring to?
    – Kenshin
    Sep 8, 2016 at 20:35

You must log in to answer this question.

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