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

Update linux.cc : to show the same used RAM than free #1028

Merged
merged 2 commits into from
Feb 5, 2021

Conversation

nihilix-melix
Copy link
Contributor

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.

@nihilix-melix nihilix-melix changed the title Update linux.cc Update linux.cc : to show the same memory usage than free Nov 28, 2020
@nihilix-melix 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
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;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this line.

Base automatically changed from master to main January 24, 2021 14:18
@brndnmtthws brndnmtthws merged commit 91a3f2e into brndnmtthws:main Feb 5, 2021
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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants