mirror of
https://github.com/golang/go
synced 2024-11-27 00:11:19 -07:00
runtime: fix runaway memory usage
It was caused by mstats.heap_alloc skew. Fixes #7430. LGTM=khr R=golang-codereviews, khr CC=golang-codereviews, rsc https://golang.org/cl/69870055
This commit is contained in:
parent
fd7ff20495
commit
aea99eda0f
@ -329,6 +329,7 @@ runtime·free(void *v)
|
||||
// it might coalesce v and other blocks into a bigger span
|
||||
// and change the bitmap further.
|
||||
c->local_nsmallfree[sizeclass]++;
|
||||
c->local_cachealloc -= size;
|
||||
if(c->alloc[sizeclass] == s) {
|
||||
// We own the span, so we can just add v to the freelist
|
||||
runtime·markfreed(v);
|
||||
|
@ -97,7 +97,6 @@ runtime·MCache_Free(MCache *c, MLink *p, int32 sizeclass, uintptr size)
|
||||
p->next = l->list;
|
||||
l->list = p;
|
||||
l->nlist++;
|
||||
c->local_cachealloc -= size;
|
||||
|
||||
// We transfer a span at a time from MCentral to MCache,
|
||||
// so we'll do the same in the other direction.
|
||||
|
@ -2346,8 +2346,12 @@ gc(struct gc_args *args)
|
||||
runtime·printf("pause %D\n", t4-t0);
|
||||
|
||||
if(runtime·debug.gctrace) {
|
||||
updatememstats(&stats);
|
||||
heap1 = mstats.heap_alloc;
|
||||
updatememstats(&stats);
|
||||
if(heap1 != mstats.heap_alloc) {
|
||||
runtime·printf("runtime: mstats skew: heap=%p/%p\n", heap1, mstats.heap_alloc);
|
||||
runtime·throw("mstats skew");
|
||||
}
|
||||
obj = mstats.nmalloc - mstats.nfree;
|
||||
|
||||
stats.nprocyield += work.markfor->nprocyield;
|
||||
|
Loading…
Reference in New Issue
Block a user