On Tue, Jan 21, 2025 at 6:10 PM John <johnsiil...@gmail.com> wrote: > > Curious if the new runtime.Cleanup() would allow auto sync.Pool.Put() for a > variable. I'm not sure from the documentation if this would work or would > cause some type of issue (the variable was on its way to collection and then > gets put in a pool. I assume it would stop collection?). The guarantees for > running it seem to be better than Finalizer for this kind of thing (its > working for file closures, so I'm guessing this will eventually happen), but > still not sure how much better.
It should be fine to use runtime.AddCleanup to add something to a sync.Pool. That said, remember that runtime.AddCleanup is not called with the pointer that is being freed. It is called on a different pointer, that is presumably associated in some way. Ian -- 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 visit https://groups.google.com/d/msgid/golang-nuts/CAOyqgcWLc3sCmQ8z8Rk6oa8upWNLV7N2Wj18_m186KNNgux6gQ%40mail.gmail.com.