49#define memString(bytes) std::to_string(bytes) + " (" + sizeString(bytes) + ")"
50#define profilerDebugPrint \
51 if (MemoryProfiler::stats) \
53 auto s = MemoryProfiler::stats; \
54 std::cout << GridLogDebug << "[Memory debug] Stats " << MemoryProfiler::stats << std::endl; \
55 std::cout << GridLogDebug << "[Memory debug] total : " << memString(s->totalAllocated) \
57 std::cout << GridLogDebug << "[Memory debug] max : " << memString(s->maxAllocated) \
59 std::cout << GridLogDebug << "[Memory debug] current: " << memString(s->currentlyAllocated) \
61 std::cout << GridLogDebug << "[Memory debug] freed : " << memString(s->totalFreed) \
65#define profilerAllocate(bytes) \
66 if (MemoryProfiler::stats) \
68 auto s = MemoryProfiler::stats; \
69 s->totalAllocated += (bytes); \
70 s->currentlyAllocated += (bytes); \
71 s->maxAllocated = std::max(s->maxAllocated, s->currentlyAllocated); \
73 if (MemoryProfiler::debug) \
75 std::cout << GridLogDebug << "[Memory debug] allocating " << memString(bytes) << std::endl; \
79#define profilerFree(bytes) \
80 if (MemoryProfiler::stats) \
82 auto s = MemoryProfiler::stats; \
83 s->totalFreed += (bytes); \
84 s->currentlyAllocated -= (bytes); \
86 if (MemoryProfiler::debug) \
88 std::cout << GridLogDebug << "[Memory debug] freeing " << memString(bytes) << std::endl; \
void check_huge_pages(void *Buf, uint64_t BYTES)
std::string sizeString(size_t bytes)
#define NAMESPACE_BEGIN(A)
static MemoryStats * stats
size_t currentlyAllocated