From d995f311ff45db1a69b87335a6cef9c0f572c81c Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Sat, 9 Jan 2016 23:23:10 -0800 Subject: [PATCH 1/1] Dump memory stats before starting deallocations. --- sliding_tile_lib.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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); -- 2.44.1