]> git.ipfire.org Git - thirdparty/bash.git/blame - lib/malloc/mstats.h
Bash-4.3 distribution sources and documentation
[thirdparty/bash.git] / lib / malloc / mstats.h
CommitLineData
f73dda09
JA
1/* mstats.h - definitions for malloc statistics */
2
b80f6443 3/* Copyright (C) 2001-2003 Free Software Foundation, Inc.
f73dda09 4
3185942a
JA
5 This file is part of GNU Bash, the Bourne-Again SHell.
6
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.
11
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.
16
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/>.
19*/
f73dda09
JA
20
21#ifndef _MSTATS_H
22#define _MSTATS_H
23
24#include "imalloc.h"
25
26#ifdef MALLOC_STATS
27
28#ifndef NBUCKETS
29# define NBUCKETS 30
30#endif
31
32/*
33 * NMALLOC[i] is the difference between the number of mallocs and frees
34 * for a given block size. TMALLOC[i] is the total number of mallocs for
35 * a given block size. NMORECORE[i] is the total number of calls to
7117c2d2
JA
36 * morecore(i). NLESSCORE[i] is the total number of calls to lesscore(i).
37 *
38 * NMAL and NFRE are counts of the number of calls to malloc() and free(),
39 * respectively. NREALLOC is the total number of calls to realloc();
40 * NRCOPY is the number of times realloc() had to allocate new memory and
41 * copy to it. NRECURSE is a count of the number of recursive calls to
42 * malloc() for the same bucket size, which can be caused by calls to
43 * malloc() from a signal handler.
44 *
45 * NSBRK is the number of calls to sbrk() (whether by morecore() or for
46 * alignment); TSBRK is the total number of bytes requested from the kernel
47 * with sbrk().
48 *
49 * BYTESUSED is the total number of bytes consumed by blocks currently in
50 * use; BYTESFREE is the total number of bytes currently on all of the free
51 * lists. BYTESREQ is the total number of bytes requested by the caller
52 * via calls to malloc() and realloc().
53 *
54 * TBSPLIT is the number of times a larger block was split to satisfy a
55 * smaller request. NSPLIT[i] is the number of times a block of size I was
56 * split.
57 *
f73dda09
JA
58 * TBCOALESCE is the number of times two adjacent smaller blocks off the free
59 * list were combined to satisfy a larger request.
60 */
61struct _malstats {
62 int nmalloc[NBUCKETS];
63 int tmalloc[NBUCKETS];
64 int nmorecore[NBUCKETS];
7117c2d2 65 int nlesscore[NBUCKETS];
f73dda09
JA
66 int nmal;
67 int nfre;
68 int nrealloc;
69 int nrcopy;
70 int nrecurse;
71 int nsbrk;
72 bits32_t tsbrk;
73 bits32_t bytesused;
74 bits32_t bytesfree;
7117c2d2 75 u_bits32_t bytesreq;
f73dda09
JA
76 int tbsplit;
77 int nsplit[NBUCKETS];
78 int tbcoalesce;
7117c2d2 79 int ncoalesce[NBUCKETS];
f73dda09
JA
80};
81
82/* Return statistics describing allocation of blocks of size BLOCKSIZE.
83 NFREE is the number of free blocks for this allocation size. NUSED
84 is the number of blocks in use. NMAL is the number of requests for
85 blocks of size BLOCKSIZE. NMORECORE is the number of times we had
7117c2d2
JA
86 to call MORECORE to repopulate the free list for this bucket.
87 NLESSCORE is the number of times we gave memory back to the system
88 from this bucket. NSPLIT is the number of times a block of this size
89 was split to satisfy a smaller request. NCOALESCE is the number of
90 times two blocks of this size were combined to satisfy a larger
91 request. */
f73dda09
JA
92struct bucket_stats {
93 u_bits32_t blocksize;
94 int nfree;
95 int nused;
96 int nmal;
97 int nmorecore;
7117c2d2 98 int nlesscore;
f73dda09 99 int nsplit;
7117c2d2 100 int ncoalesce;
f73dda09
JA
101};
102
7117c2d2
JA
103extern struct bucket_stats malloc_bucket_stats __P((int));
104extern struct _malstats malloc_stats __P((void));
105extern void print_malloc_stats __P((char *));
106extern void trace_malloc_stats __P((char *, char *));
f73dda09
JA
107
108#endif /* MALLOC_STATS */
109
110#endif /* _MSTATS_H */