LEFT | RIGHT |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 // Page heap. | 5 // Page heap. |
6 // | 6 // |
7 // See malloc.h for overview. | 7 // See malloc.h for overview. |
8 // | 8 // |
9 // When a MSpan is in the heap free list, state == MSpanFree | 9 // When a MSpan is in the heap free list, state == MSpanFree |
10 // and heapmap(s->start) == span, heapmap(s->start+s->npages-1) == span. | 10 // and heapmap(s->start) == span, heapmap(s->start+s->npages-1) == span. |
(...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
612 ········ | 612 ········ |
613 h = &runtime·mheap; | 613 h = &runtime·mheap; |
614 sumreleased = 0; | 614 sumreleased = 0; |
615 for(i=0; i < nelem(h->free); i++) | 615 for(i=0; i < nelem(h->free); i++) |
616 sumreleased += scavengelist(&h->free[i], now, limit); | 616 sumreleased += scavengelist(&h->free[i], now, limit); |
617 sumreleased += scavengelist(&h->freelarge, now, limit); | 617 sumreleased += scavengelist(&h->freelarge, now, limit); |
618 | 618 |
619 if(runtime·debug.gctrace > 0) { | 619 if(runtime·debug.gctrace > 0) { |
620 if(sumreleased > 0) | 620 if(sumreleased > 0) |
621 runtime·printf("scvg%d: %D MB released\n", k, (uint64)su
mreleased>>20); | 621 runtime·printf("scvg%d: %D MB released\n", k, (uint64)su
mreleased>>20); |
| 622 // TODO(dvyukov): these stats are incorrect as we don't subtract
stack usage from heap. |
| 623 // But we can't call ReadMemStats on g0 holding locks. |
622 runtime·printf("scvg%d: inuse: %D, idle: %D, sys: %D, released:
%D, consumed: %D (MB)\n", | 624 runtime·printf("scvg%d: inuse: %D, idle: %D, sys: %D, released:
%D, consumed: %D (MB)\n", |
623 k, mstats.heap_inuse>>20, mstats.heap_idle>>20, mstats.h
eap_sys>>20, | 625 k, mstats.heap_inuse>>20, mstats.heap_idle>>20, mstats.h
eap_sys>>20, |
624 mstats.heap_released>>20, (mstats.heap_sys - mstats.heap
_released)>>20); | 626 mstats.heap_released>>20, (mstats.heap_sys - mstats.heap
_released)>>20); |
625 } | 627 } |
626 } | 628 } |
627 | 629 |
628 static void | 630 static void |
629 scavenge_m(G *gp) | 631 scavenge_m(G *gp) |
630 { | 632 { |
631 runtime·lock(&runtime·mheap.lock); | 633 runtime·lock(&runtime·mheap.lock); |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
933 runtime·MProf_Free(sp->b, size, freed); | 935 runtime·MProf_Free(sp->b, size, freed); |
934 runtime·lock(&runtime·mheap.speciallock); | 936 runtime·lock(&runtime·mheap.speciallock); |
935 runtime·FixAlloc_Free(&runtime·mheap.specialprofilealloc, sp); | 937 runtime·FixAlloc_Free(&runtime·mheap.specialprofilealloc, sp); |
936 runtime·unlock(&runtime·mheap.speciallock); | 938 runtime·unlock(&runtime·mheap.speciallock); |
937 return true; | 939 return true; |
938 default: | 940 default: |
939 runtime·throw("bad special kind"); | 941 runtime·throw("bad special kind"); |
940 return true; | 942 return true; |
941 } | 943 } |
942 } | 944 } |
LEFT | RIGHT |