slabtop – Display Kernel Slab Memory Cache Information in Real Time

The slabtop command is a Linux utility that displays real-time information about the kernel slab memory cache. In Linux, the slab allocator is a memory management subsystem that manages small, frequently allocated kernel objects such as data structures, buffers, and caches. The slabtop command provides a detailed overview of the slab cache, including the number of objects, their size, and the total amount of memory used by each cache.

Overview

The slabtop command is used to display information about the kernel slab memory cache. To use the slabtop command, simply type slabtop in the terminal. The output will display the following columns:

  • Cache: The name of the cache
  • Num: The number of objects in the cache
  • Alloc: The total amount of memory allocated by the cache
  • Free: The total amount of free memory in the cache
  • Total: The total size of the cache
  • Size: The size of each object in the cache
  • Slabs: The number of slabs used by the cache
  • Depth: The depth of the cache

Here is an example of the output of the slabtop command:

  OBJS ACTIVE  USE OBJ SIZE  SLABS OBJ/SLAB CACHE SIZE NAME                   
  1006    978  97%    0.51K     22       46     7040K buffer_head           
  7104   7104 100%    0.03K     44      161      704K dentry                 
  4096   4096 100%    0.02K     32      128      512K ext4_inode_cache       
  1024    992  97%    0.06K     16       64      256K kmalloc-64            
  2048   2048 100%    0.03K     16      128      256K kmalloc-32            
  1024   1024 100%    0.03K      8      128      128K kmalloc-16            
  3072   3072 100%    0.01K     24      128       96K kmalloc-8             
   512    512 100%    0.03K      4      128       64K kmalloc-32percpu      
  1024   1024 100%    0.02K      8      128       32K kmalloc-16percpu      
  2048   2048 100%    0.01K     16      128       32K kmalloc-8percpu       

The slabtop command can be used to monitor the memory usage of the kernel slab cache in real-time. This can be useful for identifying memory leaks or other issues that may be impacting system performance.

Options

The slabtop command has several options that can be used to customize the output. The available options are:

Option Description
-s Sort output by the specified column (e.g., -s c to sort by cache name)
-o Only display caches that match the specified regular expression
-b Display output in bytes instead of kilobytes
-delay Set the delay between updates (in seconds)

Troubleshooting Tips

If you are experiencing issues with high memory usage or performance problems, the slabtop command can be a useful tool for identifying the source of the problem. Here are some troubleshooting tips for using the slabtop command:

  • Look for caches with a high number of objects or a large amount of memory allocated. These may be the source of memory leaks or other issues.
  • Use the -s option to sort the output by the column that is most relevant to your issue. For example, if you are experiencing performance issues, you may want to sort by the number of objects to identify caches that are being accessed frequently.
  • Use the -o option to filter the output to only display caches that match a specific regular expression. This can be useful if you are looking for a specific cache or want to exclude certain caches from the output.

Notes

  • The slabtop command requires root privileges to run.
  • The slabtop command is only available on Linux systems that use the slab allocator. Some newer Linux systems may use the slub allocator instead, which does not support the slabtop command.