Allocating memory beyond mem_limit if p->slabs <= 0

dormando dormando at rydia.net
Wed Nov 14 08:06:40 UTC 2007


(Has anyone responded to this?)

It's my understanding (although I could be wrong, this code's just a little
dicey), that if you're not pre-allocating your slabs, that fix prevented
transient out of memory errors if you hit the malloc limit before having
one slab of every size available. 

Since that's counting the malloc'ed memory and not the "used" memory, you'd 
otherwise end up stuck having OOM errors on every store of an item of 
specific size, even if there's plenty of room in in the LRU. Which there 
always is unless you run memcached with the -M option.

-Dormando

Chris Eberly wrote:
> Hello,
> We are working on optimizing our memcached configuration and I came
> across something I don't understand. It seems as though you are able to
> allocate a slab (and therefore more memory) even if you have passed the
> command line memory limit with other slabs. The code in question is in
> slabs.c in do_slabs_newslab():
> 
>     if (mem_limit && mem_malloced + len > mem_limit && p->slabs > 0)
>         return 0;
> 
> So I can theoretically allocate 1 of each type of slab I don't have yet
> even if I am passed my memory limit. While it turns out this is
> advantageous (or at worst irrelevant because of the scale of the memory
> we are using), I am wondering what the rationale behind this code is?
> 
> 
> Chris Eberly



More information about the memcached mailing list