|
|
|
|
|
by amscanne
2125 days ago
|
|
I believe your comment is wrong though. Those two things will use exactly the same amount of memory. The data pointer in the slice points to an array-type of size zero. All allocations for objects of size zero return a fixed address in the data section (so there is a distinction between a nil and non-nil object, but a pointer to a zero sized object does not actually take any space). See line 909:
https://golang.org/src/runtime/malloc.go |
|
https://play.golang.org/p/wVyv0qhj9rp