]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Implement a method to track whether there are objects of type
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Fri, 9 Feb 2001 17:01:16 +0000 (17:01 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Fri, 9 Feb 2001 17:01:16 +0000 (17:01 +0000)
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

index d9f09d81fa571ade53d248c8d047996a30cf7ad6..9821173945e9d559651e59323cec9b730cd04f7d 100644 (file)
 #include <base/subscriptor.h>
 #include <typeinfo>
 
+/*
+#include <set>
+
+template <class Class>
+class ActiveObjectMonitor
+{
+  public:
+    ~ActiveObjectMonitor ();
+    
+    void register_object (const Class *p);
+    void deregister_object (const Class *p);
+  private:
+    std::set<const Class*> registered_objects;
+};
+
+ActiveObjectMonitor<Subscriptor> active_object_monitor;
+
+
+ActiveObjectMonitor::~ActiveObjectMonitor ()
+{
+  if (registered_objects.size() > 0)
+    {
+      for (std::set<const Subscriptor*>::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 () :

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.