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 this become an issue, but it's something to keep in mind.
On Mon, Nov 23, 2020 at 4:32 AM tokers <zchao1...@gmail.com> wrote: > 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 even add a Finalizer that panics if Close haven't been called >> before... >> >> tokers a következőt írta (2020. november 23., hétfő, 4:17:18 UTC+1): >> >>> 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. >>>> >>>> Can I set up a trigger mechanism like "x.__del__" as in Python? >>>> >>>> I can set the garbage collector to follow some objects. >>>> But I have to call some C functions (alDeleteBuffers) to delete buffers >>>> in OpenAL. >>>> >>>> I want garbage collector to run this function while deleting the >>>> object. >>>> >>>> Is this possible? >>>> >>>> -- > 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/97bafe0a-46a6-46ba-8aeb-fa875bf80b58n%40googlegroups.com > <https://groups.google.com/d/msgid/golang-nuts/97bafe0a-46a6-46ba-8aeb-fa875bf80b58n%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- 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/CAA%3DXfu3T29PH%2BPgxjBFFCwVrYkSbUv5tKFk5GR%2Bbk1YZmvK5tw%40mail.gmail.com.