From 3427517d507a938074a50fa8ea6dfe3d13bef357 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Fri, 29 Mar 2013 02:17:10 +0100 Subject: Clean up global datastructures at shutdown. This should make detecting leaks much easier. --- src/main.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 22baf0f3eb..bde7b5acdb 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4750,3 +4750,29 @@ uint64 CTxOutCompressor::DecompressAmount(uint64 x) } return n; } + + +class CMainCleanup +{ +public: + CMainCleanup() {} + ~CMainCleanup() { + // block headers + std::map::iterator it1 = mapBlockIndex.begin(); + for (; it1 != mapBlockIndex.end(); it1++) + delete (*it1).second; + mapBlockIndex.clear(); + + // orphan blocks + std::map::iterator it2 = mapOrphanBlocks.begin(); + for (; it2 != mapOrphanBlocks.end(); it2++) + delete (*it2).second; + mapOrphanBlocks.clear(); + + // orphan transactions + std::map::iterator it3 = mapOrphanTransactions.begin(); + for (; it3 != mapOrphanTransactions.end(); it3++) + delete (*it3).second; + mapOrphanTransactions.clear(); + } +} instance_of_cmaincleanup; -- cgit v1.2.3