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

feat: more accurate memory usage info on glibc Linux #9204

Merged
merged 2 commits into from Jun 11, 2021
Merged

feat: more accurate memory usage info on glibc Linux #9204

merged 2 commits into from Jun 11, 2021

Conversation

jonas-schievink
Copy link
Contributor

This adds support for the new mallinfo2 API added in glibc 2.33. It addresses a shortcoming in the mallinfo API where it was unable to handle memory usage of more than 2 GB, which we sometimes exceed.

Blocked on rust-lang/libc#2228

if mallinfo2 == 1 {
let cstr = CStr::from_bytes_with_nul(b"mallinfo2\0").unwrap();
mallinfo2 = unsafe { libc::dlsym(libc::RTLD_DEFAULT, cstr.as_ptr()) } as usize;
// NB: races don't matter here, since they'll always store the same value
Copy link
Member

Choose a reason for hiding this comment

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

Interesting! OnceCell sort-of has a type for this, but using it would seem to be more awkward: https://docs.rs/once_cell/1.7.2/once_cell/race/struct.OnceNonZeroUsize.html

bors added a commit to rust-lang/libc that referenced this pull request Jun 11, 2021
Bump version to 0.2.97

I'd like to get a new release published, since I want to make use of #2228 in rust-lang/rust-analyzer#9204
@jonas-schievink jonas-schievink marked this pull request as ready for review June 11, 2021 21:55
@jonas-schievink
Copy link
Contributor Author

bors r+

@bors
Copy link
Contributor

bors bot commented Jun 11, 2021

@bors bors bot merged commit 409f5fb into rust-lang:master Jun 11, 2021
@jonas-schievink jonas-schievink deleted the mallinfo2 branch June 11, 2021 22:37
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