-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmalloc_stats.c
17 lines (15 loc) · 1.03 KB
/
malloc_stats.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include "malloc.h"
void malloc_stats(void) {
struct mallinfo info = mallinfo();
printf("Malloc Statistics:\n");
printf("Total arenas: %d\nNumber of free chunks: %d\nNumber of mmapped regions: %d\nSpace allocated in mmapped regions (bytes): %u\nMaximum total allocated space (bytes): %u\nTotal allocated space (bytes): %u\nTotal free space (bytes): %u\n\n", info.arenas, info.ordblks, info.hblks, info.hblkhd, info.usmblks, info.uordblks, info.fordblks);
printf("Arena Wise Statistics:\n");
malloc_arena start = arena_head;
int i = 0;
while(start != NULL) {
printf("Arena: %d\n", i);
printf("Number of free chunks: %d\nNumber of mmapped regions: %d\nSpace allocated in mmapped regions (bytes): %u\nMaximum total allocated space (bytes): %u\nTotal allocated space (bytes): %u\nTotal free space (bytes): %u\nTotal allocation requests: %d\nTotal free requests: %d\n\n", start->ordblks, start->hblks, start->hblkhd, start->usmblks, start->uordblks, start->fordblks, start->allocation_req, start->free_req);
i++;
start = start->next;
}
}