-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Log some memory usage statistics after preprocessing tasks.
- Loading branch information
Showing
3 changed files
with
57 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#ifndef MEMINFO_HPP | ||
#define MEMINFO_HPP | ||
|
||
#include "util/log.hpp" | ||
|
||
#include <stxxl/mng> | ||
#ifndef _WIN32 | ||
#include <sys/resource.h> | ||
#endif | ||
|
||
namespace osrm | ||
{ | ||
namespace util | ||
{ | ||
inline void DumpMemoryStats() | ||
{ | ||
#if STXXL_VERSION_MAJOR > 1 || (STXXL_VERSION_MAJOR == 1 && STXXL_VERSION_MINOR >= 4) | ||
auto manager = stxxl::block_manager::get_instance(); | ||
util::Log() << "STXXL: peak bytes used: " << manager->get_maximum_allocation(); | ||
util::Log() << "STXXL: total disk allocated: " << manager->get_total_bytes(); | ||
#else | ||
#warning STXXL 1.4+ recommended - STXXL memory summary will not be available | ||
util::Log() << "STXXL: memory summary not available, needs STXXL 1.4 or higher"; | ||
#endif | ||
|
||
#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 | ||
} | ||
} | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters