2
wadewayne@Cheetah:~$ neofetch
MMMMMMMMMMMMMMMMMMMMMMMMMmds+.        wadewayne@Cheetah 
MMm----::-://////////////oymNMd+`     ----------------- 
MMd      /++                -sNMd:    OS: Linux Mint 19.3 Tricia x86_64 
MMNso/`  dMM    `.::-. .-::.` .hMN:   Host: Inspiron 15-3567 
ddddMMh  dMM   :hNMNMNhNMNMNh: `NMm   Kernel: 5.4.0-77-generic 
    NMm  dMM  .NMN/-+MMM+-/NMN` dMM   Uptime: 9 mins 
    NMm  dMM  -MMm  `MMM   dMM. dMM   Packages: 3130 
    NMm  dMM  -MMm  `MMM   dMM. dMM   Shell: bash 4.4.20 
    NMm  dMM  .mmd  `mmm   yMM. dMM   Resolution: 1366x768 
    NMm  dMM`  ..`   ...   ydm. dMM   WM: i3 
    hMM- +MMd/-------...-:sdds  dMM   Theme: Arc-Dark [GTK2/3] 
    -NMm- :hNMNNNmdddddddddy/`  dMM   Icons: Pop [GTK2/3] 
     -dMNs-``-::::-------.``    dMM   Terminal: terminator 
      `/dMNmy+/:-------------:/yMMM   CPU: Intel i3-6006U (4) @ 2.000GHz 
         ./ydNMMMMMMMMMMMMMMMMMMMMM   GPU: Intel HD Graphics 520 
            .MMMMMMMMMMMMMMMMMMM      Memory: 367MiB / 3801MiB 

                                                              


wadewayne@Cheetah:~$ free -h
              total        used        free      shared  buff/cache   available
Mem:           3.7G        325M        2.3G         39M        1.1G        3.1G
Swap:          521M          0B        521M

Screenshot

Hi. I don't understand why neofetch and free -h output different result for RAM usage. Which one's more accurate?

2
  • 3
    can you define what "accurate free memory" means to you? (it's really not unambiguous, and what is the relevant measure depends on very much on what you need to do.) Jul 3, 2021 at 11:42
  • 1
    FYI, github.com/dylanaraps/neofetch/blob/master/neofetch#L2660 uses the slightly surprising formula MemUsed = Memtotal + Shmem - MemFree - Buffers - Cached - SReclaimable, and I'm super confused for whom that would be useful (not like shared memory was gratis for a system), but there you go. Jul 3, 2021 at 11:46

1 Answer 1

4

neofetch calculates used memory as

MemUsed = Memtotal + Shmem - MemFree - Buffers - Cached - SReclaimable

see neofetch FAQ for more information.

free calculates used memory as

used = total - free - buffers - cache

so the difference is neofetch considers shared memory (tmpfs) as used (cache in free is Cached + SReclaimable in neofetch). See free manpage for more information about columns in free output.

If you add used and shared from your free output you get 364 MiB so the difference is only 3 MiB, which can be attributed to some small change in RAM usage or rounding.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.