There are a few ways to check the memory usage of your running Memcached instance. Here are some options:
You can use the
stats command to get various statistics about your Memcached server, including its current memory usage. To do so, you can connect to the server using telnet and issue the following commands:
This will output a lot of information about the server, but one of the lines should look like this:
STAT limit_maxbytes 67108864
limit_maxbytes value represents the maximum amount of memory that Memcached is allowed to use, in bytes. You can compare this with other stats such as
bytes_used to see how much memory is currently being used.
Another way to see the memory usage of your Memcached server is to use the
stats items command. This will display statistics for each slab class (a slab class is a set of items with similar sizes). Here's an example:
This will output something like:
STAT items:1:number 4 STAT items:1:age 13636 STAT items:1:evicted 0 STAT items:1:evicted_nonzero 0 STAT items:1:evicted_time 0 STAT items:1:outofmemory 0 STAT items:1:tailrepairs 0 STAT items:1:reclaimed 32 STAT items:1:expired_unfetched 0 STAT items:2:number 12 STAT items:2:age 109726 STAT items:2:evicted 0 ...
number value for each slab class represents the number of items in that class, and the
age value represents the age of the oldest item in the class. You can use this information to get an idea of how much memory is being used by each slab class.
Finally, you can use the
ps command to see how much memory the Memcached process is using overall. Here's an example:
In this example, the
RES column shows the amount of physical memory (in kilobytes) that the Memcached process is currently using. Note that this includes both the memory used by the cache data as well as any overhead required by the Memcached process itself.