SMEM(8)

๐Ÿ“ฆ
version 1.5 ยท 2 versions
, in epel 10, epel 9, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0

๐Ÿ’– SMEM(8) โ€” smem, the memory tea spiller ๐Ÿ’–

okay so bestie, welcome to smem(8) โ€” the page for smem, the tool that reports memory usage with shared memory divided proportionally. Itโ€™s giving โ€œwho is using the RAM and how do we split the shared bits fairlyโ€ energy, and honestly? Iconic.


โœจ NAME โœจ

smem โ€” Report memory usage with shared memory divided proportionally.


๐ŸŒธ SYNOPSIS ๐ŸŒธ

smem [options]

๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

smem reports physical memory usage, taking shared memory pages into account. Unshared memory is reported as the USS (Unique Set Size). Shared memory is divided evenly among the processes sharing that memory. The unshared memory (USS) plus a process's proportion of shared memory is reported as the PSS (Proportional Set Size). The USS and PSS only include physical memory usage. They do not include memory that has been swapped out to disk.

Memory can be reported by process, by user, by mapping, or systemwide. Both text mode and graphical output are available. Versatility queen. ๐Ÿ‘‘


๐Ÿ’… OPTIONS ๐Ÿ’…

๐Ÿ’– GENERAL OPTIONS ๐Ÿ’–

  • -h, --help โ€” Show help. Cute and simple, no notes. โœจ

๐Ÿ” SOURCE DATA ๐Ÿ”

By default, smem will pull most of the data it needs from the /proc filesystem of the system it is running on. The --source option lets you used a tarred set of /proc data saved earlier, possibly on a different machine. The --kernel and --realmem options let you specify a couple things that smem cannot discover on its own.

  • -K KERNEL, --kernel=KERNEL โ€” Path to an uncompressed kernel image. This lets smem include the size of the kernel's code and statically allocated data in the systemwide (-w) output. (To obtain an uncompressed image of a kernel on disk, you may need to build the kernel yourself, then locate file vmlinux in the source tree.)
  • -R REALMEM, --realmem=REALMEM โ€” Amount of physical RAM. This lets smem detect the amount of memory used by firmware/hardware in the systemwide (-w) output. If provided, it will also be used as the total memory size to base percentages on. Example: --realmem=1024M
  • -S SOURCE, --source=SOURCE โ€” /proc data source. This lets you specify an alternate source of the /proc data. For example, you can capture data from an embedded system using smemcap, and parse the data later on a different machine. If the --source option is not included, smem reports memory usage on the running system.

๐ŸŽ€ REPORT BY ๐ŸŽ€

If none of the following options are included, smem reports memory usage by process.

  • -m, --mappings โ€” Report memory usage by mapping. ๐Ÿ—บ๏ธ
  • -u, --users โ€” Report memory usage by user. ๐Ÿซถ
  • -w, --system โ€” Report systemwide memory usage summary. ๐ŸŒˆ

๐ŸŒŸ FILTER BY ๐ŸŒŸ

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.)

  • -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 โญ

  • -a, --autosize โ€” Size columns to fit terminal size. ๐Ÿ“
  • -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. Chart girlies, rise. ๐Ÿ“Š

  • --bar=BAR โ€” Show bar graph. ๐Ÿ“Š
  • --pie=PIE โ€” Show pie graph. ๐Ÿฅง

๐Ÿงš REQUIREMENTS ๐Ÿงš

smem requires:

  • Linux kernel providing 'Pss' metric in /proc/<pid>/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). ๐Ÿ“ˆ

๐Ÿซถ EMBEDDED USAGE ๐Ÿซถ

To capture memory statistics on resource-constrained systems, the smem source includes a utility named smemcap. smemcap captures all /proc entries required by smem and outputs them as an uncompressed .tar file to STDOUT. smem can analyze the output using the --source option. smemcap is small and does not require Python. Low-key genius behavior. ๐Ÿงš

To use smemcap:

  1. Obtain the smem source at http://selenic.com/repo/smem
  2. Compile smemcap.c for your target system.
  3. Run smemcap on the target system and save the output:
smemcap > memorycapture.tar
  1. Copy the output to another machine and run smem on it:
smem -S memorycapture.tar

๐Ÿ’œ FILES ๐Ÿ’œ

  • /proc/$pid/cmdline
  • /proc/$pid/smaps
  • /proc/$pid/stat
  • /proc/meminfo
  • /proc/version

๐Ÿ‘‘ RESOURCES ๐Ÿ‘‘


๐ŸŒˆ SEE ALSO ๐ŸŒˆ

free(1), pmap(1), proc(5), ps(1), top(1), vmstat(8)


๐ŸŽ€ COPYING ๐ŸŽ€

Copyright (C) 2008-2009 Matt Mackall. Free use of this software is granted under the terms of the GNU General Public License version 2 or later.


๐Ÿ’– AUTHOR ๐Ÿ’–

smem was written by Matt Mackall.


mwah ๐Ÿ’‹ โ€” thatโ€™s the whole vibe, bestie: SMEM(8), dated 03/15/2010, and yes, she ate. ๐Ÿ’…๐Ÿ’–