5 ms·
I'm so sick of people telling me something is using some ridiculous GB of RAM because they've added up all the threads' memory in htop
by danmur 6y ago
I'm so sick of people telling me something is using some ridiculous GB of RAM because they've added up all the threads' memory in htop
- lathiat 6y agoWe really need better tooling for this. It is possible but you have to parse snaps which I think is expensive ish. Would be great to get something useful info commonly used tooling though.
- lathiat 6y agotypo: by "snaps" i meant /proc/PID/smaps
- stretchcat 6y agoPointing out the error in their reasoning by noting their sum exceeds the RAM their computer actually has usually works well.
- worik 6y agoHe he. I came within a hair's bredth of doing exactly that. Saw this article, installed htop, ran it - all in pre coffee morning fog OMG A dozen firefox threads each using 10%! .... Even in my 10% early morning function I realised, but I get your point.
- scubbo 6y agoMe too, I really hate that! I wish they'd stop making that very obvious and simple mistake in reasoning! ...just so that _I_ can know that you know what you're talking about, can you elaborate on what that obvious mistake (which I clearly know about) is? Dropping the joke - I assume it's that threads share memory in some way (so that the total consumed is not the sum of each consumption), but a. how and why, and b. why isn't it trivial for htop to represent that "correctly"?
- garaetjjte 6y agoThreads usually share address space. There's no way to know particular thread memory usage, so htop just duplicates same information for every thread.
- scubbo 6y agoGot it, thanks. > There's no way to know particular thread memory usage This sounds like the sort of statement that is self-evident to folks with a CS education (I studied math, and all my CS/programming knowledge is self-taught). I'll add that to my _long_ backlog of things that I should research to get over my imposter syndrome :)
- SAI_Peregrinus 6y agoFor most operating systems, threads each have their own stack space, and (if supported) thread-local storage, but share heap, constants (.bss), and static variables (.data). It's impossible to say exactly what resources a given thread is using from those shared resources, so htop just includes them all, for every thread.
- scubbo 6y agoMuch appreciated, thank you!