mostynb / go-grpc-compression

go gRPC encoding wrappers for some useful compression algorithms that are not available in google.golang.org/grpc
Apache License 2.0
21 stars 10 forks source link

Add finalizers to prevent memory leaking #1

Closed ains-stripe closed 4 years ago

ains-stripe commented 4 years ago

We've seen some processes leaking memory when using this library. After looking at this issue https://github.com/klauspost/compress/issues/264

It seems like it was fixed in kafka-go by using finalizers to ensure that Close was called in the wrapped objects when the GC cleans them up, otherwise the goroutines in compress will leak. https://github.com/segmentio/kafka-go/blob/master/zstd/zstd.go#L39-L47

ains-stripe commented 4 years ago

That's another way of getting around the bug (disabling the concurrency) if you use any at all though you'll need to cleanup the goroutines.

Thanks for merging though! Would you mind tagging a new release?

mostynb commented 4 years ago

Would you mind tagging a new release?

Done.