output.mp4
mem is a blazing fast, lightweight RAM usage checker for Linux.
It is specifically optimized to parse the Linux /proc filesystem instantly, accurately accounting for shared memory while easily handling hundreds of processes in a fraction of a second.
- Instantly filters all running processes to find those matching your target query.
- Safely verifies read-access to each process's
/proc/[pid]/smaps_rollup. If the kernel denies access (e.g., when checking a root process as a standard user), it seamlessly falls back to/proc/[pid]/statusforVmRSS. - Rapidly sums up the memory values across all matched processes.
- Converts the total memory (in Kilobytes) to Megabytes (MB) using integer arithmetic.
- Bash (For the core script logic)
- grep & awk (Standard POSIX tools for high-speed calculation)
- procps / pgrep (Standard Linux utility for process matching)
- libnotify / notify-send (Required for desktop notifications in
--guimode) - An Application Launcher (Required for
--guimode). Supported out-of-the-box:fuzzelrofiwofitofibemenudmenu
- Download or copy the
memscript to a directory in your$PATH, such as~/.local/bin/:nano ~/.local/bin/mem - Make the script executable:
chmod +x ~/.local/bin/mem
Pass a process name or a fragment of a command to see its total RAM usage printed to the terminal.
$ mem discord
254.12 MB
$ mem code
982.50 MB
$ mem --all
3442.97 MBRun the script with the --gui flag. This will open your preferred application launcher, prompt you to type a process name, and then display a desktop notification with the resulting memory usage.
$ mem --guiThis is highly useful for binding to a keyboard shortcut in your Window Manager.
Example: Keybind in Labwc / Openbox (rc.xml)
<keybind key="W-m">
<action name="Execute" command="mem --gui" />
</keybind>Example: Keybind in Sway / i3 (config)
bindsym Mod4+m exec mem --gui
Example: Keybind in Hyprland (hyprland.conf)
bind = SUPER, m, exec, mem --gui
You can customize the behavior of the GUI prompt by editing the configuration variables at the top of the mem script:
# Set to "fuzzel", "rofi", "wofi", "tofi", "bemenu", or "dmenu" to force a specific launcher.
# Leave empty to auto-detect!
LAUNCHER_OVERRIDE=""
PROMPT_TEXT="Check RAM usage for: "If LAUNCHER_OVERRIDE is left blank, mem will automatically scan your system and pick the best available launcher. If you have multiple installed, you can force your preferred one by typing its name in the quotes!
This script is open-sourced software licensed under the MIT license. You are free to use, modify, and distribute it!