Re: [go-nuts] how about golang channel memory usage?

2018-01-15 Thread Lynn H
OK, get it ,
you means virt memory use, I test it, result data could match the table

but how about res memory usage? how  RES memory used in golang? 

在 2018年1月16日星期二 UTC+8下午2:23:08,Jan Mercl写道:
>
> On Tue, Jan 16, 2018 at 4:49 AM Lynn H <yu3...@gmail.com > 
> wrote:
>
> > not understand ur table,
> > when memsize is 256,single channel use 6114Byte memory?
>
> Size of []byte is 3 words, assuming a 64 bit system that's 24 bytes. 
> 256*24 = 6,144 bytes ie. size of a chan []byte with capacity 256, which is 
> what make(chan []byte, 256) produces.
>
> In general, make(chan T, N) means reserve N*sizeof(T) bytes for the 
> channel buffer.
>
>
>
> -- 
>
> -j
>

-- 
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.


Re: [go-nuts] how about golang channel memory usage?

2018-01-15 Thread Lynn H
not understand ur table,
when memsize is 256,single channel use  6114Byte memory?

在 2018年1月16日星期二 UTC+8上午1:46:45,Jan Mercl写道:
>
>
>
>
> On Mon, Jan 15, 2018 at 6:04 PM Lynn H <yu3...@gmail.com > 
> wrote:
>
> > so what the rules of channel size and memory usage? 
>
> Check [0] if the formulas are correct.
>
>   [0]: 
> https://docs.google.com/spreadsheets/d/1BuAnHmBKWfWD9JXXi4_k9ck-rkJyDuQgCQ05s4ytJI8/edit?usp=sharing
>
>
>
> -- 
>
> -j
>

-- 
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.


[go-nuts] how about golang channel memory usage?

2018-01-15 Thread Lynn H
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 < 10; 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 10 
routines)
  memsize = 256,program use 306M, 10 channel use 48M
  memsize = 512, program use 328M,10 channel use 70M
  memsize = 1024,program use 379M, 10 channel use 121M
  memsize = 2048,program use 455M, 10 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.