1 /* mstats.h - definitions for malloc statistics */
3 /* Copyright (C) 2001-2020 Free Software Foundation, Inc.
5 This file is part of GNU Bash, the Bourne-Again SHell.
7 Bash is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
12 Bash is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with Bash. If not, see <http://www.gnu.org/licenses/>.
28 /* This needs to change if the definition in malloc.c changes */
34 * NMALLOC[i] is the difference between the number of mallocs and frees
35 * for a given block size. TMALLOC[i] is the total number of mallocs for
36 * a given block size. NMORECORE[i] is the total number of calls to
37 * morecore(i). NLESSCORE[i] is the total number of calls to lesscore(i).
39 * NMAL and NFRE are counts of the number of calls to malloc() and free(),
40 * respectively. NREALLOC is the total number of calls to realloc();
41 * NRCOPY is the number of times realloc() had to allocate new memory and
42 * copy to it. NRECURSE is a count of the number of recursive calls to
43 * malloc() for the same bucket size, which can be caused by calls to
44 * malloc() from a signal handler.
46 * NSBRK is the number of calls to sbrk() (whether by morecore() or for
47 * alignment); TSBRK is the total number of bytes requested from the kernel
50 * BYTESUSED is the total number of bytes consumed by blocks currently in
51 * use; BYTESFREE is the total number of bytes currently on all of the free
52 * lists. BYTESREQ is the total number of bytes requested by the caller
53 * via calls to malloc() and realloc().
55 * TBSPLIT is the number of times a larger block was split to satisfy a
56 * smaller request. NSPLIT[i] is the number of times a block of size I was
59 * TBCOALESCE is the number of times two adjacent smaller blocks off the free
60 * list were combined to satisfy a larger request.
63 int nmalloc
[NBUCKETS
];
64 int tmalloc
[NBUCKETS
];
65 int nmorecore
[NBUCKETS
];
66 int nlesscore
[NBUCKETS
];
80 int ncoalesce
[NBUCKETS
];
85 /* Return statistics describing allocation of blocks of size BLOCKSIZE.
86 NFREE is the number of free blocks for this allocation size. NUSED
87 is the number of blocks in use. NMAL is the number of requests for
88 blocks of size BLOCKSIZE. NMORECORE is the number of times we had
89 to call MORECORE to repopulate the free list for this bucket.
90 NLESSCORE is the number of times we gave memory back to the system
91 from this bucket. NSPLIT is the number of times a block of this size
92 was split to satisfy a smaller request. NCOALESCE is the number of
93 times two blocks of this size were combined to satisfy a larger
104 int nmmap
; /* currently unused */
107 extern struct bucket_stats malloc_bucket_stats
PARAMS((int));
108 extern struct _malstats malloc_stats
PARAMS((void));
109 extern void print_malloc_stats
PARAMS((char *));
110 extern void trace_malloc_stats
PARAMS((char *, char *));
112 #endif /* MALLOC_STATS */
114 #endif /* _MSTATS_H */