Memcache not freeing memory when a key expires

Fabian Thylmann fabian at toomuchmedia.com
Mon Feb 27 23:15:12 UTC 2006


Hi Stephen,

the overhead to keep track of expired keys and remove them from memory 
is too large and is not needed. Once the key is accessed memcached will 
see its expired and remove it from memory then. It will also simply 
treat it as if its not there if the same key is set again.

How exactly memcached finds which key to remove when memory is all used 
up I am not 100% sure myself.

Hope this helps a bit,
Fabian


Stephen Corgiat wrote:

> Hello,
>
> We're seeing some weird behavior from memcached.. Hopefully somebody 
> can provide some knowledge on this issue. 
>
> When we set a key in memcache with a TTL of, say, 60 seconds, after 60 
> seconds has gone by the data "expires".  This is normal, but it seems 
> the data is not truely freed by memcached (based on the 'bytes' stats 
> field).   We've found that the only way to get the memory released is 
> to try to do a GET on the key.
>
> I always thought if you had a bunch of keys with a TTL of 0, once all 
> available memory was consumed, memcache would start removing the least 
> used keys to make room for new keys. In our tests, this never happened.
>
> We've tried installations on FreeBSD & Linux, 1.1.12 & 1.1.11... all 
> with the same results.
>
> Thanks!
> Stephen
>



More information about the memcached mailing list