X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=rts%2Fsm%2FGC.c;h=ec5f70070532cc223cb63ef6c0a6877db1d6cff8;hb=fff1f6194c3c39de53cd645bda9865fb131b1c68;hp=18a87bdbfa927e95afd4cd9fad4bc66416ff2339;hpb=afabd52e95235ab36c5ad7b3473b5d6a4d58360b;p=ghc-hetmet.git diff --git a/rts/sm/GC.c b/rts/sm/GC.c index 18a87bd..ec5f700 100644 --- a/rts/sm/GC.c +++ b/rts/sm/GC.c @@ -746,6 +746,19 @@ SET_GCT(gc_threads[0]); scheduleFinalizers(cap, old_weak_ptr_list); ACQUIRE_SM_LOCK; + if (major_gc) { + nat need, got; + need = BLOCKS_TO_MBLOCKS(n_alloc_blocks); + got = mblocks_allocated; + /* If the amount of data remains constant, next major GC we'll + require (F+1)*need. We leave (F+2)*need in order to reduce + repeated deallocation and reallocation. */ + need = (RtsFlags.GcFlags.oldGenFactor + 2) * need; + if (got > need) { + returnMemoryToOS(got - need); + } + } + // check sanity after GC IF_DEBUG(sanity, checkSanity(rtsTrue)); @@ -1296,6 +1309,10 @@ init_collected_gen (nat g, nat n_threads) if (!(bd->flags & BF_FRAGMENTED)) { bd->flags |= BF_MARKED; } + + // BF_SWEPT should be marked only for blocks that are being + // collected in sweep() + bd->flags &= ~BF_SWEPT; } } }