Quantcast
Channel: slab classes and memory allocation in memcached - Stack Overflow
Viewing all articles
Browse latest Browse all 2

slab classes and memory allocation in memcached

$
0
0

I recently started going through memcached source code and i came across this structure. Based on my understanding, there are approximately 64 slabs and and each slab represents a unique chunk size. If we took the first slab class ( size 80 , say ) then the pages which are belongs to this slab will have it's memory broken into 80 bytes.

typedef struct {
  unsigned int size;      // sizes of items
  unsigned int perslab;   // how many items per slab

  void *slots;            // list of item ptrs
  unsigned int sl_curr;   // total free items in list

  unsigned int slabs;     // how many slabs were allocated for this class

  void **slab_list;       // array of slab pointers
  unsigned int list_size; // size of prev array

  size_t requested;       // The number of requested bytes

} slabclass_t;

I do not understand this line,

unsigned int slabs;     // how many slabs were allocated for this class

What does he mean by how many slabs were allocated for a slab class? Every slab class must be unique right? why will there be multiple slabs within one slab class? Am i missing something?


Viewing all articles
Browse latest Browse all 2

Latest Images





Latest Images