Add jemalloc purge (#239)

This commit is contained in:
antonio2368
2021-09-21 14:43:27 +02:00
committed by GitHub
parent f560293657
commit 9f855676cb
10 changed files with 48 additions and 6 deletions

View File

@@ -0,0 +1,22 @@
#include "memory_control.hpp"
#if USE_JEMALLOC
#include <jemalloc/jemalloc.h>
#endif
namespace memory {
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
#define STRINGIFY_HELPER(x) #x
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
#define STRINGIFY(x) STRINGIFY_HELPER(x)
void PurgeUnusedMemory() {
#if USE_JEMALLOC
mallctl("arena." STRINGIFY(MALLCTL_ARENAS_ALL) ".purge", nullptr, nullptr, nullptr, 0);
#endif
}
#undef STRINGIFY
#undef STRINGIFY_HELPER
} // namespace memory