How to Check Memory Usage in Linux using SMEM ?

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. 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
$ 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,

Subscribe with Valid Email Id to receive updates in Inbox. ( Secured by Google FeedBurner )


$ smem --pie=command

here, we are saving the the collected memory report to /tmp directory, you can save it to any location.

Related :   What is the difference between elfutils and binutils ?

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. Install smem for host as,

$ sudo apt-get install smem

We install smem for host since it will also install the other required packages such as python-matplotlib which are required to create chart reports.

Now, you can create report as,

$ smem -S smem_reports.tar --pie=command

Reference –


Leave a Comment

Android Android Build system Android Commands Android Java Applications Application Libraries Application Stack / User Interface Bash / Shell Scripts Bluetooth driver Cloud Technologies Commands and Packages Compilation Content Management System Core Kernel C Programs Development & Build Development, Debugging and Performance Tools Development Environment Setup Django & REST Api Errors & Failures Git Hardware Platforms HTML JAVA Programs Linux, OS Concepts and Networking Linux Device Drivers Linux Host, Ubuntu, SysAdmin Linux Kernel Linux Networking Middleware Libraries, HAL Multimedia Audio, Video, Images NDK / Middleware / HAL OS Concepts PHP Programming Languages Scripting and Automation Search Engine Optimisation ( SEO ) Social Media Source Code Management ( SCM ) System Administration, Security Testing and Debugging Uncategorized Web design and development Website Hosting Wordpress Yocto / Bitbake / Openembedded