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

Sebastian Dröge via gstreamer-devel <[email protected]>
Newsgroups gmane.comp.video.gstreamer.devel
Message-ID <[email protected]>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.