Russ Cox | d2cc988 | 2012-02-16 23:50:37 -0500 | [diff] [blame] | 1 | // run |
Russ Cox | 1ce1791 | 2009-01-26 17:37:05 -0800 | [diff] [blame] | 2 | |
| 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 Pike | 83976e3 | 2012-02-19 14:28:53 +1100 | [diff] [blame] | 7 | // Simple test of the garbage collector. |
| 8 | |
Russ Cox | 1ce1791 | 2009-01-26 17:37:05 -0800 | [diff] [blame] | 9 | package main |
| 10 | |
Russ Cox | 33e396a | 2010-02-03 16:31:34 -0800 | [diff] [blame] | 11 | import "runtime" |
Russ Cox | 1ce1791 | 2009-01-26 17:37:05 -0800 | [diff] [blame] | 12 | |
| 13 | func mk2() { |
Russ Cox | 33e396a | 2010-02-03 16:31:34 -0800 | [diff] [blame] | 14 | b := new([10000]byte) |
| 15 | _ = b |
Rob Pike | 4f61fc9 | 2010-09-04 10:36:13 +1000 | [diff] [blame] | 16 | // println(b, "stored at", &b) |
Russ Cox | 1ce1791 | 2009-01-26 17:37:05 -0800 | [diff] [blame] | 17 | } |
| 18 | |
Russ Cox | 33e396a | 2010-02-03 16:31:34 -0800 | [diff] [blame] | 19 | func mk1() { mk2() } |
Russ Cox | 1ce1791 | 2009-01-26 17:37:05 -0800 | [diff] [blame] | 20 | |
| 21 | func main() { |
| 22 | for i := 0; i < 10; i++ { |
Russ Cox | 33e396a | 2010-02-03 16:31:34 -0800 | [diff] [blame] | 23 | mk1() |
| 24 | runtime.GC() |
Russ Cox | 1ce1791 | 2009-01-26 17:37:05 -0800 | [diff] [blame] | 25 | } |
| 26 | } |