I am using valgrind to check heap allocation of archive/compression tool p7zip (7zip on Windows) on Linux. I downloaded the code from here (https://sourceforge.net/projects/p7zip/files/p7zip/) and build it (make all_test) and then installed it (./install.sh).
After installation, a shell script named '7Za' is created at /usr/local/bin and its content reads as:
#! /bin/sh
"/usr/local/lib/p7zip/7za" "$@"
Also, on the specified path /usr/local/lib/p7zip/7za the executable of 7za is placed.
Now, if I run valgrind to test the memory usage of 7za (which basically runs the shell script) using this command then I get just 2KB of heap usage.
valgrind 7za x file.7z
Whereas, if I directly use the 7za binary then I get high memory usage around 1MB which also looks real one:
valgrind /usr/local/lib/p7zip/7za x /home/z/Desktop/file.7z
Similary, when I build the code, a bin directory is created there containing 7za executable. If I run it from there, then I again get high and correct memory usage.
I am trying to understand what is the difference in both approaches. Why using installed app (run through sheel script) does not give correct memory usage.
valgrind is supposed to debug memory related problems for ELF 64-bit or ELF 32-bit exectuables. It can't be used with shell scripts. So you won't be able to debug your application using the shell script.