Call protobuff::Shutdown to free dynamic data

This commit is contained in:
Vinnie Falco
2013-09-17 18:48:01 -07:00
parent e2e8f85b3c
commit 985db3fa16
2 changed files with 39 additions and 31 deletions

View File

@@ -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;
}

View File

@@ -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 <ProtobufLibrary>::get ();
int result (0);
ripple::RippleMain rippled;
return rippled.runFromMain (argc, argv);
result = rippled.runFromMain (argc, argv);
return result;
}