| // $G $D/$F.go && $L $F.$A && ./$A.out |
| // 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. |
| var chatty = flag.Bool("v", false, "chatty"); |
| if st := malloc.GetStats(); oldsys < st.Sys { |
| println(st.Sys, " system bytes for ", st.Alloc, " Go bytes"); |
| malloc.GetStats().Alloc = 0; // ignore stacks |
| for i := 0; i < 1<<7; i++ { |
| for j := 1; j <= 1<<22; j<<=1 { |
| println("First alloc:", j); |
| if a := malloc.GetStats().Alloc; a != 0 { |
| panicln("no allocations but stats report", a, "bytes allocated"); |
| b := malloc.Alloc(uintptr(j)); |
| during := malloc.GetStats().Alloc; |
| if a := malloc.GetStats().Alloc; a != 0 { |
| panic("allocated ", j, ": wrong stats: during=", during, " after=", a, " (want 0)"); |
| if i%(1<<10) == 0 && *chatty { |