adam-markovics commented on a change in pull request #845:
URL: https://github.com/apache/nifi-minifi-cpp/pull/845#discussion_r458809908
##########
File path: libminifi/src/utils/OsUtils.cpp
##########
@@ -154,6 +160,80 @@ std::string OsUtils::userIdToUsername(const std::string
&uid) {
return name;
}
+unsigned long long OsUtils::getMemoryUsage() {
+#ifdef __linux__
+ long resPages;
+ long sharedPages;
+ {
+ std::string ignore;
+ std::ifstream ifs("/proc/self/statm");
+ ifs >> ignore >> resPages >> sharedPages;
+ }
+
+ if (sharedPages > resPages) {
+ throw std::range_error("Shared memory page count ("
+ + std::to_string(sharedPages)
+ + ") should not be larger than resident set size ("
+ + std::to_string(resPages)
+ + "), that includes it"
+ );
+ }
+
+ const long ownPages = resPages - sharedPages;
Review comment:
This code is Linux-only. Man says values in /proc/self/statm will be
long: https://man7.org/linux/man-pages/man5/proc.5.html. Page size is usually
4096, memory usage value should definitely fit 64 bits even after
multiplication.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]