[Git][NTPsec/ntpsec][master] getrusage()'s ru_maxrss field is bytes on OSX, not kilobytes
Matt Selsky
gitlab at mg.gitlab.com
Fri Dec 30 09:27:29 UTC 2016
Matt Selsky pushed to branch master at NTPsec / ntpsec
Commits:
1d834187 by Matt Selsky at 2016-12-30T04:20:47-05:00
getrusage()'s ru_maxrss field is bytes on OSX, not kilobytes
Based on http://fa.bianp.net/blog/2013/different-ways-to-get-memory-consumption-or-lessons-learned-from-memory_profiler/
Fixes GitLab issue #218
- - - - -
1 changed file:
- ntpclients/ntpq
Changes:
=====================================
ntpclients/ntpq
=====================================
--- a/ntpclients/ntpq
+++ b/ntpclients/ntpq
@@ -1263,8 +1263,12 @@ usage: config_from_file <configuration filename>
self.say("# Processed %d slots in %.3f seconds\n" \
% (self.session.slots, delta2) )
usage = resource.getrusage(resource.RUSAGE_SELF)
+ rusage_denom = 1024.
+ if sys.platform == 'darwin':
+ # OSX uses bytes, while every other platform uses kilobytes
+ rusage_denom = rusage_denom * rusage_denom
self.say("# Used %d megabytes of memory\n" % \
- (usage.ru_maxrss/1000) )
+ (usage.ru_maxrss/rusage_denom) )
except ntp.packet.ControlException as e:
# Giving up after 8 restarts from the beginning.
# With high-traffic NTP servers, this can occur if the
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/1d834187d4fceb8f10e1e2a82a788d099cc4b4e2
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20161230/503d7eec/attachment.html>
More information about the vc
mailing list