6 #ifndef TURI_MEMORY_INFO_HPP 7 #define TURI_MEMORY_INFO_HPP 13 #include <google/malloc_extension.h> 15 #include <core/logging/assertions.hpp> 25 namespace memory_info {
54 MallocExtension::instance()->
55 GetNumericProperty(
"generic.heap_size", &heap_size);
58 "memory_info::heap_bytes() requires tcmalloc" << std::endl;
72 size_t allocated_size(0);
74 MallocExtension::instance()->
75 GetNumericProperty(
"generic.current_allocated_bytes",
79 "memory_info::allocated_bytes() requires tcmalloc" << std::endl;
81 return allocated_size;
94 const double BYTES_TO_MB = double(1) / double(1024 * 1024);
96 <<
"Memory Info: " << label << std::endl
97 <<
"\t Heap: " << (
heap_bytes() * BYTES_TO_MB) <<
" MB" 103 <<
"Unable to print memory info for: " << label <<
". " 104 <<
"No memory extensions api available." << std::endl;
118 const double BYTES_TO_MB = double(1) / double(1024 * 1024);
120 <<
"Memory Info: " << label
121 <<
"\n\t Heap: " << (
heap_bytes() * BYTES_TO_MB) <<
" MB" 126 <<
"Unable to print memory info for: " << label <<
". " 127 <<
"No memory extensions api available." << std::endl;
void log_usage(const std::string &label="")
Log a memory usage summary prefixed by the string argument.
size_t heap_bytes()
Estimates the total current size of the memory heap in bytes. If memory info is not available then 0 ...
bool available()
Returns whether memory info reporting is available on this system (if memory_info was built with TCMa...
size_t allocated_bytes()
Determines the total number of allocated bytes. If memory info is not available then 0 is returned...
void print_usage(const std::string &label="")
Print a memory usage summary prefixed by the string argument.
#define logstream_once(lvl)