Skip to content
Navigation Menu
Toggle navigation
Sign in
In this repository
All GitHub Enterprise
↵
Jump to
↵
No suggested jump to results
In this repository
All GitHub Enterprise
↵
Jump to
↵
In this organization
All GitHub Enterprise
↵
Jump to
↵
In this repository
All GitHub Enterprise
↵
Jump to
↵
Sign in
Reseting focus
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
git-mirror
/
glibc
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
0
Security
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security
Insights
Files
e56bad6
abilist
aout
argp
assert
bare
bits
catgets
conf
conform
crypt
csu
ctype
debug
dirent
dlfcn
elf
gmon
gnulib
grp
hesiod
hurd
iconv
iconvdata
include
inet
intl
io
libidn
libio
locale
localedata
login
mach
malloc
Depend
Makefile
Versions
arena.c
hooks.c
malloc.c
malloc.h
mallocbug.c
mcheck-init.c
mcheck.c
mcheck.h
memusage.c
memusage.sh
memusagestat.c
morecore.c
mtrace.c
mtrace.pl
obstack.c
obstack.h
set-freeres.c
thread-freeres.c
tst-calloc.c
tst-malloc.c
tst-mallocfork.c
tst-mallocstate.c
tst-mcheck.c
tst-mtrace.c
tst-mtrace.sh
tst-obstack.c
tst-valloc.c
manual
math
misc
nis
nptl
nptl_db
nscd
nss
po
posix
pwd
resolv
resource
rt
scripts
setjmp
shadow
signal
socket
soft-fp
stdio-common
stdlib
streams
string
sunrpc
sysdeps
sysvipc
termios
time
timezone
wcsmbs
wctype
.cvsignore
BUGS
CANCEL-FCT-WAIVE
CANCEL-FILE-WAIVE
CONFORMANCE
COPYING
COPYING.LIB
ChangeLog
ChangeLog.1
ChangeLog.10
ChangeLog.11
ChangeLog.12
ChangeLog.13
ChangeLog.14
ChangeLog.15
ChangeLog.2
ChangeLog.3
ChangeLog.4
ChangeLog.5
ChangeLog.6
ChangeLog.7
ChangeLog.8
ChangeLog.9
FAQ
FAQ.in
INSTALL
INTERFACE
LICENSES
MakeTAGS
Makeconfig
Makefile
Makefile.in
Makerules
NAMESPACE
NEWS
NOTES
PROJECTS
README
README.libm
README.template
Rules
Versions.def
WUR-REPORT
abi-tags
aclocal.m4
config-name.in
config.h.in
config.make.in
configure
configure.in
cppflags-iterator.mk
extra-lib.mk
extra-modules.mk
o-iterator.mk
shlib-versions
test-skeleton.c
tls.make.c
version.h
Breadcrumbs
glibc
/
malloc
/
memusage.sh
Blame
Blame
Latest commit
History
History
executable file
·
272 lines (247 loc) · 7.47 KB
Breadcrumbs
glibc
/
malloc
/
memusage.sh
Top
File metadata and controls
Code
Blame
executable file
·
272 lines (247 loc) · 7.47 KB
Raw
#! @BASH@ # Copyright (C) 1999-2004, 2005, 2006 Free Software Foundation, Inc. # This file is part of the GNU C Library. # Contributed by Ulrich Drepper <drepper@gnu.org>, 1999. # The GNU C Library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # The GNU C Library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # You should have received a copy of the GNU Lesser General Public # License along with the GNU C Library; if not, write to the Free # Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA # 02111-1307 USA. memusageso=@SLIBDIR@/libmemusage.so memusagestat=@BINDIR@/memusagestat TEXTDOMAIN=libc # Print usage message. do_usage() { echo >&2 $"Try \`memusage --help' for more information." exit 1 } # Message for missing argument. do_missing_arg() { echo >&2 $"memusage: option \`$1' requires an argument" do_usage } # Print help message do_help() { echo $"Usage: memusage [OPTION]... PROGRAM [PROGRAMOPTION]... Profile memory usage of PROGRAM. -n,--progname=NAME Name of the program file to profile -p,--png=FILE Generate PNG graphic and store it in FILE -d,--data=FILE Generate binary data file and store it in FILE -u,--unbuffered Don't buffer output -b,--buffer=SIZE Collect SIZE entries before writing them out --no-timer Don't collect additional information though timer -m,--mmap Also trace mmap & friends -?,--help Print this help and exit --usage Give a short usage message -V,--version Print version information and exit The following options only apply when generating graphical output: -t,--time-based Make graph linear in time -T,--total Also draw graph of total memory use --title=STRING Use STRING as title of the graph -x,--x-size=SIZE Make graphic SIZE pixels wide -y,--y-size=SIZE Make graphic SIZE pixels high Mandatory arguments to long options are also mandatory for any corresponding short options. For bug reporting instructions, please see: <http://www.gnu.org/software/libc/bugs.html>." exit 0 } do_version() { echo 'memusage (GNU libc) @VERSION@' printf $"Copyright (C) %s Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. " "2006" printf $"Written by %s. " "Ulrich Drepper" exit 0 } # Process arguments. But stop as soon as the program name is found. while test $# -gt 0; do case "$1" in -V | --v | --ve | --ver | --vers | --versi | --versio | --version) do_version ;; -\? | --h | --he | --hel | --help) do_help ;; --us | --usa | --usag | --usage) echo $"Syntax: memusage [--data=FILE] [--progname=NAME] [--png=FILE] [--unbuffered] [--buffer=SIZE] [--no-timer] [--time-based] [--total] [--title=STRING] [--x-size=SIZE] [--y-size=SIZE] PROGRAM [PROGRAMOPTION]..." exit 0 ;; -n | --pr | --pro | --prog | --progn | --progna | --prognam | --progname) if test $# -eq 1; then do_missing_arg $1 fi shift progname="$1" ;; --pr=* | --pro=* | --prog=* | --progn=* | --progna=* | --prognam=* | --progname=*) progname=${1##*=} ;; -p | --pn | --png) if test $# -eq 1; then do_missing_arg $1 fi shift png="$1" ;; --pn=* | --png=*) png=${1##*=} ;; -d | --d | --da | --dat | --data) if test $# -eq 1; then do_missing_arg $1 fi shift data="$1" ;; --d=* | --da=* | --dat=* | --data=*) data=${1##*=} ;; -u | --un | --unb | --unbu | --unbuf | --unbuff | --unbuffe | --unbuffer | --unbuffere | --unbuffered) buffer=1 ;; -b | --b | --bu | --buf | --buff | --buffe | --buffer) if test $# -eq 1; then do_missing_arg $1 fi shift buffer="$1" ;; --b=* | --bu=* | --buf=* | --buff=* | --buffe=* | --buffer=*) buffer=${1##*=} ;; --n | --no | --no- | --no-t | --no-ti | --no-tim | --no-time | --no-timer) notimer=yes ;; -m | --m | --mm | --mma | --mmap) tracemmap=yes ;; -t | --tim | --time | --time- | --time-b | --time-ba | --time-bas | --time-base | --time-based) memusagestat_args="$memusagestat_args -t" ;; -T | --to | --tot | --tota | --total) memusagestat_args="$memusagestat_args -T" ;; --tit | --titl | --title) if test $# -eq 1; then do_missing_arg $1 fi shift memusagestat_args="$memusagestat_args -s $1" ;; --tit=* | --titl=* | --title=*) memusagestat_args="$memusagestat_args -s ${1##*=}" ;; -x | --x | --x- | --x-s | --x-si | --x-siz | --x-size) if test $# -eq 1; then do_missing_arg $1 fi shift memusagestat_args="$memusagestat_args -x $1" ;; --x=* | --x-=* | --x-s=* | --x-si=* | --x-siz=* | --x-size=*) memusagestat_args="$memusagestat_args -x ${1##*=}" ;; -y | --y | --y- | --y-s | --y-si | --y-siz | --y-size) if test $# -eq 1; then do_missing_arg $1 fi shift memusagestat_args="$memusagestat_args -y $1" ;; --y=* | --y-=* | --y-s=* | --y-si=* | --y-siz=* | --y-size=*) memusagestat_args="$memusagestat_args -y ${1##*=}" ;; --p | --p=* | --t | --t=* | --ti | --ti=* | --u) echo >&2 $"memusage: option \`${1##*=}' is ambiguous" do_usage ;; --) # Stop processing arguments. shift break ;; --*) echo >&2 $"memusage: unrecognized option \`$1'" do_usage ;; *) # Unknown option. This means the rest is the program name and parameters. break ;; esac shift done # See whether any arguments are left. if test $# -eq 0; then echo >&2 $"No program name given" do_usage fi # This will be in the environment. add_env="LD_PRELOAD=$memusageso" # Generate data file name. datafile= if test -n "$data"; then datafile="$data" elif test -n "$png"; then datafile=$(mktemp ${TMPDIR:-/tmp}/memusage.XXXXXX 2> /dev/null) if test $? -ne 0; then # Lame, but if there is no `mktemp' program the user cannot expect more. if test "$RANDOM" != "$RANDOM"; then datafile=${TMPDIR:-/tmp}/memusage.$RANDOM else datafile=${TMPDIR:-/tmp}/memusage.$$ fi fi fi if test -n "$datafile"; then add_env="$add_env MEMUSAGE_OUTPUT=$datafile" fi # Set program name. if test -n "$progname"; then add_env="$add_env MEMUSAGE_PROG_NAME=$progname" fi # Set buffer size. if test -n "$buffer"; then add_env="$add_env MEMUSAGE_BUFFER_SIZE=$buffer" fi # Disable timers. if test -n "$notimer"; then add_env="$add_env MEMUSAGE_NO_TIMER=yes" fi # Trace mmap. if test -n "$tracemmap"; then add_env="$add_env MEMUSAGE_TRACE_MMAP=yes" fi # Execute the program itself. eval $add_env '"$@"' result=$? # Generate the PNG data file if wanted and there is something to generate # it from. if test -n "$png" -a -n "$datafile" -a -s "$datafile"; then # Append extension .png if it isn't already there. case $png in *.png) ;; *) png="$png.png" ;; esac $memusagestat $memusagestat_args "$datafile" "$png" fi if test -z "$data" -a -n "$datafile"; then rm -f "$datafile" fi exit $result # Local Variables: # mode:ksh # End:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
You can’t perform that action at this time.