mirror of
https://github.com/golang/go
synced 2024-11-13 19:30:22 -07:00
runtime: print scavenger details when forced with debug.FreeOSMemory
Fixes #5900. R=golang-dev, bradfitz CC=golang-dev https://golang.org/cl/12669043
This commit is contained in:
parent
1f4d58ad5d
commit
9f46efce52
@ -412,8 +412,8 @@ scavengelist(MSpan *list, uint64 now, uint64 limit)
|
|||||||
return sumreleased;
|
return sumreleased;
|
||||||
}
|
}
|
||||||
|
|
||||||
static uintptr
|
static void
|
||||||
scavenge(uint64 now, uint64 limit)
|
scavenge(int32 k, uint64 now, uint64 limit)
|
||||||
{
|
{
|
||||||
uint32 i;
|
uint32 i;
|
||||||
uintptr sumreleased;
|
uintptr sumreleased;
|
||||||
@ -424,7 +424,14 @@ scavenge(uint64 now, uint64 limit)
|
|||||||
for(i=0; i < nelem(h->free); i++)
|
for(i=0; i < nelem(h->free); i++)
|
||||||
sumreleased += scavengelist(&h->free[i], now, limit);
|
sumreleased += scavengelist(&h->free[i], now, limit);
|
||||||
sumreleased += scavengelist(&h->large, now, limit);
|
sumreleased += scavengelist(&h->large, now, limit);
|
||||||
return sumreleased;
|
|
||||||
|
if(runtime·debug.gctrace > 0) {
|
||||||
|
if(sumreleased > 0)
|
||||||
|
runtime·printf("scvg%d: %D MB released\n", k, (uint64)sumreleased>>20);
|
||||||
|
runtime·printf("scvg%d: inuse: %D, idle: %D, sys: %D, released: %D, consumed: %D (MB)\n",
|
||||||
|
k, mstats.heap_inuse>>20, mstats.heap_idle>>20, mstats.heap_sys>>20,
|
||||||
|
mstats.heap_released>>20, (mstats.heap_sys - mstats.heap_released)>>20);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static FuncVal forcegchelperv = {(void(*)(void))forcegchelper};
|
static FuncVal forcegchelperv = {(void(*)(void))forcegchelper};
|
||||||
@ -437,8 +444,7 @@ runtime·MHeap_Scavenger(void)
|
|||||||
{
|
{
|
||||||
MHeap *h;
|
MHeap *h;
|
||||||
uint64 tick, now, forcegc, limit;
|
uint64 tick, now, forcegc, limit;
|
||||||
uint32 k;
|
int32 k;
|
||||||
uintptr sumreleased;
|
|
||||||
Note note, *notep;
|
Note note, *notep;
|
||||||
|
|
||||||
g->issystem = true;
|
g->issystem = true;
|
||||||
@ -476,16 +482,8 @@ runtime·MHeap_Scavenger(void)
|
|||||||
runtime·lock(h);
|
runtime·lock(h);
|
||||||
now = runtime·nanotime();
|
now = runtime·nanotime();
|
||||||
}
|
}
|
||||||
sumreleased = scavenge(now, limit);
|
scavenge(k, now, limit);
|
||||||
runtime·unlock(h);
|
runtime·unlock(h);
|
||||||
|
|
||||||
if(runtime·debug.gctrace > 0) {
|
|
||||||
if(sumreleased > 0)
|
|
||||||
runtime·printf("scvg%d: %p MB released\n", k, sumreleased>>20);
|
|
||||||
runtime·printf("scvg%d: inuse: %D, idle: %D, sys: %D, released: %D, consumed: %D (MB)\n",
|
|
||||||
k, mstats.heap_inuse>>20, mstats.heap_idle>>20, mstats.heap_sys>>20,
|
|
||||||
mstats.heap_released>>20, (mstats.heap_sys - mstats.heap_released)>>20);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -494,7 +492,7 @@ runtime∕debug·freeOSMemory(void)
|
|||||||
{
|
{
|
||||||
runtime·gc(1);
|
runtime·gc(1);
|
||||||
runtime·lock(&runtime·mheap);
|
runtime·lock(&runtime·mheap);
|
||||||
scavenge(~(uintptr)0, 0);
|
scavenge(-1, ~(uintptr)0, 0);
|
||||||
runtime·unlock(&runtime·mheap);
|
runtime·unlock(&runtime·mheap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user