| // Copyright 2010 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. |
| // Test that selects do not consume undue memory. |
| func sender(c chan int, n int) { |
| func receiver(c, dummy chan int, n int) { |
| runtime.MemProfileRate = 0 |
| receiver(c, dummy, 100000) |
| memstats := new(runtime.MemStats) |
| runtime.ReadMemStats(memstats) |
| // second time shouldn't increase footprint by much |
| receiver(c, dummy, 100000) |
| runtime.ReadMemStats(memstats) |
| // Be careful to avoid wraparound. |
| if memstats.Alloc > alloc && memstats.Alloc-alloc > 1.1e5 { |
| println("BUG: too much memory for 100,000 selects:", memstats.Alloc-alloc) |