osrm-backend/include/util/meminfo.hpp
Dennis Luxen a4aa153ba4 Use nested namespace
It's a mechanical change to modernize the code base
2022-12-11 10:17:17 +01:00

32 lines
654 B
C++

#ifndef MEMINFO_HPP
#define MEMINFO_HPP
#include "util/log.hpp"
#ifndef _WIN32
#include <sys/resource.h>
#endif
namespace osrm::util
{
inline void DumpMemoryStats()
{
#ifndef _WIN32
rusage usage;
getrusage(RUSAGE_SELF, &usage);
#ifdef __linux__
// Under linux, ru.maxrss is in kb
util::Log() << "RAM: peak bytes used: " << usage.ru_maxrss * 1024;
#else // __linux__
// Under BSD systems (OSX), it's in bytes
util::Log() << "RAM: peak bytes used: " << usage.ru_maxrss;
#endif // __linux__
#else // _WIN32
util::Log() << "RAM: peak bytes used: <not implemented on Windows>";
#endif // _WIN32
}
} // namespace osrm
#endif