4

I know Linux likes to eat my RAM, and that's great, but it doesn't quite account for what I'm seeing on a VPS (KVM) running CentOS 6.5. In fact, I'm missing at least 200MB on a 1GB VM. Where could it be?

             total       used       free     shared    buffers     cached
Mem:           996        907         89          0         76        379
-/+ buffers/cache:        451        545
Swap:         1023          5       1018

free -m suggests that, without buffers/cache, the system uses 451 MB of memory. However, there's no way the running programs (mostly nginx/php-fpm/mysqld/sshd) add up to that much RAM.

ps_mem reports that 90MB is currently in use by programs, and here's what smem says:

Area                           Used      Cache   Noncache
firmware/hardware                 0          0          0
kernel image                      0          0          0
kernel dynamic memory        820912     775204      45708
userspace memory              96300      27988      68312
free memory                  103168     103168          0
----------------------------------------------------------
                            1020380     906360     114020

Is there anything outside of the visible running processes that could be eating my RAM? Or is free -m incorrectly reporting memory usage? Any tips on reclaiming this memory (without rebooting)?

Results of cat /proc/meminfo: http://paste.ubuntu.com/6949236/

EDIT: Turns out to be a large slab cache, see: https://stackoverflow.com/questions/5463800/linux-memory-reporting-discrepancy. I was confused by it being much larger than I'm used to, and the fact that tools like free -m, htop and the like report this as used memory rather than cache/buffers.

redburn
  • 197

2 Answers2

4
  1. free -m is accurate. I'm not familiar with ps_mem, but suspect it's reporting only certain kinds of memory usage by the programs. Try using top -a, see if it gives you more information.

  2. The memory is likely used by programs' "resource" space. Restarting them will clear some of this out, but I'd be surprised if it wasn't back to the same place in an hour.

  3. Why do you want to "reclaim" this memory. You're not out of RAM. "Free" memory is wasted memory. You'd be better off using 100%, even if only to get the most marginal of performance gains (which is why Linux uses it for caching aggressively).

  4. See also: Why is Linux reporting "free" memory strangely?

    Sounds like you've got the same misunderstands of memory utilization as many people. This Q&A has a great explanation of what's going, on along with links to more information. But in short, unless OOM is killing processes let the OS do it's thing. Serious, kernel programmers have dedicated large portions of their lives to getting this right, I'd dare not question their expertise unless there's an obvious problem.

Chris S
  • 78,455
3

try to check out:

cat /proc/meminfo

could give you the extra info you need :)

Semirke
  • 314