<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">On Dec 24, 2014, at 1:33 AM, Oran Agra <<a href="mailto:oran@redislabs.com" class="">oran@redislabs.com</a>> wrote:<div><blockquote type="cite" class=""><div dir="ltr" class=""><div class="gmail_signature"><div dir="ltr" class=""></div></div>
<div class="">I'm trying to get the stat for total allocated memory.</div><div class=""><br class=""></div><div class="">i'm calling either:<br class=""><div class=""><div class=""><font face="monospace, monospace" class="">    size_t um;</font></div><div class=""><font face="monospace, monospace" class="">    size_t sz = sizeof(size_t);<br class=""></font></div></div><div class=""><font face="monospace, monospace" class="">    res = je_mallctl("stats.allocated", &um, &sz, NULL, 0);</font></div></div><div class="">or </div><div class=""><div class=""><font face="monospace, monospace" class="">    size_t allocated_mib[2];</font></div><div class=""><font face="monospace, monospace" class="">    size_t allocated_mib_len = 0;</font></div><div class=""><font face="monospace, monospace" class="">    allocated_mib_len = sizeof(allocated_mib);<br class=""></font></div><div class=""><font face="monospace, monospace" class="">    int res = je_mallctlnametomib("stats.allocated", allocated_mib, &allocated_mib_len);</font></div></div><div class=""><font face="monospace, monospace" class="">    int res = je_mallctlbymib(allocated_mib, allocated_mib_len, &um, &sz, NULL, 0);</font><br class=""></div><div class="">both return success (0), but 'um' variable is always set to 0.</div><div class=""><br class=""></div><div class="">digging into the source code of jemalloc, it seems that ctl_refresh() which is suppose to update this stat is never called.</div><div class="">p.s. config_stats is set to true, and i confirmed that with a debugger.<br class=""></div><div class=""><br class=""></div><div class="">is it a bug? or am i missing something?</div></div></blockquote><div><br class=""></div><div>You need to call the "epoch" mallctl to refresh the stats:</div><div><br class=""></div><div><span class="Apple-tab-span" style="white-space:pre"> </span><a href="http://www.canonware.com/download/jemalloc/jemalloc-latest/doc/jemalloc.html#epoch" class="">http://www.canonware.com/download/jemalloc/jemalloc-latest/doc/jemalloc.html#epoch</a></div><div><br class=""></div><div>Jason</div></div><br class=""></body></html>