0

I have set Item Size to 128M and Maximum Memory to 1024M in my memcached configuration. But when I run this command:

ps -eo pmem,pcpu,vsize,pid,cmd | sort -k 1 -nr | head -5

I get

71.7  0.0 3072592 4537 /usr/bin/memcached -vv -m 1024 -p 11211 -u memcache -l 0.0.0.0 -I 128M

Which states that memcached is taking 3GB of memory. Now I understand when we set Item Size larger than 1MB, memory consumption of memcached increases. But 3GB when you have set Maximum memory to 1GB seems to be quite much.

Is is always so or I am doing something wrong? Is there anyway to decrease this memory consumption?

Note: Although keys that I am currently storing in the memcached or a little over 1MB but size of these keys keeps increasing continuously, so to be safe in the future I have set the Item size to maximum possible!

1 Answers1

1

vsize does not mean how much memory the process is taking up. That number is given by rss.

Resident set size, or rss, indicates how much memory the process is actually using. While, total VM size, here vsize, indicates how much total address space is in use. The program could theoretically use that much RAM eventually, but most of the address space is used by things like memory allocated but not used, parts of libraries which haven't been loaded from disk because they weren't needed, etc.

In practice you can ignore vsize unless you're on a 32-bit system, on which the maximum possible address space for any process is 4GiB (even if the process uses a far smaller amount of RAM).

Michael Hampton
  • 237,123
  • 42
  • 477
  • 940
  • rss=2884048 for memcached which is not much less than vsize and is far greater than size configures i.e. 1GB – Muhammad Tahir Aug 08 '15 at 19:01
  • Also memcached consumes memory as much data is stored, it does not reserve all the specified memory (As far as I know). But here there is only 5M data that is stored at the moment (according to stats command to memcached telnet) and it still is taking almost 3GB of memory. – Muhammad Tahir Aug 08 '15 at 19:04