Re: [go-nuts] Re: Garbage Collector triggering when deleting an object

2020-11-24 Thread Tyler Compton
If you're using finalizers to clean up C memory, it's important to know that the Go garbage collector has no understanding of how much C memory a given resource holds. This prevents the garbage collector from making smart decisions about when to release your resources. I've never personally seen th

[go-nuts] Re: Garbage Collector triggering when deleting an object

2020-11-24 Thread jake...@gmail.com
On Monday, November 23, 2020 at 6:31:50 AM UTC-5 tokers wrote: > Are there any documents? > https://golang.org/pkg/runtime/#SetFinalizer -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails

Re: [go-nuts] Re: Garbage Collector triggering when deleting an object

2020-11-23 Thread Robert Engels
Finalizers are essential in a highly concurrent system - otherwise you are doing manual resource management with automatic memory management (a resource) and its ugly and error prone. Even though they are no guaranteed to be called they work very well to manage shared resources. > On Nov 23,

[go-nuts] Re: Garbage Collector triggering when deleting an object

2020-11-23 Thread tokers
Are there any documents? On Monday, November 23, 2020 at 7:28:31 PM UTC+8 Tamás Gulácsi wrote: > There is a runtime.SetFinalizer, but it is not guaranteed to be run, > anytime. > The most idiomatic and safe solution is to have a Close() method on the Go > side, which frees the C side. > You may

[go-nuts] Re: Garbage Collector triggering when deleting an object

2020-11-23 Thread Tamás Gulácsi
There is a runtime.SetFinalizer, but it is not guaranteed to be run, anytime. The most idiomatic and safe solution is to have a Close() method on the Go side, which frees the C side. You may even add a Finalizer that panics if Close haven't been called before... tokers a következőt írta (2020.

[go-nuts] Re: Garbage Collector triggering when deleting an object

2020-11-22 Thread tokers
There is a runtime.SetFinalizer function. On Sunday, November 22, 2020 at 8:13:22 PM UTC+8 Sean wrote: > I am writing a Golang wrapper for OpenAL-Soft. > I need to create some buffers. These operations are happening on the > OpenAL-Soft side (So C functions). I am loading PCM data into buffers.