-
-
Notifications
You must be signed in to change notification settings - Fork 610
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
Update linux.cc : to show the same used RAM than free #1028
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nihilix-melix
changed the title
Update linux.cc
Update linux.cc : to show the same memory usage than free
Nov 28, 2020
nihilix-melix
changed the title
Update linux.cc : to show the same memory usage than free
Update linux.cc : to show the same used RAM than free
Nov 28, 2020
brndnmtthws
requested changes
Jan 23, 2021
src/linux.cc
Outdated
@@ -248,7 +248,23 @@ int update_meminfo(void) { | |||
curmem -= curbufmem; | |||
cureasyfree += curbufmem; | |||
#else | |||
curmem = info.memmax - memavail; | |||
# curmem = info.memmax - memavail; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this line.
brndnmtthws
added a commit
that referenced
this pull request
Apr 22, 2021
It seems there is some confusion between the way Conky reports free memory, versus other programs. I'm adding a new variable, `legacyfree`, to provide the same value that is reported on older programs that don't report memory the way recommended by newer kernels. For more details, see: * https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=34e431b0ae398fc54ea69ff85ec700722c9da773 * #859 * #1028 * #1090 This resolves #1090.
brndnmtthws
added a commit
that referenced
this pull request
Apr 22, 2021
It seems there is some confusion between the way Conky reports free memory, versus other programs. I'm adding a new variable, `legacymem`, to provide the same value that is reported on older programs that don't report memory the way recommended by newer kernels. For more details, see: * https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=34e431b0ae398fc54ea69ff85ec700722c9da773 * #859 * #1028 * #1090 This resolves #1090.
brndnmtthws
added a commit
that referenced
this pull request
Apr 22, 2021
It seems there is some confusion between the way Conky reports free memory, versus other programs. I'm adding a new variable, `legacymem`, to provide the same value that is reported on older programs that don't report memory the way recommended by newer kernels. For more details, see: * https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=34e431b0ae398fc54ea69ff85ec700722c9da773 * #859 * #1028 * #1090 This resolves #1090.
brndnmtthws
added a commit
that referenced
this pull request
Apr 25, 2021
It seems there is some confusion between the way Conky reports free memory, versus other programs. I'm adding a new variable, `legacymem`, to provide the same value that is reported on older programs that don't report memory the way recommended by newer kernels. For more details, see: * https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=34e431b0ae398fc54ea69ff85ec700722c9da773 * #859 * #1028 * #1090 This resolves #1090.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Descriptions
The memory available field is describe in /proc man page as : "An estimate of how much memory is available for starting new applications, without swapping."
We can see in page_alloc.c in the linux kernel that : "Not all the page cache can be freed, otherwise the system will start swapping. Assume at least half of the page cache, or the low watermark worth of cache, needs to stay."
There is a difference between the system starts swapping and OOM happens even if there is no swap on the system.
People think they will find the same amount of used RAM with the free program. From man free, we can see :
used Used memory (calculated as total - free - buffers - cache)
free Unused memory (MemFree and SwapFree in /proc/meminfo)
buffers Memory used by kernel buffers (Buffers in /proc/meminfo)
cache Memory used by the page cache and slabs (Cached and SReclaimable in /proc/meminfo)
So, curmem should be calculate as follow to find the same amount of memory in conky and free.
curmem = info.memmax - (info.memfree + info.buffers + info.cached + sreclaimable);
Licenses
The contributed code is GPLv3 licensed.