On Thu, Jan 31, 2019 at 4:48 PM 伊藤和也 <[email protected]> wrote:
>
> When initializing variables, If the copies of values are made,  their memory 
> usages will be:
>
>> var a = [3]int8{2, 4, 6}
>>        |              |
>>
>>  3 bytes + 3 bytes = 6 bytes
>
>
>> var b = []int8[2, 4, 6}
>>        |               |
>> 24 bytes + 24 bytes = 48 bytes
>
>
>> var c = func() {}
>>       |             |
>>  8 bytes + 8 bytes = 16 bytes
>
>
>> var d = struct{n1 int, n2 int}{1, 2}
>>        |                     |
>> 16 bytes   +   16 bytes = 32 bytes

If you want to understand the memory requirements of Go code at this
level, you need to read the generated assembly code.  You can't reason
about this kind of memory usage from first principles from the spec.
The spec does not impose any requirements on values in transit between
variables.

Ian

-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to