diff options
author | rwatson <rwatson@FreeBSD.org> | 2006-10-26 10:17:13 +0000 |
---|---|---|
committer | rwatson <rwatson@FreeBSD.org> | 2006-10-26 10:17:13 +0000 |
commit | 55067e6cf7b8af77887d5fd1620da9fcc596ad9d (patch) | |
tree | 0c4d59ceae3b8c7ad9480556ef9b9bd1ae874589 /sys/kern/kern_malloc.c | |
parent | 329f9b6294caa30cd8f5f17101f06309aeaa726b (diff) | |
download | FreeBSD-src-55067e6cf7b8af77887d5fd1620da9fcc596ad9d.zip FreeBSD-src-55067e6cf7b8af77887d5fd1620da9fcc596ad9d.tar.gz |
Increase usefulness of "show malloc" by moving from displaying the basic
counters of allocs/frees/use for each malloc type to calculating InUse,
MemUse, and Requests as displayed by the userspace vmstat -m. This is
more useful when debugging malloc(9)-related memory leaks, where the
count of allocs/frees may not usefully reflect that current memory
allocation (i.e., when highly variable size allocations occur with the
same malloc type, such as with contigmalloc).
MFC after: 3 days
Limitations observed by: scottl
Diffstat (limited to 'sys/kern/kern_malloc.c')
-rw-r--r-- | sys/kern/kern_malloc.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/sys/kern/kern_malloc.c b/sys/kern/kern_malloc.c index 18fa9fe..b05d13a 100644 --- a/sys/kern/kern_malloc.c +++ b/sys/kern/kern_malloc.c @@ -1,7 +1,7 @@ /*- * Copyright (c) 1987, 1991, 1993 * The Regents of the University of California. - * Copyright (c) 2005 Robert N. M. Watson + * Copyright (c) 2005-2006 Robert N. M. Watson * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -802,20 +802,26 @@ DB_SHOW_COMMAND(malloc, db_show_malloc) struct malloc_type_internal *mtip; struct malloc_type *mtp; u_int64_t allocs, frees; + u_int64_t alloced, freed; int i; - db_printf("%18s %12s %12s %12s\n", "Type", "Allocs", "Frees", - "Used"); + db_printf("%18s %12s %12s %12s\n", "Type", "InUse", "MemUse", + "Requests"); for (mtp = kmemstatistics; mtp != NULL; mtp = mtp->ks_next) { mtip = (struct malloc_type_internal *)mtp->ks_handle; allocs = 0; frees = 0; + alloced = 0; + freed = 0; for (i = 0; i < MAXCPU; i++) { allocs += mtip->mti_stats[i].mts_numallocs; frees += mtip->mti_stats[i].mts_numfrees; + alloced += mtip->mti_stats[i].mts_memalloced; + freed += mtip->mti_stats[i].mts_memfreed; } - db_printf("%18s %12ju %12ju %12ju\n", mtp->ks_shortdesc, - allocs, frees, allocs - frees); + db_printf("%18s %12ju %12juK %12ju\n", + mtp->ks_shortdesc, allocs - frees, + (alloced - freed + 1023) / 1024, allocs); } } #endif |