tinyzimmer / go-gst

Gstreamer bindings and utilities for golang
GNU Lesser General Public License v2.1
130 stars 37 forks source link

memory leak #23

Open brucekim opened 2 years ago

brucekim commented 2 years ago

Hi,

I am checking memory allocation & release with debug/pprof tool.

And I found that heap profiler indicates following heap stack.

0: 0 [2: 48] @ 0x4613e53 0x45e5fe9 0x481deb1 0x4076681
#   0x4613e52   github.com/tinyzimmer/go-gst/gst.NewBufferFromBytes.func1+0x52  /Users/bkim/go/pkg/mod/github.com/tinyzimmer/go-gst@v0.2.31/gst/gst_buffer.go:101
#   0x45e5fe8   github.com/tinyzimmer/go-gst/gst.NewBufferFromBytes+0x48    /Users/bkim/go/pkg/mod/github.com/tinyzimmer/go-gst@v0.2.31/gst/gst_buffer.go:101

This is because Extract() returns C.GoBytes() which underlying array is a copy of the array in C area. And I couldn't find anywhere doing free for it.

Please help me whether or not I have right understanding.

https://github.com/tinyzimmer/go-gst/blob/5437f8a654ee228e8959fb52d6cbc6f5c14123a2/gst/gst_buffer.go#L387-L394

tinyzimmer commented 2 years ago

I would expect the defer C.free(dest) to be taking care of it, but this is an interesting case indeed. Will warrant a closer look.

RSWilli commented 1 year ago

@brucekim move this issue to https://github.com/go-gst/go-gst (where future development of the bindings will take place) if it is still necessary