I user golang to write tcp  server recently, I'm puzzled by  memoy usage 
with channel

so I write some code for test
   
import (
    "time"
)

func main() {
    memsize := 256
    for i := 0; i < 100000; i++ {
        go func() {
            m := make(chan []byte, memsize)
            time.Sleep(30 * time.Second)
            <-m
        }()
    }
    time.Sleep(30 * time.Second)
}
 I user  RES value of 'top' command to get program memory use 
  memsize = 0,  program use 258M (memory just use to  allocate for 100000 
routines)
  memsize = 256,program use 306M, 100000 channel use 48M
  memsize = 512, program use 328M,100000 channel use 70M
  memsize = 1024,program use 379M, 100000 channel use 121M
  memsize = 2048,program use 455M, 100000 channel use 197M

so what the rules of channel size and  memory usage?

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to