-
Notifications
You must be signed in to change notification settings - Fork 31
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
PID is not respected on MacOS/Darwin platform #39
Comments
schneems
changed the title
PID is not respected on MacOS/Darvin platform
PID is not respected on MacOS/Darwin platform
Aug 25, 2020
schneems
added a commit
that referenced
this issue
Aug 25, 2020
Currently when you call `GetProcessMem.new` with a different pid value than the current process it calls `GetProcessMem::Darwin.resident_size this uses FFI to get data from the mach kernel about the current process. - #32 - https://stackoverflow.com/questions/18389581/memory-used-by-a-process-under-mac-os-x/23379216#23379216 This PR adds a test to ensure that memory results from different processes is correctly reported. This PR addresses the different PID problem by checking if a different pid other than Process.pid is being passed in. If that's the case then we will fall back to determining memory based off of shelling out to `ps`. There was a performance concern over using `Process.pid` but it appears to be relatively fast. It is approximately the speed of allocating 3 string object.
I've got a workaround on #41 |
schneems
added a commit
that referenced
this issue
Aug 25, 2020
[close #39] Supporting different PIDs on Mac
This is fixed and released in 0.2.6 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
get_process_mem always returns memory used by current process. It does not respect PID.
Here are some tests from
irb
but if I try to get memory of different process
I'll get back the same amount of memory as I've got for the current process.
This issue was introduced by the pull request #32. Code for Darvin platform doesn't use PID to determine used RAM, it always returns used RAM for current process.
The text was updated successfully, but these errors were encountered: