From: Wolfgang Bangerth Date: Fri, 9 Feb 2001 17:01:16 +0000 (+0000) Subject: Implement a method to track whether there are objects of type X-Git-Tag: v8.0.0~19739 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3c5a23f889d66ea090a9905e951f0e57c6364418;p=dealii.git 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 --- 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 () :