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:
parent
ab6b483b17
commit
005d38f410
1 changed files with 9 additions and 0 deletions
|
@ -44,6 +44,15 @@ then N=512 # number of iterations for each test
|
||||||
{
|
{
|
||||||
vmstate --format='%(busy_size)u'
|
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
|
# Otherwise, make do with the nonstandard 'rss' (real resident size) keyword
|
||||||
# of the 'ps' command (the standard 'vsz', virtual size, is not usable).
|
# of the 'ps' command (the standard 'vsz', virtual size, is not usable).
|
||||||
elif n=$(ps -o rss= -p "$$" 2>/dev/null) &&
|
elif n=$(ps -o rss= -p "$$" 2>/dev/null) &&
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue