2 * Copyright (C) 2002 by Martin Pool
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 * Show moderately high-level information about how much memory was
25 * used for different things. The counting relies on various parts of
26 * the program updating counters as they use memory, so at first it
27 * will not be super accurate.
30 /* TODO: Perhaps show these numbers with commas to make them a bit
34 * If our C library can get malloc statistics, then show them to FINFO
36 void show_mem_stats(void)
38 extern struct stats stats;
40 rprintf(FINFO, "Memory usage:\n"
45 " %10ld file_structs (and associated data)\n"
46 " %10ld string_areas\n"
47 " %10ld exclude_structs\n"
48 " %10ld map_structs\n"
50 " %10ld delete_list\n"
53 (long) stats.main_flist,
54 (long) stats.flist_size,
55 (long) stats.hlink_list,
56 (long) stats.file_structs,
57 (long) stats.string_areas,
58 (long) stats.exclude_struct,
59 (long) stats.map_struct,
61 (long) stats.delete_list);
65 void * malloc_counted(size_t howmuch, size_t *pot)
68 return malloc(howmuch);
73 * If our C library can get malloc statistics, then show them to FINFO
75 void show_malloc_stats(void)
82 rprintf(FINFO, "VM statistics:\n"
86 rprintf(FINFO, " %10ld from sbrk()\n",
88 rprintf(FINFO, " %10ld from mmap()\n",
90 rprintf(FINFO, " %10ld in use\n",
92 rprintf(FINFO, " %10ld free in heap\n",
94 #endif /* HAVE_MALLINFO */