htop-dev / htop

htop - an interactive process viewer
https://htop.dev/
GNU General Public License v2.0
6.11k stars 411 forks source link

htop doesn't report shared memory usage on Linux #1443

Open jart opened 2 months ago

jart commented 2 months ago

In the screenshot below, you'll see that one of my processes is using 139GB of memory, but htop reports the system using 6GB of RAM.

image

It's because htop hides mmap(MAP_SHARED) memory. This has caused a great deal of confusion in the machine learning community over the past year. For example https://twitter.com/JustineTunney/status/1778420352504512774 one Twitter user got snagged by poor performance because his system was swapping, but according to htop everything was fine.

Could htop start reporting this information? Thanks!

BenBE commented 2 months ago

Okay, something seems off here …

Can you provide a copy of /proc/meminfo with what htop reports alongside? Shared memory should be handled already.

Also, which htop version/release?

fish98 commented 1 month ago

Hi, I might experience the same issue with htop version 3.3.0-2 on ArchLinux where the swap memory usage statistics of htop differs from those shown by top and /proc/meminfo. Please find the following screenshot for more detailed information. I tested Line 213-215 in linux/LinuxMachine.c and found these variables match with the correct memory consumption listed in meminfo. I suppose these variables were incorrectly changed during the whole htop workflow although I have not investigated the root cause in depth.

htop

PTAL, thank you :)

cgzones commented 1 month ago

@fish98 your observed behavior is probably due to the zswap handling, see https://github.com/htop-dev/htop/commit/71f5a80d9e312375eff28d2fbb7d8add81f6793c and https://github.com/htop-dev/htop/commit/71f2e66126286540ca88d8c36f81008ba5181f89

fish98 commented 1 month ago

@fish98 your observed behavior is probably due to the zswap handling, see 71f5a80 and 71f2e66

Thanks for your reply :)