From 3c5a23f889d66ea090a9905e951f0e57c6364418 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Fri, 9 Feb 2001 17:01:16 +0000 Subject: [PATCH] Implement a method to track whether there are objects of type Subscriptor alive at the end of the program. This might be used to track down memory leaks. Unfortunately, it requires that there be a global object that may be used when the first object of type Subscriptor is constructed. Since there are global and/or static member variables of that type, we get into ordering problems since we can't guarantee that the global ActiveObjectMonitor is created *before* the first global object of type Subscriptor. The code is therefore commented out for now, until we have found a satisfactory solution. git-svn-id: https://svn.dealii.org/trunk@3893 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/base/source/subscriptor.cc | 50 ++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/deal.II/base/source/subscriptor.cc b/deal.II/base/source/subscriptor.cc index d9f09d81fa..9821173945 100644 --- a/deal.II/base/source/subscriptor.cc +++ b/deal.II/base/source/subscriptor.cc @@ -15,6 +15,56 @@ #include #include +/* +#include + +template +class ActiveObjectMonitor +{ + public: + ~ActiveObjectMonitor (); + + void register_object (const Class *p); + void deregister_object (const Class *p); + private: + std::set registered_objects; +}; + +ActiveObjectMonitor active_object_monitor; + + +ActiveObjectMonitor::~ActiveObjectMonitor () +{ + if (registered_objects.size() > 0) + { + for (std::set::const_iterator i=registered_objects.begin(); + i!=registered_objects.end(); ++i) + std::cout << "Object still exists of type " + << typeid(**i).name() + << std::endl; + Assert (false, ExcInternalError()); + }; +}; + + +void ActiveObjectMonitor::register_object (const Subscriptor *p) +{ + Assert (registered_objects.find(p) == registered_objects.end(), + ExcInternalError()); + registered_objects.insert (p); +}; + + +void +ActiveObjectMonitor::deregister_object (const Subscriptor *p) +{ + Assert (registered_objects.find(p) != registered_objects.end(), + ExcInternalError()); + registered_objects.erase (registered_objects.find(p)); +}; +*/ + + Subscriptor::Subscriptor () : -- 2.39.5