Navigation Menu

Skip to content

Commit

Permalink
fix some shutdown memory leaks
Browse files Browse the repository at this point in the history
  • Loading branch information
simonmar committed Aug 20, 2010
1 parent fa13a9b commit d63ba79
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions rts/sm/MBlock.c
Expand Up @@ -88,10 +88,11 @@ setHeapAlloced(void *p, StgWord8 i)
if(map == NULL)
{
mblock_map_count++;
mblock_maps = realloc(mblock_maps,
sizeof(MBlockMap*) * mblock_map_count);
mblock_maps = stgReallocBytes(mblock_maps,
sizeof(MBlockMap*) * mblock_map_count,
"markHeapAlloced(1)");
map = mblock_maps[mblock_map_count-1] =
stgMallocBytes(sizeof(MBlockMap),"markHeapAlloced");
stgMallocBytes(sizeof(MBlockMap),"markHeapAlloced(2)");
memset(map,0,sizeof(MBlockMap));
map->addrHigh32 = (StgWord32) (((StgWord)p) >> 32);
}
Expand Down Expand Up @@ -264,8 +265,16 @@ freeMBlocks(void *addr, nat n)
void
freeAllMBlocks(void)
{
nat n;

debugTrace(DEBUG_gc, "freeing all megablocks");

osFreeAllMBlocks();

for (n = 0; n < mblock_map_count; n++) {
stgFree(mblock_maps[n]);
}
stgFree(mblock_maps);
}

void
Expand Down

0 comments on commit d63ba79

Please sign in to comment.