To get the memory usage information, including the cached memory, you can use the free command in Linux. By default, the free command displays memory information in kilobytes.ย
Here's an example command: free -h
Output is something like this:
The -h option is used to display the memory sizes in a more human-readable format (e.g., gigabytes, megabytes).ย
The output of the free command includes several columns, including:
-
total: Total available memory -
used: Memory used by processes and the kernel -
free: Memory that is not being used -
shared: Memory shared between multiple processes -
buffers: Memory used for buffers by the kernel -
cached: Memory used for caching disk data by the kernel
The buffers and cached columns represent memory used for optimization purposes. The cached memory contains disk cache, which is used to improve performance by keeping frequently accessed data in memory. This memory is available for use by processes when needed.
Keep in mind that Linux considers the cached memory as available memory for processes. If needed, the kernel can release the cached memory to accommodate the memory requirements of running processes.
By considering the used column minus the buffers and cached columns, you can get a better understanding of the actual memory usage by processes.
To summarize, the free command provides memory usage information, including the cached memory, which the kernel can release for use by processes when necessary.
ย
ย