Hi Ian, thanks for the help... quick question about alignment because i may 
be doing something wrong but it shows me that it doesn't matter for the 
slice type, everything is alignment the same way. Can you comment on this?

On 32 bit it'll always return 4 and for 64 bit - 8... even for char or 
boolean slices
https://play.golang.org/p/wLbt41sISft

Another question, i create []byte slice, then i create []int slice, in the 
middle of []byte by changing 

    arr := [10]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
    size := len(arr)
    p := uintptr(unsafe.Pointer(&arr))

    var data []int
    sh := (*reflect.SliceHeader)(unsafe.Pointer(&data))
    sh.Data = p + some_alignment_offset_
    sh.Len = size
    sh.Cap = size

Now data points at memory used by arr, when arr will become unreachable... 
will underlying memory be collected by GC? Should i call some function to 
inform GC to not collect the memory?

Thanks

-- 
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/7430d6a7-909e-41fd-a292-5de2be9f9733%40googlegroups.com.

Reply via email to