* Copyright (c) 1993 The Regents of the University of California.
* %sccs.include.redist.c%
static char sccsid
[] = "@(#)mem.c 5.1 (Berkeley) %G%";
static struct nlist nl
[] = {
* These names are defined in <sys/malloc.h>.
char *kmemnames
[] = INITKMEMNAMES
;
register struct kmembuckets
*kp
;
register struct kmemstats
*ks
;
long totuse
= 0, totfree
= 0, totreq
= 0;
struct kmemstats kmemstats
[M_LAST
];
struct kmembuckets buckets
[MINBUCKET
+ 16];
kread(nl
[X_BUCKET
].n_value
, &buckets
, sizeof buckets
, "kmembucket");
(void)printf("Memory statistics by bucket size\n");
" Size In Use Free Requests HighWater Couldfree\n");
for (i
= MINBUCKET
, kp
= &buckets
[i
]; i
< MINBUCKET
+ 16; i
++, kp
++) {
(void)printf("%8d %8ld %6ld %10ld %7ld %10ld\n", size
,
kp
->kb_total
- kp
->kb_totalfree
,
kp
->kb_totalfree
, kp
->kb_calls
,
kp
->kb_highwat
, kp
->kb_couldfree
);
totfree
+= size
* kp
->kb_totalfree
;
kread(nl
[X_KMEMSTATS
].n_value
, &kmemstats
, sizeof kmemstats
,
(void)printf("\nMemory statistics by type\n");
" Type In Use MemUse HighUse Limit Requests TypeLimit KernLimit\n");
for (i
= 0, ks
= &kmemstats
[0]; i
< M_LAST
; i
++, ks
++) {
(void)printf("%11s %6ld %7ldK %8ldK %5ldK %8ld %6u %9u\n",
kmemnames
[i
] ? kmemnames
[i
] : "undefined",
ks
->ks_inuse
, (ks
->ks_memuse
+ 1023) / 1024,
(ks
->ks_maxused
+ 1023) / 1024,
(ks
->ks_limit
+ 1023) / 1024, ks
->ks_calls
,
ks
->ks_limblocks
, ks
->ks_mapblocks
);
(void)printf("\nMemory Totals: In Use Free Requests\n");
(void)printf(" %7ldK %6ldK %8ld\n",
(totuse
+ 1023) / 1024, (totfree
+ 1023) / 1024, totreq
);