aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/runtime/malloc.goc
diff options
context:
space:
mode:
authorDmitriy Vyukov <dvyukov@google.com>2014-05-19 12:06:30 +0400
committerDmitriy Vyukov <dvyukov@google.com>2014-05-19 12:06:30 +0400
commite893acf1848b96a922356eb753e8cea79f469afd (patch)
tree4d2a7c0b6be80fbb053493cad8e70b9b2114d308 /src/pkg/runtime/malloc.goc
parentd021d982daa3f12701722bcb5420675fd2295d6a (diff)
downloadgo-e893acf1848b96a922356eb753e8cea79f469afd.tar.xz
runtime: fix freeOSMemory to free memory immediately
Currently freeOSMemory makes only marking phase of GC, but not sweeping phase. So recently memory is not released after freeOSMemory. Do both marking and sweeping during freeOSMemory. Fixes #8019. LGTM=khr R=golang-codereviews, khr CC=golang-codereviews, rsc https://golang.org/cl/97550043
Diffstat (limited to 'src/pkg/runtime/malloc.goc')
-rw-r--r--src/pkg/runtime/malloc.goc11
1 files changed, 1 insertions, 10 deletions
diff --git a/src/pkg/runtime/malloc.goc b/src/pkg/runtime/malloc.goc
index 6371689a9c..6e1068d93d 100644
--- a/src/pkg/runtime/malloc.goc
+++ b/src/pkg/runtime/malloc.goc
@@ -849,16 +849,7 @@ runtime·cnewarray(Type *typ, intgo n)
}
func GC() {
- // We assume that the user expects unused memory to have
- // been freed when GC returns. To ensure this, run gc(1) twice.
- // The first will do a collection, and the second will force the
- // first's sweeping to finish before doing a second collection.
- // The second collection is overkill, but we assume the user
- // has a good reason for calling runtime.GC and can stand the
- // expense. At the least, this fixes all the calls to runtime.GC in
- // tests that expect finalizers to start running when GC returns.
- runtime·gc(1);
- runtime·gc(1);
+ runtime·gc(2); // force GC and do eager sweep
}
func SetFinalizer(obj Eface, finalizer Eface) {