-
Notifications
You must be signed in to change notification settings - Fork 2
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
Process memory #16
Process memory #16
Conversation
a33489a
to
1566d41
Compare
I haven't done this in the coding style of #14 by the way. Will try to convert it and see how I like that :-). |
I think this is the nicest we can get. It's not possible to combine |
I tried a slightly different approach, something like this: file_to_string(path).
and_then(|raw_data| {
let segments: Vec<&str> = raw_data.split_whitespace().collect();
if segments.len() < 2 {
return Err(ProbeError::UnexpectedContent("Incorrect number of segments".to_owned()))
} This isn't very ergonomic because the errors within the block are not of the same type as the IO error from Overall I feel that a more functional style in the implementation of these functions causes more hassle than the benefit it delivers. |
1566d41
to
994c41e
Compare
It's a balancing act 🐵 |
|
||
// Value is in pages, needs to be multiplied by the page size to get a value in KB. We ask the OS | ||
// for this information using sysconf. | ||
let pagesize = unsafe { libc::sysconf(libc::_SC_PAGESIZE) } as u64; |
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.
Ok, but why is it unsafe? Or is just whole libc unsafe?
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.
Using libc is almost always unsafe since its a C library that doesn't offer the guarantees Rust needs. Therefore we have to check things manually and make sure they are correct.
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.
The compiler will emit a warning if you use an unnecessary unsafe
block by the way, so we'd know about it if this was unnecessary.
Yeah we'll plan that evening after its done, didn't mean to imply that I wanted to impose deadlines :-). |
Any objections to merging this? |
None at all! +1 |
Measurements of current and max memory usage for processes. You can get current for all processes. Max seems to be only available for the current process, at least in Linux.
Fixes #12