htop icon indicating copy to clipboard operation
htop copied to clipboard

htop doesn't report shared memory usage on Linux

Open jart opened this issue 1 year ago • 4 comments

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!

jart avatar Apr 11 '24 13:04 jart

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?

BenBE avatar Apr 12 '24 05:04 BenBE

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 :)

fish98 avatar May 06 '24 16:05 fish98

@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

cgzones avatar May 06 '24 18:05 cgzones

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

Thanks for your reply :)

fish98 avatar May 15 '24 17:05 fish98