-
Notifications
You must be signed in to change notification settings - Fork 23
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
Include available memory #10
base: master
Are you sure you want to change the base?
Include available memory #10
Conversation
1106214
to
0df3723
Compare
0df3723
to
ea268d3
Compare
Any news here? |
// The total available memory is the free memory + freeable memory | ||
// such as buffer and cache. | ||
// | ||
// If available memory size could not be determined, then 0 is returned. |
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.
"If freeable memory size could not be determined, then freeable memory is assumed to be 0"
Seems to fit the semantics of the windows/bsd/darwin stubs a bit better.
I haven't had time to look into Darwin/BSD implementations. Should be straightforward just need to find/confirm which names to use in the syscalls |
// Buffer/cache ram is included on linux since the kernel | ||
// will free this memory for applications if needed, and tends | ||
// to use almost all free memory for itself when it can. | ||
return (uint64(in.Freeram) + uint64(in.Bufferram)) * uint64(in.Unit) |
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.
On Linux it's generally better to use MemAvailable
from /proc/meminfo
. There is a good justification for this in the Linux kernel git commit.
The hard part is there's no simple stdlib syscall that I am aware of that can read this. 🙁
From the discussion in #9, this is the AvailableMemory() function addition.
It intends to return free+freeable memory.
I think Windows is ready to go as-is, and this adds the change for Linux. Darwin and BSDs remain and I could use some help there.