apfs
apfs copied to clipboard
Memory leaks when calling C.CString
I found a memory leak in https://github.com/buildbuddy-io/buildbuddy/pull/2686/files in the way we were calling C.clonefile
, and was curious if anybody else on GitHub was using the same problematic code pattern.
While searching across code on GitHub I found that this package has a few instances where C.CString
is called, but C.free
is not called on the result, which causes a memory leak for long-running applications:
- https://cs.github.com/go-darwin/apfs/blob/f84b94dbf34818a1ecdc0836be075cf386a53198/clone.go#L54
- https://cs.github.com/go-darwin/apfs/blob/f84b94dbf34818a1ecdc0836be075cf386a53198/clone.go#L82
- https://cs.github.com/go-darwin/apfs/blob/f84b94dbf34818a1ecdc0836be075cf386a53198/clone.go#L101
Not sure if this package is still maintained but figured I'd report it.