]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Implementation of memory monitoring.
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 9 Feb 2001 20:02:32 +0000 (20:02 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 9 Feb 2001 20:02:32 +0000 (20:02 +0000)
git-svn-id: https://svn.dealii.org/trunk@3898 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/base/include/base/object_monitor.h [new file with mode: 0644]
deal.II/base/include/base/object_monitor_activator.h [new file with mode: 0644]
deal.II/base/source/object_monitor.cc [new file with mode: 0644]
deal.II/base/source/object_monitor_activator.cc [new file with mode: 0644]

diff --git a/deal.II/base/include/base/object_monitor.h b/deal.II/base/include/base/object_monitor.h
new file mode 100644 (file)
index 0000000..d64d9bc
--- /dev/null
@@ -0,0 +1,48 @@
+//----------------------------  object_monitor.h  ---------------------------
+//    $Id$
+//    Version: $Name$
+//
+//    Copyright (C) 1998, 1999, 2000, 2001 by the deal.II authors
+//
+//    This file is subject to QPL and may not be  distributed
+//    without copyright and license information. Please refer
+//    to the file deal.II/doc/license.html for the  text  and
+//    further information on this license.
+//
+//----------------------------  object_monitor.h  ---------------------------
+#ifndef __deal2__object_monitor_h
+#define __deal2__object_monitor_h
+
+
+
+#include <set>
+
+class Subscriptor;
+
+
+
+class ObjectMonitor
+{
+  public:
+    ObjectMonitor ();
+    ~ObjectMonitor ();
+
+    void activate ();
+    void deactivate ();
+    
+    void register_object (const Subscriptor *p);
+    void deregister_object (const Subscriptor *p);
+  private:
+    std::set<const Subscriptor*> registered_objects;
+    bool activated;
+};
+
+
+extern ObjectMonitor *object_monitor;
+
+
+
+#endif
+
+
+
diff --git a/deal.II/base/include/base/object_monitor_activator.h b/deal.II/base/include/base/object_monitor_activator.h
new file mode 100644 (file)
index 0000000..ea05c02
--- /dev/null
@@ -0,0 +1,33 @@
+//----------------------------  object_monitor_activator.h  ---------------------------
+//    $Id$
+//    Version: $Name$
+//
+//    Copyright (C) 1998, 1999, 2000, 2001 by the deal.II authors
+//
+//    This file is subject to QPL and may not be  distributed
+//    without copyright and license information. Please refer
+//    to the file deal.II/doc/license.html for the  text  and
+//    further information on this license.
+//
+//----------------------------  object_monitor_activator.h  ---------------------------
+#ifndef __deal2__object_monitor_activator_h
+#define __deal2__object_monitor_activator_h
+
+
+
+
+class ObjectMonitorActivator
+{
+  public:
+    ObjectMonitorActivator ();
+    ~ObjectMonitorActivator ();
+};
+
+
+
+
+
+#endif
+
+
+
diff --git a/deal.II/base/source/object_monitor.cc b/deal.II/base/source/object_monitor.cc
new file mode 100644 (file)
index 0000000..8322114
--- /dev/null
@@ -0,0 +1,76 @@
+//----------------------------  object_monitor.cc  ---------------------------
+//    $Id$
+//    Version: $Name$
+//
+//    Copyright (C) 1998, 1999, 2000, 2001 by the deal.II authors
+//
+//    This file is subject to QPL and may not be  distributed
+//    without copyright and license information. Please refer
+//    to the file deal.II/doc/license.html for the  text  and
+//    further information on this license.
+//
+//----------------------------  object_monitor.cc  ---------------------------
+
+
+#include <base/object_monitor.h>
+#include <base/subscriptor.h>
+
+
+ObjectMonitor *object_monitor;
+
+
+
+ObjectMonitor::ObjectMonitor ():
+               activated (false)
+{};
+
+
+ObjectMonitor::~ObjectMonitor ()
+{};
+
+
+
+void ObjectMonitor::activate ()
+{
+  activated=true;
+};
+
+
+
+void ObjectMonitor::deactivate ()
+{
+  activated = false;
+  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;
+      abort ();
+    };
+};
+
+
+void ObjectMonitor::register_object (const Subscriptor *p)
+{
+  if (activated)
+    {
+      cout << typeid(*p).name() << endl;
+      if (registered_objects.find(p) != registered_objects.end())
+       abort();
+      registered_objects.insert (p);
+    };
+};
+
+
+void
+ObjectMonitor::deregister_object (const Subscriptor *p)
+{
+  if (activated)
+    {
+      if (registered_objects.find(p) == registered_objects.end())
+       abort();
+      registered_objects.erase (registered_objects.find(p));
+    };
+};
diff --git a/deal.II/base/source/object_monitor_activator.cc b/deal.II/base/source/object_monitor_activator.cc
new file mode 100644 (file)
index 0000000..1d05167
--- /dev/null
@@ -0,0 +1,31 @@
+//----------------------------  object_monitor_activator.cc  ---------------------------
+//    $Id$
+//    Version: $Name$
+//
+//    Copyright (C) 1998, 1999, 2000, 2001 by the deal.II authors
+//
+//    This file is subject to QPL and may not be  distributed
+//    without copyright and license information. Please refer
+//    to the file deal.II/doc/license.html for the  text  and
+//    further information on this license.
+//
+//----------------------------  object_monitor_activator.cc  ---------------------------
+
+
+#include <base/object_monitor.h>
+#include <base/object_monitor_activator.h>
+#include <base/subscriptor.h>
+
+
+ObjectMonitorActivator::ObjectMonitorActivator ()
+{
+  if (true)
+    Subscriptor b;
+  object_monitor->activate();
+};
+
+
+ObjectMonitorActivator::~ObjectMonitorActivator ()
+{
+  object_monitor->deactivate();
+};

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.