1
0
mirror of https://github.com/golang/go synced 2024-11-27 03:21:18 -07:00
go/usr/rsc/mem/testrepeat.go
Russ Cox 75647d2024 First pieces of malloc.
R=r
DELTA=756  (754 added, 0 deleted, 2 changed)
OCL=19266
CL=19378
2008-11-17 12:32:35 -08:00

38 lines
665 B
Go

// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import (
"allocator"
)
var footprint int64
func bigger() {
if footprint < allocator.footprint {
footprint = allocator.footprint;
println("Footprint", footprint);
}
}
func main() {
for i := 0; i < 1<<16; i++ {
for j := 1; j <= 1<<22; j<<=1 {
if i == 0 {
println("First alloc:", j);
}
b := allocator.malloc(j);
allocator.free(b);
bigger();
}
if i%(1<<10) == 0 {
println(i);
}
if i == 0 {
println("Primed", i);
allocator.frozen = true;
}
}
}