On Thu, 3 Oct 2024, Andrew C Aitchison via clamav-users wrote:
On Wed, 2 Oct 2024, Mikhail Soumar via clamav-users wrote:
Hello,
We are using sigtool to decompile the standard clamav virus signature
databases in a low-memory environment. However, the process is too
short-lived for us to accurately measure peak usage. Is there a way we can
get an estimate (or is it known and documented somewhere?) of how much
memory is needed to run sigtool?
valgrind will give you total memory usage.
It may or may not be possible to make it report peak usage too.
Loooking deeper, I believe that on Linux
strace -ebrk sigtool your_sigtool_options
will give you enough to calculate peak usage:
strace -ebrk sigtool --md5 /var/lib/clamav/daily.cld
brk(NULL) = 0x5fd6086e2000
brk(NULL) = 0x5fd6086e2000
brk(0x5fd608703000) = 0x5fd608703000
brk(0x5fd608725000) = 0x5fd608725000
Taking the difference between the extreme values
gives 0x43000 or 274432 bytes.
ls -l /usr/bin/sigtool
-rwxr-xr-x 1 root root 13126328 Sep 6 19:27 /usr/bin/sigtool*
So I figure that the value calculated from brk does not include the
memory used to load the program itself.
`valgrind sigtool --md5 /var/lib/clamav/daily.cld` reports
==1092231== HEAP SUMMARY:
==1092231== in use at exit: 3,322 bytes in 8 blocks
==1092231== total heap usage: 5,032 allocs, 5,024 frees, 289,321 bytes
allocated
in this case 289321 and 274432 are comparable,
but if the program runs for longer and mallocs/frees memory successive
blocks of memory, I think the valgrind value will increase much more than
the brk values.
Inferring from the Linux 'brk' man page, some or all of
strace -emalloc command ...
ltrace -esbrk command ...
ltrace -emalloc command ...
may be useful on other posix-like systems.
--
Andrew C. Aitchison Kendal, UK
and...@aitchison.me.uk
_______________________________________________
Manage your clamav-users mailing list subscription / unsubscribe:
https://lists.clamav.net/mailman/listinfo/clamav-users
Help us build a comprehensive ClamAV guide:
https://github.com/Cisco-Talos/clamav-documentation
https://docs.clamav.net/#mailing-lists-and-chat