<link href="//fonts.googleapis.com/css?family=Roboto+Slab:700%7CRoboto:700%7CRoboto:normal" rel="stylesheet">

How To Check Memory Usage On Ubuntu Via Command Line

How to check memory usage on Linux Ubuntu. Install and use Smem memory reporting tool to show Memory usage on Linux Ubutnu systems. Smem is a commandline tool to check memory usage in Linux, per process, in percentage or in charts.

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.

smem-memory

Smem reports Unique Set Size (USS) and Proportional Set Size (PSS) using the standard measure of memory known as Resident Set Size(RSS).

  • Unique Set Size (USS) – Unsahred memory. Memory that is not shared with any other process.
  • Proportional Set Size (PSS) – Shared memory for a process. In simple terms, it is the share of the shared memory.

The USS and PSS only include physical memory usage. They do not include memory that has been swapped out to disk. The final memory usage can be reported by process, by user, by mapping, or systemwide in text mode or graphical mode output.

smem features:

  • system overview listing
  • listings by process, mapping, user
  • filtering by process, mapping, or user
  • configurable columns from multiple data sources
  • configurable output units and percentages
  • configurable headers and totals
  • reading live data from /proc
  • reading data snapshots from directory mirrors or compressed tarballs
  • lightweight capture tool for embedded systems
  • built-in chart generation

smem requirements:

  • Linux kernel providing ‘Pss’ metric in /proc//smaps (generally 2.6.27 or newer).
  • Python 2.x (at least 2.4 or so).
  • The matplotlib library (only if you want to generate graphical charts).

Install smem on Ubuntu

Run the following commands in Terminal to install the latest version of smem tool:

sudo apt-get update
sudo apt-get install smem

Please note that smem is primarily a commandline tool and can be accessed via Terminal.

Using smem smem on Ubuntu

Once smem is successfully installed, users can use it easily. Smem is a commandline tool and can be accessed via Terminal. There are various commandline options for smem command. Users can memory usage by mapping, user or sytemwide. By default, smem will show each running process and the memory used. Here you start to note the way RSS reports memory used relative to USS and PSS.

If none of these options are included, memory usage is reported for all processes, users, or mappings. (Note: If you are running as a non-root user, and if you are not using the –source options, then you will only see data from processes whose /proc/ information you have access to.)

Example 1: Show memeory used as per library.
$ smem -m

smem-01

Example 2: Show memeory used as per a specific application. The below given command will display the memory usage by Firefox. The -p option displays memory usage in percentage.
$ smem -m -p | grep firefox

smem-02

Example 3: Show memeory used in a pie chart medium (RSS labeled by name).
$ smem --pie name -s rss

Similarly to show a bar chart memory usage (labeled by pid) run the command smem –bar pid -c “pss uss” in Terminal

Below are the various options that can be used with smem command.

Report By

  • -m, –mappings Report memory usage by mapping.
  • -u, –users Report memory usage by user.
  • -w, –system Report systemwide memory usage summary.

Filter By

  • M MAPFILTER, –mapfilter=MAPFILTER Mapping filter regular expression.
  • -P PROCESSFILTER, –processfilter=PROCESSFILTER Process filter regular expression.
  • -U USERFILTER, –userfilter=USERFILTER User filter regular expression.

Output Formatting

  • -c COLUMNS, –columns=COLUMNS Columns to show.
  • -H, –no-header Disable header line.
  • -k, –abbreviate Show unit suffixes.
  • -n, –numeric Show numeric user IDs instead of usernames.
  • -p, –percent Show percentages.
  • -r, –reverse Reverse sort.
  • -s SORT, –sort=SORT Field to sort on.
  • -t, –totals Show totals.

Output Type

These options specify graphical output styles.

  • –bar=BAR Show bar graph.
  • –pie=PIE Show pie graph.

For any help or more info use info command.
http://manpages.ubuntu.com/manpages/wily/man8/smem.8.html

Leave a Reply