Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

memory[bar] should display used+shared as the used memory #906

Closed
dragomang87 opened this issue Dec 28, 2021 · 5 comments · Fixed by #913
Closed

memory[bar] should display used+shared as the used memory #906

dragomang87 opened this issue Dec 28, 2021 · 5 comments · Fixed by #913
Labels
enhancement Extension or improvement to existing feature Linux 🐧 Linux related issues
Milestone

Comments

@dragomang87
Copy link

dragomang87 commented Dec 28, 2021

Shared memory accounts for memory in tmpfs among other things. If tmpfs is mounted in /tmp then adding a 1GB file will occupy 1GB of ram that is neither buffer or cache and cannot be freed by kernel on demand. However, htop's memory[bar] will only display the shared memory as purple bars but only write used/total in numbers at the end of the bar.

In case of a system running out of memory, the bar will look full but the number indicating the memory usage might be very low. memory[text] does not have this problem because it will display available memory, which will immediately show that the system is low on memory.

I think memory[bar] should display used+shared/total at the end of the bar to truly reflect the system state. An alternative would be to add an option to display available/total or to display used/used+shared/total.

(running htop 3.1.2 on Arch Linux)

Edit: corrected some confusion where I wrote free instead of `used' as pointed out by @kjbracey

@BenBE BenBE added enhancement Extension or improvement to existing feature Linux 🐧 Linux related issues labels Jan 1, 2022
@kjbracey2
Copy link
Contributor

kjbracey2 commented Jan 9, 2022

Issue is misdescribed - it should be requesting used+shared/total rather than used/total.

htop 2.2.0 as packaged in my Ubuntu is working well, at least w.r.t tmpfs - it has used, buffers and cached, and Shmem has been subtracted from Cached, so tmpfs appears in used.

But since shared memory has been separated, the basic used is now less meaningful in isolation. I agree that the end-of-bar readout should be showing used+shared, and would also suggest that shared should be shown between used and buffers in the bar order.

@kjbracey2
Copy link
Contributor

kjbracey2 commented Jan 10, 2022

Here's the history of the readout, as I figured it out:

@cupen
Copy link

cupen commented Jul 15, 2023

@kjbracey2 Maybe there is something wrong in my htop 3.2.1.
Here is what I saw. The purple bar is obviously not included in used/total.
img_v2_39f67730-d29a-420a-a03d-1acc9951c08g

@kjbracey2
Copy link
Contributor

kjbracey2 commented Jul 15, 2023

Yes, that's the issue being discussed. Since 3.1.1 the purple bar (shared) has not been included in the "used", despite it definitely being in use and not being reclaimable.

Note that the blue and orange (buffers + cache) are not counted either, but that makes sense as they are reclaimable, and will just occupy any unclaimed memory until someone claims it.

PR #913 would address this, and reorder the bars to put the green+purple (claimed) memory together, and show "claimed/total".

@BenBE
Copy link
Member

BenBE commented Jul 15, 2023

That PR has not been merged yet, because there was a related change scheduled that touched quite a bit of the same code. Also some details on the UI/UX will likely still need to be worked out.

@BenBE BenBE added this to the 3.3.0 milestone Oct 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Extension or improvement to existing feature Linux 🐧 Linux related issues
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants