Bug 1082199 - Recompute stats in jemalloc_stats when using jemalloc3. r=glandium
authorGuilherme Goncalves <guilherme.p.gonc@gmail.com>
Fri, 17 Oct 2014 15:55:00 +0200
changeset 211191 169ea979fe84920f0d09d5e5fe4608b5de0d7e67
parent 211190 70868ad1299f9cbd61a209789405568c1b174450
child 211192 c39e875e01f3ba63ea2f1d1e91d00c96a42f3051
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersglandium
bugs1082199
milestone36.0a1
Bug 1082199 - Recompute stats in jemalloc_stats when using jemalloc3. r=glandium
memory/build/mozjemalloc_compat.c
--- a/memory/build/mozjemalloc_compat.c
+++ b/memory/build/mozjemalloc_compat.c
@@ -63,16 +63,22 @@ malloc_good_size_impl(size_t size)
 
 MOZ_JEMALLOC_API void
 jemalloc_stats_impl(jemalloc_stats_t *stats)
 {
   unsigned narenas;
   size_t active, allocated, mapped, page, pdirty;
   size_t lg_chunk;
 
+  // Refresh jemalloc's stats by updating its epoch, see ctl_refresh in
+  // src/ctl.c
+  uint64_t epoch = 0;
+  size_t esz = sizeof(epoch);
+  int ret = je_(mallctl)("epoch", &epoch, &esz, &epoch, esz);
+
   CTL_GET("arenas.narenas", narenas);
   CTL_GET("arenas.page", page);
   CTL_GET("stats.active", active);
   CTL_GET("stats.allocated", allocated);
   CTL_GET("stats.mapped", mapped);
   CTL_GET("opt.lg_chunk", lg_chunk);
 
   /* get the summation for all arenas, i == narenas */