diff options
author | Dmitry Kozlov <xeb@mail.ru> | 2011-01-17 18:08:11 +0300 |
---|---|---|
committer | Dmitry Kozlov <xeb@mail.ru> | 2011-01-17 18:08:11 +0300 |
commit | c783f297faa2453daca7189182a17f913e003ccc (patch) | |
tree | 0527171103dbe568658ea21262e1027b7023bf9a /accel-pppd/cli | |
parent | 56762d9574d05bff9709c856f9f466c51156f549 (diff) | |
download | accel-ppp-c783f297faa2453daca7189182a17f913e003ccc.tar.gz accel-ppp-c783f297faa2453daca7189182a17f913e003ccc.zip |
memory usage optimization
Diffstat (limited to 'accel-pppd/cli')
-rw-r--r-- | accel-pppd/cli/std_cmd.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/accel-pppd/cli/std_cmd.c b/accel-pppd/cli/std_cmd.c index a49bbce..3adb926 100644 --- a/accel-pppd/cli/std_cmd.c +++ b/accel-pppd/cli/std_cmd.c @@ -3,6 +3,7 @@ #include <string.h> #include <unistd.h> #include <signal.h> +#include <malloc.h> #include <arpa/inet.h> #include "triton.h" @@ -21,6 +22,9 @@ static int show_stat_exec(const char *cmd, char * const *fields, int fields_cnt, FILE *f; unsigned long vmsize = 0, vmrss = 0; unsigned long page_size_kb = sysconf(_SC_PAGE_SIZE) / 1024; +#ifdef MEMDEBUG + struct mallinfo mi = mallinfo(); +#endif sprintf(statm_fname, "/proc/%i/statm", getpid()); f = fopen(statm_fname, "r"); @@ -38,7 +42,16 @@ static int show_stat_exec(const char *cmd, char * const *fields, int fields_cnt, cli_sendv(client, "uptime: %i.%02i:%02i:%02i\r\n", day, hour, dt / 60, dt % 60); cli_sendv(client, "cpu: %i%%\r\n", triton_stat.cpu); +#ifdef MEMDEBUG + cli_send(client, "memory:\r\n"); + cli_sendv(client, " rss/virt: %lu/%lu kB\r\n", vmrss * page_size_kb, vmsize * page_size_kb); + cli_sendv(client, " arena: %lu kB\r\n", mi.arena / 1024); + cli_sendv(client, " mmaped: %lu kB\r\n", mi.hblkhd / 1024); + cli_sendv(client, " uordblks: %lu kB\r\n", mi.uordblks / 1024); + cli_sendv(client, " fordblks: %lu kB\r\n", mi.fordblks / 1024); +#else cli_sendv(client, "mem(rss/virt): %lu/%lu kB\r\n", vmrss * page_size_kb, vmsize * page_size_kb); +#endif cli_send(client, "core:\r\n"); cli_sendv(client, " mempool_allocated: %u\r\n", triton_stat.mempool_allocated); cli_sendv(client, " mempool_available: %u\r\n", triton_stat.mempool_available); |