Free various things we allocate
authorIan Lynagh <igloo@earth.li>
Fri, 15 Dec 2006 13:45:07 +0000 (13:45 +0000)
committerIan Lynagh <igloo@earth.li>
Fri, 15 Dec 2006 13:45:07 +0000 (13:45 +0000)
rts/Capability.c
rts/RtsStartup.c
rts/Sparks.c
rts/Sparks.h
rts/ThreadLabels.c
rts/ThreadLabels.h
rts/sm/Storage.c

index f1c625e..3d55b42 100644 (file)
@@ -673,6 +673,8 @@ shutdownCapability (Capability *cap, Task *task)
            continue;
        }
        debugTrace(DEBUG_sched, "capability %d is stopped.", cap->no);
+        stgFree(cap->mut_lists);
+        freeSparkPool(&cap->r.rSparks);
        RELEASE_LOCK(&cap->lock);
        break;
     }
index 937334b..87df96a 100644 (file)
@@ -444,9 +444,14 @@ hs_exit(void)
     /* free shared Typeable store */
     exitTypeableStore();
 
-    /* initialise the stable pointer table */
+    /* free the stable pointer table */
     exitStablePtrTable();
 
+#if defined(DEBUG)
+    /* free the thread label table */
+    freeThreadLabelTable();
+#endif
+
     /* free hash table storage */
     exitHashTable();
 
index 40ebcad..ca60e13 100644 (file)
@@ -63,6 +63,11 @@ initSparkPools( void )
 #endif
 }
 
+void
+freeSparkPool(StgSparkPool *pool) {
+    stgFree(pool->base);
+}
+
 /* -----------------------------------------------------------------------------
  * 
  * findSpark: find a spark on the current Capability that we can fork
index 65db52d..f2d3c6e 100644 (file)
@@ -12,6 +12,7 @@
 #if defined(PARALLEL_HASKELL) || defined(THREADED_RTS)
 StgClosure * findSpark         (Capability *cap);
 void         initSparkPools    (void);
+void         freeSparkPool     (StgSparkPool *pool);
 void         markSparkQueue    (evac_fn evac);
 void         createSparkThread (Capability *cap, StgClosure *p);
 
index 1c89d84..6919e1a 100644 (file)
@@ -29,6 +29,15 @@ initThreadLabelTable(void)
 }
 
 void
+freeThreadLabelTable(void)
+{
+    if (threadLabels != NULL) {
+        freeHashTable(threadLabels, NULL);
+        threadLabels = NULL;
+    }
+}
+
+void
 updateThreadLabel(StgWord key, void *data)
 {
   removeThreadLabel(key);
index eaed22d..59eb321 100644 (file)
@@ -12,6 +12,7 @@
 
 #if defined(DEBUG)
 void    initThreadLabelTable (void);
+void    freeThreadLabelTable (void);
 void    updateThreadLabel    (StgWord key, void *data);
 void *  lookupThreadLabel    (StgWord key);
 void    removeThreadLabel    (StgWord key);
index 1d08a85..6e862f2 100644 (file)
@@ -287,6 +287,7 @@ freeStorage (void)
 #if defined(THREADED_RTS)
     closeMutex(&sm_mutex);
     closeMutex(&atomic_modify_mutvar_mutex);
+    stgFree(nurseries);
 #endif
 }