diff options
author | kenton@google.com <kenton@google.com@630680e5-0e50-0410-840e-4b1c322b438d> | 2009-05-06 19:27:03 +0000 |
---|---|---|
committer | kenton@google.com <kenton@google.com@630680e5-0e50-0410-840e-4b1c322b438d> | 2009-05-06 19:27:03 +0000 |
commit | 63e646b7ad6f18228c1807f8d18111ae96e86aa7 (patch) | |
tree | fc524e6f55b32b7d786bd41623402394a2f1af26 /src/google/protobuf/testing/googletest.cc | |
parent | 9824eda6b558cd88c63064017593521ecad2029f (diff) | |
download | protobuf-63e646b7ad6f18228c1807f8d18111ae96e86aa7.tar.gz protobuf-63e646b7ad6f18228c1807f8d18111ae96e86aa7.tar.bz2 protobuf-63e646b7ad6f18228c1807f8d18111ae96e86aa7.zip |
Provide ShutdownProtobufLibrary() which frees all startup-allocated objects.
Diffstat (limited to 'src/google/protobuf/testing/googletest.cc')
-rw-r--r-- | src/google/protobuf/testing/googletest.cc | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/google/protobuf/testing/googletest.cc b/src/google/protobuf/testing/googletest.cc index 99dbbb32..1339b332 100644 --- a/src/google/protobuf/testing/googletest.cc +++ b/src/google/protobuf/testing/googletest.cc @@ -233,5 +233,19 @@ void ScopedMemoryLog::HandleLog(LogLevel level, const char* filename, } } +namespace { + +// Force shutdown at process exit so that we can test for memory leaks. To +// actually check for leaks, I suggest using the heap checker included with +// google-perftools. Set it to "draconian" mode to ensure that every last +// call to malloc() has a corresponding free(). +struct ForceShutdown { + ~ForceShutdown() { + ShutdownProtobufLibrary(); + } +} force_shutdown; + +} // namespace + } // namespace protobuf } // namespace google |