smem is a tool that can give numerous reports on memory usage on Linux systems. Unlike existing tools, smem can report proportional set size (PSS), which is a more meaningful representation of the amount of memory used by libraries and applications in a virtual memory system. Because large portions of physical memory are typically shared among multiple applications, the standard measure of memory usage known as resident set size (RSS) will significantly overestimate memory usage.

Execution & Command Syntax

Terminalbash
sed by libraries and applications in a virtual memory system
Terminalbash
sudo apt install mercurial $ hg clone http://selenic

Risk level: caution. Review the command before running it.

Terminalbash
gcc smemcap

Technical Implementation Details

PSS instead measures each application’s “fair share” of each shared area to give a realistic measure. For more details of smem, refer to smem website Compile SMEM for Embedded Linux Target $ sudo apt install mercurial $ hg clone http://selenic.com/repo/smem $ cd smem You can cross compile smem using cross toolchain as, $ arm-linux-gnueabi-gcc smemcap.c -o smem-arm You can also static cross compile to avoid any library loading errors for embedded targets as, $ arm-linux-gnueabi-gcc smemcap.c -static -o smem-arm-static Now, if you are testing on Embedded platform, push/copy the cross compiled binary to embedded target and run the command to capture the reports as, $ ./smem-arm > smem_reports.tar For Ubuntu / Desktop Linux You can install smem using below command, $ sudo apt-get install smem Now, generate the smem report as, $ smem --pie=command here, we are saving the the collected memory report to /tmp directory, you can save it to any location. For Android, Since android uses different toolchain, its better to push static smem and use it to generate the smem_reports.tar and use the same to analyse. Using below command we pushed smem static to android device over adb and pulled the logs using adb, other steps to analyse the reports remains same as other embedded targets. $ adb push smem-arm-static /sdcard $ adb shell $ chmod 777 /sdcard/smem-arm-static $ cd /sdcard $ ./smem-arm-static > smem_reports.tar $ exit $ adb pull /sdcard/smem_reports.tar For other usage of smem command, refer to smem website as mentioned earlier, in this post, we will just demo how you can create proper report using smem. Now download this smem_reports.tar to your Linux host / PC.

Gotchas and Common Issues

  • Permission Verification - confirm execution permissions and path variables before invoking system binaries.

  • Version Compatibility - check software version release notes for deprecated flags or syntax changes.

  • Log Monitoring - inspect system logs (journalctl or /var/log) to troubleshoot execution failures.

Following these steps ensures clean configuration, proper security boundaries, and reliable execution for check memory usage in linux using smem.