martinzink commented on a change in pull request #1032:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1032#discussion_r621970763
##########
File path: libminifi/test/unit/MemoryUsageTest.cpp
##########
@@ -21,8 +21,29 @@
#include "../TestBase.h"
TEST_CASE("Test memory usage", "[testmemoryusage]") {
+ constexpr bool cout_enabled = true;
std::vector<char> v(30000000);
- const auto memoryUsage = utils::OsUtils::getMemoryUsage();
- REQUIRE(memoryUsage > v.size());
- REQUIRE(memoryUsage < 2 * v.size());
+ const auto RAMUsagebyProcess =
utils::OsUtils::getCurrentProcessPhysicalMemoryUsage();
+ const auto RAMUsagebySystem = utils::OsUtils::getSystemPhysicalMemoryUsage();
+ const auto RAMTotal = utils::OsUtils::getSystemTotalPhysicalMemory();
+
+ if (cout_enabled) {
+ std::cout << "Physical Memory used by this process: " << RAMUsagebyProcess
<< " bytes" << std::endl;
+ std::cout << "Physical Memory used by the system: " << RAMUsagebySystem <<
" bytes" << std::endl;
+ std::cout << "Total Physical Memory in the system: " << RAMTotal << "
bytes" << std::endl;
+ }
+ REQUIRE(RAMUsagebyProcess >= v.size());
+ REQUIRE(v.size()*2 >= RAMUsagebyProcess);
+ REQUIRE(RAMUsagebySystem >= RAMUsagebyProcess);
+ REQUIRE(RAMTotal >= RAMUsagebySystem);
+}
+
+#ifndef WIN32
+size_t GetTotalMemoryLegacy() {
+ return (size_t) sysconf(_SC_PHYS_PAGES) * (size_t) sysconf(_SC_PAGESIZE);
Review comment:
Yeah, I just copy pasted the pre-PR method to verify the new one gives
the same result.
Strange that the linter havent caught it before, and it didnt catch it now
either.
Nonetheless changed it to use static_cast in
https://github.com/apache/nifi-minifi-cpp/pull/1065
--
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]