go - If the capacity of a slice has been modified by the unsafe.Pointer, can the rest memory reused by the garbage collection? -
think case:
s := make([]byte, 512, 1024) (*reflect.sliceheader)((unsafe.pointer(&s))).cap = 512
are last 512 bytes memory can collected gc?
whether or not, why?
as far know, current garbage collector not collect partial slices or strings. same true for:
s=s[:512:512] // example idiomatically starting in go1.3 s=s[128:] // first 128 elements not collected.
Comments
Post a Comment