4 ms·
I'm wondering how they deal with Go's garbage collector, which is allowed to move objects in memory.
by amelius 11y ago
I'm wondering how they deal with Go's garbage collector, which is allowed to move objects in memory.
- danieldk 11y agoThe Go garbage collector only concerns itself with memory allocated in Go, not with memory allocated in C-land. So, it doesn't move C objects. (C objects are typically freed using finalizers, or an explicit method call.) Of course, moving can cause problems for Go pointers in C land, but keeping Go pointers beyond a cgo function call will be prohibited in Go 1.6: https://tip.golang.org/doc/go1.6#cgo https://tip.golang.org/doc/go1.6#cgo
- amelius 11y agoYes, the callback functions (registered in Qt, calling back into Go) will probably be a problem then. I guess they will need to handle the situation through a kind of lookup-table approach, which of course will come at a cost.