Expose query for cleaning memory and add memory limit flag (#100)

* Add memory flag, add additional meminfo utilities

* Add free memory query
This commit is contained in:
antonio2368
2021-03-04 12:20:11 +01:00
committed by Antonio Andelic
parent dee885d69c
commit cc56ac3dd8
26 changed files with 252 additions and 54 deletions

View File

@@ -3,6 +3,7 @@
#include <gtest/gtest.h>
#include <utils/memory_tracker.hpp>
#include <utils/on_scope_exit.hpp>
TEST(MemoryTrackerTest, ExceptionEnabler) {
utils::MemoryTracker memory_tracker;
@@ -16,11 +17,15 @@ TEST(MemoryTrackerTest, ExceptionEnabler) {
// wait until the second thread creates exception enabler
while (!enabler_created)
;
ASSERT_NO_THROW(memory_tracker.Alloc(hard_limit + 1));
ASSERT_EQ(memory_tracker.Amount(), hard_limit + 1);
// tell the second thread it can finish its test
can_continue = true;
// we use the OnScopeExit so the test doesn't deadlock when
// an ASSERT fails
utils::OnScopeExit thread_notifier{[&] {
// tell the second thread it can finish its test
can_continue = true;
}};
ASSERT_NO_THROW(memory_tracker.Alloc(hard_limit + 1));
}};
std::thread t2{[&] {