thewtex / tmux-mem-cpu-load

CPU, RAM, and load monitor for use with tmux
Apache License 2.0
1.01k stars 136 forks source link

Option to include Cached memory in output #37

Closed NHDaly closed 8 years ago

NHDaly commented 8 years ago

My tmuxstatus line says I am only using 16GBof my 32GB available ram. But my machine is really sluggish, and looking at the output of free -m, you can see this just isn't true:

$ free -m
             total       used       free     shared    buffers     cached
Mem:         32100      28415       3684         32        151      11381
-/+ buffers/cache:      16882      15217
Swap:        32695        289      32406

This is because the Cache is actually taking up a lot of memory:

$ cat /proc/meminfo
MemTotal:       32870884 kB
MemFree:         3102568 kB
Buffers:          152772 kB
Cached:         11650120 kB
SwapCached:        64272 kB
Active:         19052916 kB
Inactive:        8415600 kB
...

Can there be an option to use the total memory usage which includes the Cache, so I can get a better idea for why my computer is slow? Thanks.

l0ner commented 8 years ago

IF I understood and remember correctly cached memory on linux doesn't count to used memory, because it is available for immediate use for applications, and should actually make things work faster, since it's used to store stuff that lives on you hdd and is accessed often (RAM access is a lot faster than HDD). A good explanation is here: http://www.linuxatemyram.com/

I never had issues with sluggish system because of high caching on linux. Note that sluggish feel of the system may be cpu related, or simply because you have a lot of tasks running or the applications you use are heavyweight.

NHDaly commented 8 years ago

Huh, yeah that makes sense actually. Haha, in fact, I think I remember reading a similar thing when Mac OSX switched over to showing "Memory Pressure" instead of used vs free memory, and I think the cited reason was that, exactly as you described, having lots of cached memory is actually most of the time a good thing, since it's caching stuff that would otherwise be on disk. So yeah, I think that makes sense.

Must've been some other reason, maybe! :)

Anyway, thanks for the help!

l0ner commented 8 years ago

Youre welcome ;)