lsmem
List system memory information
TLDR
List memory information
List memory information in JSON format
List memory information with size in bytes
SYNOPSIS
lsmem [options]
PARAMETERS
-b, --bytes
Print the memory sizes in bytes rather than human-readable format. This can be useful for scripting or precise calculations.
-J, --json
Use the JSON output format. This allows for easy parsing of lsmem's output by other programs and scripts.
-o <list>, --output <list>
Specify which output columns to print. The <list> is a comma-separated list of column names. Use --help to see a list of all supported columns. Common columns include RANGE, SIZE, STATE, BLOCK, NODE, and REMOVABLE.
-h, --help
Display a help message and exit. This provides a quick reference to the command's options and usage.
-V, --version
Display version information and exit. This shows the version of lsmem being used.
DESCRIPTION
The lsmem command, part of the util-linux package, provides a comprehensive overview of the system's memory architecture. It lists the ranges of available memory, their current online status, and key attributes such as memory block size, total available memory, and information related to NUMA (Non-Uniform Memory Access) nodes.
lsmem gathers its information by reading data from the /sys/devices/system/memory/ directory, offering a structured and machine-readable view of the memory topology. This is particularly useful for administrators and developers who need to understand memory layout, identify memory hotplug capabilities, or analyze NUMA node configurations without parsing raw kernel output or less structured files like /proc/meminfo.
CAVEATS
The information presented by lsmem is derived from the kernel's view of the memory subsystem, primarily via the /sys filesystem. Its accuracy and detail depend on the kernel's support for memory hotplug, NUMA, and proper hardware reporting. Systems without advanced memory management features might show less detailed output. Memory ranges might not always appear contiguous due to hardware or virtualization configurations.
OUTPUT COLUMNS
When using the --output option, lsmem can display various columns providing specific details about memory regions. Key columns include:
RANGE: The start and end address of the memory range.
SIZE: The size of the memory range.
STATE: The current state of the memory range (e.g., 'online', 'offline').
BLOCK: The memory block size.
NODE: The NUMA node to which the memory range belongs.
REMOVABLE: Indicates if the memory is hot-removable.
NUMA AWARENESS
One of lsmem's significant features is its NUMA awareness. It helps in understanding how memory is distributed across different NUMA nodes, which is critical for optimizing performance in multi-processor systems. By showing which memory ranges belong to which NUMA node, administrators and developers can make informed decisions about process affinity and memory allocation strategies to reduce latency and improve resource utilization.
HISTORY
lsmem is a relatively modern addition to the util-linux project, which provides a large set of essential system utilities for Linux. It was developed to address the need for a more structured and machine-readable way to present memory topology information, especially in light of increasing adoption of NUMA architectures and memory hotplug capabilities in server environments. Its design focuses on leveraging the sysfs interface to provide detailed memory block and node information that is crucial for optimizing application performance and managing system resources effectively.


