memory addresses as keys in a hash map while marshaling a cyclic data structure? without disabling GC, it might move data around in memory, changing the addresses.
I think we have non-moving GC, GO runtime moves (copying) stacks of goroutines, and yes, you can off GC by env var GOGC=off or by func SetGCPercent (https://pkg.go.dev/runtime/debug#SetGCPercent)
apparently Go's GC as it exists today does not move values on the heap around, but this behavior is not guaranteed and could change in the future.
No. Why would you want to do that?
so I can detect cycles in cyclic data structures for marshaling
Don't use raw pointer. Don't use unsafe pointer. You'll only make your life difficult for no reason. Just use pointers
If by memory addresses you mean normal Go pointer then you're fine and you don't habe to care about GC
Обсуждают сегодня