I was curious if reducing the capacity of slice makes that memory available to 
be reclaimed?

(1) Reducing capacity using a three-index:

var s = make([]int64, 1e9)
... add data to s, keeping a count .. 
s = s[:n:n] // reduce length and capacity to number of items read

(2) Reducing capacity by slicing off the front, as happens when using slice as 
a queue

var s []int64
s = append(s, 1, 2, 3, 4, 5) 
s = s[5:] 

Should I be careful to allocate a new slice and copy over, if I want to avoid 
that memory being pinned until the original slice goes out of scope?

Thank you,
Rob

-- 
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 golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/555450b4-903b-4c65-80f5-64010d5fe0a1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to