[commit: ghc] master: fix a small memory leak with +RTS -hb (334545e)

git at git.haskell.org git at git.haskell.org
Thu Nov 14 12:07:42 UTC 2013


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/334545e010051f31266f6637fa999d1df438b065/ghc

>---------------------------------------------------------------

commit 334545e010051f31266f6637fa999d1df438b065
Author: Simon Marlow <marlowsd at gmail.com>
Date:   Wed Nov 13 10:21:47 2013 +0000

    fix a small memory leak with +RTS -hb


>---------------------------------------------------------------

334545e010051f31266f6637fa999d1df438b065
 rts/ProfHeap.c |   19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/rts/ProfHeap.c b/rts/ProfHeap.c
index f094038..6d78886 100644
--- a/rts/ProfHeap.c
+++ b/rts/ProfHeap.c
@@ -262,12 +262,8 @@ initEra(Census *census)
 STATIC_INLINE void
 freeEra(Census *census)
 {
-    if (RtsFlags.ProfFlags.bioSelector != NULL)
-        // when bioSelector==NULL, these are freed in heapCensus()
-    {
-        arenaFree(census->arena);
-        freeHashTable(census->hash, NULL);
-    }
+    arenaFree(census->arena);
+    freeHashTable(census->hash, NULL);
 }
 
 /* --------------------------------------------------------------------------
@@ -467,8 +463,12 @@ endHeapProfiling(void)
 #ifdef PROFILING
     if (doingLDVProfiling()) {
         nat t;
-        for (t = 1; t <= era; t++) {
-            freeEra( &censuses[t] );
+        if (RtsFlags.ProfFlags.bioSelector != NULL) {
+            for (t = 1; t <= era; t++) {
+                freeEra( &censuses[t] );
+            }
+        } else {
+            freeEra( &censuses[era] );
         }
     } else {
         freeEra( &censuses[0] );
@@ -1125,8 +1125,7 @@ void heapCensus (Time t)
 #ifdef PROFILING
   if (RtsFlags.ProfFlags.bioSelector == NULL)
   {
-      freeHashTable( census->hash, NULL/* don't free the elements */ );
-      arenaFree( census->arena );
+      freeEra(census);
       census->hash = NULL;
       census->arena = NULL;
   }



More information about the ghc-commits mailing list