AppSink consumes lot's of memory. How to control memory consumption?

Sebastian Dröge sebastian at centricular.com
Fri Sep 15 14:29:05 UTC 2023


On Fri, 2023-09-15 at 10:23 -0400, Nicolas Dufresne via gstreamer-devel
wrote:
> > > 
> > > > Appsink config and NewSample handler is below. My problem is
> > > that it consumes lot’s of (unmanaged) memory.
> > > > There is no leak, it works ok, after .net GC run memory lower
> > > to normal values and then grows again. It looks like
> > > > saw-tooth. I’ve tried to limit max-buffers (set it to 100 or
> > > 1), drop = true but it seems that nothing works. Memory profiler
> > > shows smth like 30K instances of Gst.Memory holds 1.5Gb of
> > > unmanaged (in terms of .net) memory. Aftre GC collect, it seems
> > > to collect some of these instances and release some unmanaged
> > > memory (say it lowers 10 times). Again, there is no leeks, I just
> > > want to lower memory consumption of appsink element.
> 
> I believe recent C# GC allow you to do explicit unref (nullifying the
> object) to workaround the issue. The GC have no idea about the size
> of the object/buffer, so it does not prioritize it.

Also the bindings allow you to call dispose() on the object to
"invalidate" it (any further calls on it will cause an exception then).
That also unrefs the native object immediately.

The problem you're running into here is the main problem with any
bindings for a language with a tracing GC, unfortunately. Or at least
the cases where you can't provide more information (and object
traversal information) to the GC.

-- 
Sebastian Dröge, Centricular Ltd · https://www.centricular.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20230915/f7b6c46f/attachment.htm>


More information about the gstreamer-devel mailing list