blob: 6688f9fbddb9148c60ff0719e45cfc367cff35dc [file] [log] [blame]
Russ Coxd2cc9882012-02-16 23:50:37 -05001// run
Russ Cox1ce17912009-01-26 17:37:05 -08002
3// Copyright 2009 The Go Authors. All rights reserved.
4// Use of this source code is governed by a BSD-style
5// license that can be found in the LICENSE file.
6
Rob Pike83976e32012-02-19 14:28:53 +11007// Simple test of the garbage collector.
8
Russ Cox1ce17912009-01-26 17:37:05 -08009package main
10
Russ Cox33e396a2010-02-03 16:31:34 -080011import "runtime"
Russ Cox1ce17912009-01-26 17:37:05 -080012
13func mk2() {
Russ Cox33e396a2010-02-03 16:31:34 -080014 b := new([10000]byte)
15 _ = b
Rob Pike4f61fc92010-09-04 10:36:13 +100016 // println(b, "stored at", &b)
Russ Cox1ce17912009-01-26 17:37:05 -080017}
18
Russ Cox33e396a2010-02-03 16:31:34 -080019func mk1() { mk2() }
Russ Cox1ce17912009-01-26 17:37:05 -080020
21func main() {
22 for i := 0; i < 10; i++ {
Russ Cox33e396a2010-02-03 16:31:34 -080023 mk1()
24 runtime.GC()
Russ Cox1ce17912009-01-26 17:37:05 -080025 }
26}