apple / apple/foundationdb

Golang: provide explicit methods to "close" objects with native resources

Open
#1,340 8 comments 0 reactions 2 assignees Claimed by @vishesh View on GitHub
Dominant language
C++
Stars
16.7k
Forks
1.6k
Avg merge
1d 20h
Merged PRs (30d)
126

Description

In the Go bindings, we currently use finalizers to free native memory. From what I've gathered, this has similar issues to what we found in Java, which among other things was that we could end up using lots of native memory without exerting enough GC pressure in the JVM to cause the finalizers to run.

Based on discussion [on the forums](https://forums.foundationdb.org/t/use-of-finalizers-in-golang-bindings/1228), I think we should switch to a model similar to the current Java bindings, which require objects that wrap native resources to be explicitly closed. Like in Java, we could optionally deprecate the finalizer behavior but keep it around for now if we are worried that removing it could cause problems. We could also put warnings in the finalizers for unreleased memory in addition to or instead of deprecating the finalizer behavior (Java also has these warnings, with them enabled by default).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.