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

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -