Index: src/helpers.cpp
===================================================================
--- src/helpers.cpp	(revision c0917c976855c93e7755fae6eabf5a1b2cd9255e)
+++ src/helpers.cpp	(revision 21b9c3591722efc708e1482ec02108da1918128b)
@@ -144,3 +144,13 @@
 };
 
+/**
+ * Frees all memory registered by the memory observer and calls exit(225) afterwards.
+ */
+void performCriticalExit() {
+  map<void*, size_t> pointers = MemoryUsageObserver::getInstance()->getPointersToAllocatedMemory();
+  for (map<void*, size_t>::iterator runner = pointers.begin(); runner != pointers.end(); runner++) {
+    Free(((void**) &runner->first));
+  }
 
+  exit(255);
+}
Index: src/helpers.hpp
===================================================================
--- src/helpers.hpp	(revision c0917c976855c93e7755fae6eabf5a1b2cd9255e)
+++ src/helpers.hpp	(revision 21b9c3591722efc708e1482ec02108da1918128b)
@@ -51,11 +51,7 @@
 void flip(double *x, double *y);
 int pot(int base, int n);
-//void * Malloc(size_t size, const char* output);
-//void * Calloc(size_t size, const char* output);
-//void * ReAlloc(void * OldPointer, size_t size, const char* output);
-//char* MallocString(size_t size, const char* output);
-//void Free(void ** buffer, const char* output);
 char *FixedDigitNumber(const int FragmentNumber, const int digits);
 bool IsValidNumber( const char *string);
+static void performCriticalExit();
 
 /********************************************** helpful template functions *********************************/
Index: src/memoryallocator.hpp
===================================================================
--- src/memoryallocator.hpp	(revision c0917c976855c93e7755fae6eabf5a1b2cd9255e)
+++ src/memoryallocator.hpp	(revision 21b9c3591722efc708e1482ec02108da1918128b)
@@ -111,10 +111,10 @@
  * \param pointer to the allocated memory range to free; may be NULL, this function is a no-op then
  */
-template <typename X> void Free(X** buffer)
+template <typename X> void Free(X** buffer, const char *msg = NULL)
 {
   if ((buffer == NULL) || (*buffer == NULL))
     return;
 
-  MemoryUsageObserver::getInstance()->removeMemory(*buffer);
+  MemoryUsageObserver::getInstance()->removeMemory(*buffer, msg);
   free(*buffer);
   *buffer = NULL;
Index: src/memoryusageobserver.cpp
===================================================================
--- src/memoryusageobserver.cpp	(revision c0917c976855c93e7755fae6eabf5a1b2cd9255e)
+++ src/memoryusageobserver.cpp	(revision 21b9c3591722efc708e1482ec02108da1918128b)
@@ -78,10 +78,13 @@
  * \param pointer to the allocated piece of memory
  */
-void MemoryUsageObserver::removeMemory(void* pointer) {
+void MemoryUsageObserver::removeMemory(void* pointer, const char *msg) {
   map<void*, size_t>::iterator current = memoryUsers.find(pointer);
 
   if (current == memoryUsers.end()) {
     cout << "WARNING: There is non-tracked memory to be freed. Pointer "
-      << pointer << " is not registered by MemoryUsageObserver." << endl;
+      << pointer << " is not registered by MemoryUsageObserver";
+    if (msg != NULL)
+      cout << ": " << msg;
+    cout << "." << endl;
     return;
   }
@@ -104,2 +107,10 @@
   return maximumSize;
 }
+
+/**
+ * Gets a map with pointers to the currently allocated memory ranges as keys and
+ * the allocated size as value.
+ */
+map<void*, size_t> MemoryUsageObserver::getPointersToAllocatedMemory() {
+  return memoryUsers;
+}
Index: src/memoryusageobserver.hpp
===================================================================
--- src/memoryusageobserver.hpp	(revision c0917c976855c93e7755fae6eabf5a1b2cd9255e)
+++ src/memoryusageobserver.hpp	(revision 21b9c3591722efc708e1482ec02108da1918128b)
@@ -28,7 +28,8 @@
   static void purgeInstance();
   void addMemory(void* pointer, size_t size);
-  void removeMemory(void* pointer);
+  void removeMemory(void* pointer, const char *msg = NULL);
   size_t getUsedMemorySize();
   size_t getMaximumUsedMemory();
+  map<void*, size_t> getPointersToAllocatedMemory();
 
 protected:
Index: src/memoryusageobserverunittest.cpp
===================================================================
--- src/memoryusageobserverunittest.cpp	(revision c0917c976855c93e7755fae6eabf5a1b2cd9255e)
+++ src/memoryusageobserverunittest.cpp	(revision 21b9c3591722efc708e1482ec02108da1918128b)
@@ -10,4 +10,5 @@
 #include <cppunit/ui/text/TestRunner.h>
 
+#include "memoryallocator.hpp"
 #include "memoryusageobserver.hpp"
 #include "memoryusageobserverunittest.hpp"
@@ -41,5 +42,5 @@
 void MemoryUsageObserverTest::getInstanceTwiceReturnsSameInstanceTest()
 {
-  int* i = new int;
+  int* i = Malloc<int>(1, "MemoryUsageObserverTest::getInstanceTwiceReturnsSameInstanceTest - i");
   MemoryUsageObserver::getInstance()->addMemory(i, sizeof(int));
   CPPUNIT_ASSERT_EQUAL(sizeof(int), MemoryUsageObserver::getInstance()->getUsedMemorySize());
@@ -52,5 +53,5 @@
 void MemoryUsageObserverTest::getInstanceAfterPurgeInstanceReturnsNewInstanceTest()
 {
-  int* i = new int;
+  int* i = Malloc<int>(1, "MemoryUsageObserverTest::getInstanceAfterPurgeInstanceReturnsNewInstanceTest - i");
   MemoryUsageObserver::getInstance()->addMemory(i, sizeof(int));
   CPPUNIT_ASSERT_EQUAL(sizeof(int), MemoryUsageObserver::getInstance()->getUsedMemorySize());
@@ -64,5 +65,5 @@
 void MemoryUsageObserverTest::addAndRemoveMemoryTest()
 {
-  int* i = new int;
+  int* i = Malloc<int>(1, "MemoryUsageObserverTest::addAndRemoveMemoryTest - i");
   MemoryUsageObserver::getInstance()->addMemory(i, sizeof(int));
   CPPUNIT_ASSERT_EQUAL(sizeof(int), MemoryUsageObserver::getInstance()->getUsedMemorySize());
@@ -76,5 +77,5 @@
 void MemoryUsageObserverTest::removeNonTrackedMemoryDoesNotCauseACrashTest()
 {
-  int* i = new int;
+  int* i = Malloc<int>(1, "MemoryUsageObserverTest::removeNonTrackedMemoryDoesNotCauseACrashTest - i");
   MemoryUsageObserver::getInstance()->removeMemory(i);
   CPPUNIT_ASSERT_EQUAL((size_t) 0, MemoryUsageObserver::getInstance()->getUsedMemorySize());
@@ -86,10 +87,10 @@
 void MemoryUsageObserverTest::addMemoryTwiceTest()
 {
-  int* i = new int;
-  int* j = new int;
+  int* i = Malloc<int>(1, "MemoryUsageObserverTest::addMemoryTwiceTest - i");
+  int* j = Malloc<int>(1, "MemoryUsageObserverTest::addMemoryTwiceTest - j");
   MemoryUsageObserver::getInstance()->addMemory(i, sizeof(int));
   MemoryUsageObserver::getInstance()->addMemory(j, sizeof(int));
   CPPUNIT_ASSERT_EQUAL(2 * sizeof(int), MemoryUsageObserver::getInstance()->getUsedMemorySize());
- };
+};
 
 /**
@@ -98,9 +99,9 @@
 void MemoryUsageObserverTest::addMemoryAndChangeSizeOfAddedMemoryTest()
 {
-  int* i = new int;
+  int* i = Malloc<int>(1, "MemoryUsageObserverTest::addMemoryAndChangeSizeOfAddedMemoryTest - i");
   MemoryUsageObserver::getInstance()->addMemory(i, 2 * sizeof(int));
   MemoryUsageObserver::getInstance()->addMemory(i, sizeof(int));
   CPPUNIT_ASSERT_EQUAL(sizeof(int), MemoryUsageObserver::getInstance()->getUsedMemorySize());
- };
+};
 
 /**
@@ -109,9 +110,9 @@
 void MemoryUsageObserverTest::addMemoryChangeSizeOfAddedMemoryAndGetMaximumSizeTest()
 {
-  int* i = new int;
+  int* i = Malloc<int>(1, "MemoryUsageObserverTest::addMemoryChangeSizeOfAddedMemoryAndGetMaximumSizeTest - i");
   MemoryUsageObserver::getInstance()->addMemory(i, 2 * sizeof(int));
   MemoryUsageObserver::getInstance()->addMemory(i, sizeof(int));
   CPPUNIT_ASSERT_EQUAL(2 * sizeof(int), MemoryUsageObserver::getInstance()->getMaximumUsedMemory());
- };
+};
 
 /**
@@ -120,9 +121,21 @@
 void MemoryUsageObserverTest::addMemoryRemoveMemoryAndGetMaximumSizeTest()
 {
-  int* i = new int;
+  int* i = Malloc<int>(1, "MemoryUsageObserverTest::addMemoryRemoveMemoryAndGetMaximumSizeTest - i");
   MemoryUsageObserver::getInstance()->addMemory(i, sizeof(int));
   MemoryUsageObserver::getInstance()->removeMemory(i);
   CPPUNIT_ASSERT_EQUAL(sizeof(int), MemoryUsageObserver::getInstance()->getMaximumUsedMemory());
- };
+};
+
+/**
+ * UnitTest for getPointersToAllocatedMemory()
+ */
+void MemoryUsageObserverTest::getPointersToAllocatedMemoryTest()
+{
+  int* i = Malloc<int>(1, "MemoryUsageObserverTest::getPointersToAllocatedMemoryTest - i");
+  MemoryUsageObserver::getInstance()->addMemory(i, sizeof(int));
+  CPPUNIT_ASSERT_EQUAL(i, (int*) MemoryUsageObserver::getInstance()->getPointersToAllocatedMemory().begin()->first);
+};
+
+
 /********************************************** Main routine **************************************/
 
Index: src/memoryusageobserverunittest.hpp
===================================================================
--- src/memoryusageobserverunittest.hpp	(revision c0917c976855c93e7755fae6eabf5a1b2cd9255e)
+++ src/memoryusageobserverunittest.hpp	(revision 21b9c3591722efc708e1482ec02108da1918128b)
@@ -24,4 +24,5 @@
     CPPUNIT_TEST ( addMemoryChangeSizeOfAddedMemoryAndGetMaximumSizeTest );
     CPPUNIT_TEST ( addMemoryRemoveMemoryAndGetMaximumSizeTest );
+    CPPUNIT_TEST ( getPointersToAllocatedMemoryTest );
     CPPUNIT_TEST_SUITE_END();
 
@@ -39,4 +40,5 @@
     void addMemoryChangeSizeOfAddedMemoryAndGetMaximumSizeTest();
     void addMemoryRemoveMemoryAndGetMaximumSizeTest();
+    void getPointersToAllocatedMemoryTest();
 };
 
