Linux free shows high memory usage but top does not
Don't look at the "Mem" line, look at the one below it.
The Linux kernel consumes as much memory as it can to provide the I/O cache (and other non-critical buffers, but the cache is going to be most of this usage). This memory is relinquished to processes when they request it. The "-/+ buffers/cache" line is showing you the adjusted values after the I/O cache is accounted for, that is, the amount of memory used by processes and the amount available to processes (in this case, 578MB used and 7411MB free).
The difference of used memory between the "Mem" and "-/+ buffers/cache" line shows you how much is in use by the kernel for the purposes of caching: 7734MB - 578MB = 7156MB in the I/O cache. If processes need this memory, the kernel will simply shrink the size of the I/O cache.
Why do 'htop' and 'top' show different memory usage?
Top counts the cache aswell.
So if you do:
X = Used
Y = Buffers
Z = Cached
X - Y - Z = HTOPMEM
Memory used but i can't see process that used it (Debian)
www.linuxatemyram.com
It's too good of a site to ruin by copy/pasting the entire contents here.
Linux free -m : Total, used and free memory values don't add up
For the main memory, the actual size of memory can be calculated as used+free+buffers+cache
OR used+free+buffers/cache
because buffers/cache = buffer+cache
.
The man page of free
highlights used
as Used memory (calculated as total - free - buffers - cache)
As the man page of free says :-
total Total installed memory (MemTotal and SwapTotal in /proc/meminfo)
used Used memory (calculated as total - free - buffers - cache)
free Unused memory (MemFree and SwapFree in /proc/meminfo)
shared Memory used (mostly) by tmpfs (Shmem in /proc/meminfo,
on kernels 2.6.32, displayed as zero if not available)buffers Memory used by kernel buffers (Buffers in /proc/meminfo)
cache Memory used by the page cache and slabs (Cached and Slab in
/proc/meminfo)buff / cache Sum of buffers and cache
available Estimation of how much memory is available for starting new applications, without swapping. Unlike the data provided by the cache or free fields, this field takes into account page cache and also that not all reclaimable memory slabs will be reclaimed due to items being in use (MemAvailable in /proc/meminfo, available on kernels 3.14, emulated on kernels 2.6.27+, otherwise the same as free)
In your case,
873224(used) + 389320(free) + 25493068(buff/cache) = 26755612(total)
Why would free be reporting a freakishly high swap used value?
Are the systems running kernel-2.6.32-573.1.1.el6.x86_64?
Could be this bug:
access.redhat.com/solutions/1571043
Memory usage doesn't decrease when free() used
On many operating systems, free()
doesn't make the memory available for the OS again, but "only" for new calls to malloc()
. This is why you don't see the memory usage go down externally, but when you increase the number of new allocations by threading, the memory is re-used so total usage doesn't go through the roof.
Related Topics
Minicom Black Background Color Is Not Respected
Interprocess Communication Using Pipe in Linux
Diff to Output Only the File Names
Linux: Which Process Is Causing "Device Busy" When Doing Umount
How to Add My Own Software to a Buildroot Linux Package
How Does Epoll's Epollexclusive Mode Interact with Level-Triggering
Linux - Yum Install Gcc - Missing Kernel-Headers
Xdg Basedir Directories for Windows
Every Command Is Returning 'Bash: <Command>: Command Not Found...'
Can Linux Cat Command Be Used for Writing Text to File
How to Know Which of the /Dev/Input/Eventx (X=0..7) Have the Linux Input Stream
How to Schedule Tcpdump to Run for a Specific Period of Time
How to Download a File from the Internet to My Linux Server with Bash