1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-03-09 15:50:02 +00:00

tests/leaks.sh: add procfs method for Linux

This allows faster testing for memory leaks on Linux if
ksh is compiled without vmalloc.
This commit is contained in:
Martijn Dekker 2021-01-28 07:26:40 +00:00
parent ab6b483b17
commit 005d38f410

View file

@ -44,6 +44,15 @@ then N=512 # number of iterations for each test
{
vmstate --format='%(busy_size)u'
}
# On Linux, we can use /proc to get byte granularity for vsize (field 23).
elif [[ -f /proc/$$/stat && $(uname) == Linux ]]
then N=1024 # number of iterations for each test
unit=bytes
tolerance=$((4*N)) # tolerate 4 bytes per iteration to account for malloc artefacts
function getmem
{
cut -f 23 -d ' ' </proc/$$/stat
}
# Otherwise, make do with the nonstandard 'rss' (real resident size) keyword
# of the 'ps' command (the standard 'vsz', virtual size, is not usable).
elif n=$(ps -o rss= -p "$$" 2>/dev/null) &&