Kernel Modules: Check RAM Usage with lsmod

Quick Linux Tip #89:

Question: The kernel is using tons of RAM. Which modules are the biggest?

Try: sudo lsmod | sort -k2 -rn | head -10

Info: lsmod lists currently loaded kernel modules alongside their size in bytes. Sorting numerically by size quickly highlights memory-intensive display drivers, filesystems, and device modules.

Examples:

  • $ sudo modinfo nvidia  # Display detailed kernel module info and parameters
  • $ sudo modprobe -r nvidia  # Safely unload an unused kernel module
  • $ cat /proc/meminfo | grep -i slab  # Check kernel slab memory utilization

Note: Kernel-level memory allocations appear under Slab in /proc/meminfo. Active modules (Used by > 0) cannot be unloaded until dependent processes or devices release them.




LinuxTeck.com
linuxteck:~$ sudo lsmod | sort -k2 -rn | head -10
Module                  Size  Used by
nvidia_drm             81920  4
nvidia_modeset       1257472  9 nvidia_drm
nvidia               62636032  609 nvidia_modeset
snd_hda_intel          57344  4
snd_hda_codec        192512  2 snd_hda_codec_hdmi,snd_hda_intel
snd_hda_core         126976  3 snd_hda_codec_hdmi,snd_hda_codec,snd_hda_intel
i915                4423680  10
btrfs               1892352  1
zstd_compress         188416  1 btrfs
xor                    24576  1 btrfs
linuxteck:~$

PREVIOUS ARTICLE Quick Linux Tip #88: Chrony Time Synchronization: Fix Linux Clock Drift NEXT ARTICLE Quick Linux Tip #90: DNS Lookup Time: Measure Network Latency with curl
About John Britto

John Britto Founder & Chief-Editor @LinuxTeck. A Computer Geek and Linux Intellectual having more than 20+ years of experience in Linux and Open Source technologies.

View all posts by John Britto →

Leave a Reply

Your email address will not be published.