Source-Changes archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
CVS commit: src/usr.bin/make
Module Name: src
Committed By: rillig
Date: Sat Jun 11 17:58:15 UTC 2022
Modified Files:
src/usr.bin/make: parse.c
Log Message:
make: fix memory leak in wildcard targets and sources
$ cat <<'EOF' > glob-leak.mk
all:
@pid=$$$$; \
ppid=$$(ps -o ppid -p "$$pid" | sed 1d); \
ps -o vsz,rsz -p $$ppid | sed 1d
.for _ in ${:U:${:Urange=$n}}
bin/*: source
.endfor
EOF
$ make.before -r -f glob-leak.mk n=1
19424 5280
$ make.before -r -f glob-leak.mk n=10
24220 10208
$ make.before -r -f glob-leak.mk n=100
71280 58504
$ make.before -r -f glob-leak.mk n=1000
556356 541620
$ make.after -r -f glob-leak.mk n=1
19208 5040
$ make.after -r -f glob-leak.mk n=10
22132 8092
$ make.after -r -f glob-leak.mk n=100
49040 35940
$ make.after -r -f glob-leak.mk n=1000
324160 314400
That's a saving of 40% already. The remaining 60% are suspicious as
well since after the first iteration of the .for loop, make's internal
state doesn't change conceptually, so there's no need to throw more
memory at it.
To generate a diff of this commit:
cvs rdiff -u -r1.678 -r1.679 src/usr.bin/make/parse.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Home |
Main Index |
Thread Index |
Old Index