1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-05 09:13:14 +02:00

Add option "memory" to command /debug

This commit is contained in:
Sebastien Helleu
2011-02-10 18:37:12 +01:00
parent aae8a2e54c
commit 2ef6fdb2a1
21 changed files with 205 additions and 74 deletions
+34
View File
@@ -26,6 +26,9 @@
#endif
#include <stdlib.h>
#ifdef HAVE_MALLINFO
#include <malloc.h>
#endif
#include "weechat.h"
#include "wee-backtrace.h"
@@ -256,6 +259,37 @@ debug_windows_cb (void *data, const char *signal, const char *type_data,
return WEECHAT_RC_OK;
}
/*
* debug_memory: display information about dynamic memory allocation
*/
void
debug_memory ()
{
#ifdef HAVE_MALLINFO
struct mallinfo info;
info = mallinfo ();
gui_chat_printf (NULL, "");
gui_chat_printf (NULL, _("Memory usage (see \"man mallinfo\" for help):"));
gui_chat_printf (NULL, " arena :%10d", info.arena);
gui_chat_printf (NULL, " ordblks :%10d", info.ordblks);
gui_chat_printf (NULL, " smblks :%10d", info.smblks);
gui_chat_printf (NULL, " hblks :%10d", info.hblks);
gui_chat_printf (NULL, " hblkhd :%10d", info.hblkhd);
gui_chat_printf (NULL, " usmblks :%10d", info.usmblks);
gui_chat_printf (NULL, " fsmblks :%10d", info.fsmblks);
gui_chat_printf (NULL, " uordblks:%10d", info.uordblks);
gui_chat_printf (NULL, " fordblks:%10d", info.fordblks);
gui_chat_printf (NULL, " keepcost:%10d", info.keepcost);
#else
gui_chat_printf (NULL,
_("Memory usage not available (function \"mallinfo\" not "
"found)"));
#endif
}
/*
* debug_init: hook signals for debug
*/