Details
-
Bug
-
Resolution: Fixed
-
Critical
-
2.5.1, 3.0
-
Security Level: Public
-
Untriaged
-
Centos 64-bit
-
Unknown
Description
The memory statistics 'total_free_bytes' and 'total_fragmentation_bytes' are calculated incorrectly, as they do not account for tcmalloc memory which is free and has been unmapped (returned to the OS). This means that the free memory is under-counted, and the fragmentation size is over-counted.
Currently, we calculate 'total_free_bytes' from tcmalloc.pageheap_free_bytes, then calculate total_fragmentation_bytes as "heap_size - allocated - free" - see: http://src.couchbase.org/source/xref/3.0.0/memcached/daemon/alloc_hooks.c#157
However, from the tcmalloc documentation [1] we see that actual free memory is sub-divided into two statistics:
- tcmalloc.pageheap_free_bytes Number of bytes in free, mapped pages in page heap.
- tcmalloc.pageheap_unmapped_bytes Number of bytes in free, unmapped pages in page heap.
The free memory 'inside' the memcached process should be the sum of both of these statistics. In turn, due to us calculating this wrongly, total_fragmentation_bytes is also wrong.
[1]: http://gperftools.googlecode.com/svn/trunk/doc/tcmalloc.html#compiletime
... patch incoming...