mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
runtime: instrument malloc + garbage collector.
add simple garbage collection benchmark. R=iant CC=golang-dev https://golang.org/cl/204053
This commit is contained in:
parent
49c4256913
commit
e4f06812c5
14 changed files with 340 additions and 2 deletions
|
|
@ -46,6 +46,8 @@ mallocgc(uintptr size, uint32 refflag, int32 dogc)
|
|||
if(v == nil)
|
||||
throw("out of memory");
|
||||
mstats.alloc += size;
|
||||
mstats.total_alloc += size;
|
||||
mstats.by_size[sizeclass].nmalloc++;
|
||||
} else {
|
||||
// TODO(rsc): Report tracebacks for very large allocations.
|
||||
|
||||
|
|
@ -57,6 +59,7 @@ mallocgc(uintptr size, uint32 refflag, int32 dogc)
|
|||
if(s == nil)
|
||||
throw("out of memory");
|
||||
mstats.alloc += npages<<PageShift;
|
||||
mstats.total_alloc += npages<<PageShift;
|
||||
v = (void*)(s->start << PageShift);
|
||||
}
|
||||
|
||||
|
|
@ -127,6 +130,7 @@ free(void *v)
|
|||
size = class_to_size[sizeclass];
|
||||
runtime_memclr(v, size);
|
||||
mstats.alloc -= size;
|
||||
mstats.by_size[sizeclass].nfree++;
|
||||
MCache_Free(c, v, sizeclass, size);
|
||||
|
||||
out:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue