Re: [go-nuts] Memory usages

2019-01-30 Thread Bakul Shah
I think computing memory use of any *constant* is not straightforward and probably not worth it. Even a typed constant may only exist in an instruction stream. For instance "var x int64 = 42" may compile down to a single instruction (or more, depending on the underlying architecture). Or there m

Re: [go-nuts] Memory usages

2019-01-30 Thread Michael Jones
On Wed, Jan 30, 2019 at 4:05 PM 伊藤和也 wrote: > : > So in this case below, Is the memory usage "12" bytes in total? (Question > 1) > > var num int32 = 100 >> | | >> 4 bytes + 8 bytes = 12 bytes > > no. the literal "100" has no specific size and is conformed to the ta

[go-nuts] Memory usages

2019-01-30 Thread 伊藤和也
An interger constant is "int" type and takes "8" bytes memory on 64-bit system. fmt.Println(unsafe.Sizeof(100)) // 8 > fmt.Println(reflect.TypeOf(100)) // int and an "int32" type value takes "4" bytes. var num int32 > fmt.Println(unsafe.Sizeof(num)) // 4 So in this case below, Is the memory