From: Scott Worley Date: Sun, 10 Jan 2016 07:23:10 +0000 (-0800) Subject: Dump memory stats before starting deallocations. X-Git-Url: http://git.scottworley.com/slidingtile/commitdiff_plain/d995f311ff45db1a69b87335a6cef9c0f572c81c?ds=inline Dump memory stats before starting deallocations. --- diff --git a/sliding_tile_lib.cc b/sliding_tile_lib.cc index 5a4114b..83d6297 100644 --- a/sliding_tile_lib.cc +++ b/sliding_tile_lib.cc @@ -1,6 +1,7 @@ #include "sliding_tile_lib.h" #include +#include #include #include #include @@ -9,6 +10,7 @@ #include #include #include +#include #include #include @@ -203,6 +205,15 @@ std::shared_ptr find_path(const std::string& start, const std::string& goa return find_path(board_start, board_goal, max_frontier); } +static void show_memory_stats() { + std::ifstream statm{"/proc/self/statm"}; + if (statm.is_open()) { + std::string statm_data; + std::getline(statm, statm_data); + std::cerr << "Memory stats: " << statm_data << std::endl; + } +} + std::shared_ptr find_path(const Board& start, const Board& goal, unsigned max_frontier) { InvertedBoard invgoal = goal.invert(); std::multimap> todo; @@ -215,6 +226,7 @@ std::shared_ptr find_path(const Board& start, const Board& goal, unsigned auto cur = todo.begin()->second; todo.erase(todo.begin()); if (cur->board == goal) { + show_memory_stats(); return cur; } std::vector> successors = cur->successors(cur);