aboutsummaryrefslogtreecommitdiff
path: root/src/common/util.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2007-07-30 18:14:14 +0000
committerNick Mathewson <nickm@torproject.org>2007-07-30 18:14:14 +0000
commit45c82b1d8555901b6992bf9a30120fbb35a005ab (patch)
treef4856594ac021a4b9988433f782d2516dfb56606 /src/common/util.c
parent9fb77a6479a079aeb5698272c68bd50acdffe401 (diff)
downloadtor-45c82b1d8555901b6992bf9a30120fbb35a005ab.tar.gz
tor-45c82b1d8555901b6992bf9a30120fbb35a005ab.zip
r14024@catbus: nickm | 2007-07-30 14:13:58 -0400
Glibc (and maybe others) define a mallinfo() that can be used to see how the platform malloc is acting inside. When we have it, dump its output on dumpmemusage(). svn:r10996
Diffstat (limited to 'src/common/util.c')
-rw-r--r--src/common/util.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/common/util.c b/src/common/util.c
index 991cda1a97..580f078afe 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -213,6 +213,24 @@ _tor_free(void *mem)
tor_free(mem);
}
+/** DOCDOC */
+void
+tor_log_mallinfo(int severity)
+{
+#ifdef HAVE_MALLINFO
+ struct mallinfo mi;
+ memset(&mi, 0, sizeof(mi));
+ mi = mallinfo();
+ log(severity, LD_MM,
+ "mallinfo() said: arena=%d, ordblks=%d, smblks=%d, hblks=%d, "
+ "hblkhd=%d, usmblks=%d, fsmblks=%d, uordblks=%d, fordblks=%d, "
+ "keepcost=%d",
+ mi.arena, mi.ordblks, mi.smblks, mi.hblks,
+ mi.hblkhd, mi.usmblks, mi.fsmblks, mi.uordblks, mi.fordblks,
+ mi.keepcost);
+#endif
+}
+
/* =====
* Math
* ===== */