From 985db3fa1679fd3567b46fea61fc39eadf14e5b8 Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Tue, 17 Sep 2013 18:48:01 -0700 Subject: [PATCH] Call protobuff::Shutdown to free dynamic data --- src/ripple_app/main/RippleMain.cpp | 32 ++----------------------- src/ripple_app/ripple_app.cpp | 38 +++++++++++++++++++++++++++++- 2 files changed, 39 insertions(+), 31 deletions(-) diff --git a/src/ripple_app/main/RippleMain.cpp b/src/ripple_app/main/RippleMain.cpp index a9ec433a3..30366b7e6 100644 --- a/src/ripple_app/main/RippleMain.cpp +++ b/src/ripple_app/main/RippleMain.cpp @@ -220,36 +220,6 @@ int RippleMain::run (int argc, char const* const* argv) { FatalErrorReporter reporter; - // - // These debug heap calls do nothing in release or non Visual Studio builds. - // - - // Checks the heap at every allocation and deallocation (slow). - // - //Debug::setAlwaysCheckHeap (false); - - // Keeps freed memory blocks and fills them with a guard value. - // - //Debug::setHeapDelayedFree (false); - - // At exit, reports all memory blocks which have not been freed. - // -#if RIPPLE_DUMP_LEAKS_ON_EXIT - Debug::setHeapReportLeaks (true); -#else - Debug::setHeapReportLeaks (false); -#endif - -#if 0 - // This is some temporary leak checking test code - Debug::setHeapReportLeaks (false); - //malloc (512); // Any leaks before this line in the output are from static initializations. - ThreadWithCallQueue t ("test"); - GlobalPagedFreeStore::getInstance (); - t.start (); - return 0; -#endif - using namespace std; setCallingThreadName ("main"); @@ -474,3 +444,5 @@ int RippleMain::run (int argc, char const* const* argv) return iResult; } + + diff --git a/src/ripple_app/ripple_app.cpp b/src/ripple_app/ripple_app.cpp index a5a930c14..8022bffd9 100644 --- a/src/ripple_app/ripple_app.cpp +++ b/src/ripple_app/ripple_app.cpp @@ -70,10 +70,46 @@ namespace ripple //------------------------------------------------------------------------------ +struct ProtobufLibrary +{ + ~ProtobufLibrary () + { + google::protobuf::ShutdownProtobufLibrary(); + } +}; + // Must be outside the namespace for obvious reasons // int main (int argc, char** argv) { + // + // These debug heap calls do nothing in release or non Visual Studio builds. + // + + // Checks the heap at every allocation and deallocation (slow). + // + //beast::Debug::setAlwaysCheckHeap (false); + + // Keeps freed memory blocks and fills them with a guard value. + // + //beast::Debug::setHeapDelayedFree (false); + + // At exit, reports all memory blocks which have not been freed. + // +#if RIPPLE_DUMP_LEAKS_ON_EXIT + beast::Debug::setHeapReportLeaks (true); +#else + beast::Debug::setHeapReportLeaks (false); +#endif + + beast::SharedSingleton ::get (); + + int result (0); + ripple::RippleMain rippled; - return rippled.runFromMain (argc, argv); + + result = rippled.runFromMain (argc, argv); + + return result; } +