How to Use the Smem command line to check the memory usage on Ubuntu

Source: Internet
Author: User

How to Use the Smem command line to check the memory usage on Ubuntu

To check the memory usage in Ubuntu Linux, we can install and use the Smem memory reporting tool to display the memory usage in Ubutnu Linux. Smem is a command line tool used to check the memory usage, percentage, or chart of each process in Linux.

Smem is a tool that provides a large amount of memory usage reports on Linux systems. Different from existing tools, smem can report the ratio set size (PSS), which is a more meaningful representation of the amount of memory used by libraries and applications in the virtual memory system.

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

  • Unique Set Size (USS)-memory that is not remembered. The memory is not shared with any other process.
  • Proportional Set Size (PSS)-shares the memory of a process. In short, it is the share of shared memory.

USS and PSS only include physical memory usage. They do not include the memory that has been swapped out to the disk. The final memory usage can be reported through process, user, ing, full system text mode, or graphic mode output.

Smem function:

  • System overview list
  • List by process, ing, user
  • Filter by process, ing or user
  • Configurable columns from multiple data sources
  • Configurable output unit and percentage
  • Configurable titles and total
  • Read real-time data from/proc
  • Read data snapshots from directory images or compressed tarball
  • Capture tools for lightweight embedded systems
  • Built-in chart generation

Smem requirements:

  • Linux Kernel that provides the "Pss" Metric in/proc // smaps (usually 2.6.27 or later ).
  • Python 2.x( at least 2.4 or so ).
  • Matplotlib Library (only when you want to generate a graph chart ).
Install smem on Ubuntu

Run the following command on the terminal to install the latest smem tool:

Sudo apt-get update
Sudo apt-get install smem

Note that smem is mainly a command line tool that can be accessed through a terminal.

Use smem on Ubuntu

Once the installation is successful, you can use it easily. Smem is a command line tool that can be accessed through a terminal. There are various command line options smem command. You can map the user or system to remember the usage. By default, smem displays each running process and memory used. Here you begin to notice the usage of the RSS report memory relative to USS and PSS.

If these options are not included, all processes, users, or mappings report memory usage. (Note: If you run as a non-root user and do not use the-source option, you can only view the data of the/proc/information process that you have the right to access .)

Example 1: display the memeory used by each database.

$ smem -m

Example 2: displays the memory used by a specific application. The following command displays the memory usage of Firefox. The-p option displays memory usage in percentage.

$ smem -m -p | grep firefox

Example 3: display the memory used in the pie chart media (RSS is marked by a name ).

$ smem --pie name -s rss

Similar to displaying bar chart memory usage (marked as pid), run the command smem-bar pid-c "pss uss" on the terminal"

The following are various options for the smem command.


  • -M,-mappings reports memory usage through ing.
  • -U,-users reports the user's memory usage.
  • -W,-system reports system memory usage summary.


  • M mapfilter,-mapfilter = MAPFILTER ing filter regular expression.
  • -P processfilter,-processfilter = PROCESSFILTER: Process filters regular expressions.
  • -U userfilter,-userfilter = USERFILTER: the user filters regular expressions.

Output Format

  • -C COLUMNS,-columns = COLUMNS column to be displayed.
  • -H,-no-header to disable the title line.
  • -K,-abbreviate indicates the unit suffix.
  • -N,-numeric shows the digital user ID instead of the user name.
  • -P,-percent indicates the percentage.
  • -R,-reverse sorting.
  • -S SORT and-sort = SORT fields are sorted.
  • -T,-totals shows the total.

Output type

These options specify the image output style.

  • -Bar = BAR: displays a bar chart.
  • -Pie = PIE: the pie chart is displayed.

Use Information commands for any help or more information.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.