<html><head><style>pre,code,address {
margin: 0px;
}
h1,h2,h3,h4,h5,h6 {
margin-top: 0.2em;
margin-bottom: 0.2em;
}
ol,ul {
margin-top: 0em;
margin-bottom: 0em;
}
blockquote {
margin-top: 0em;
margin-bottom: 0em;
}
</style></head><body><div>Le vendredi 15 septembre 2023 à 12:26 +0300, Антон Шаров via gstreamer-devel a écrit :</div><blockquote type="cite" style="margin:0 0 0 .8ex; border-left:2px #729fcf solid;padding-left:1ex"><div>Hi. Thank you very much for reply.</div><div> </div><div>I’ve added as you suggested, but still no luck, still saw-tooth behaviour:</div><div><div><div> var appSink = new AppSink("appsink_{CaptureConfig.CameraId}");</div><div> appSink.NewSample += AppSinkNewSample;</div><div> appSink.EmitSignals = true;</div><div> appSink.Drop = true;</div><div> appSink.MaxBuffers= 10;</div></div></div><div> </div><div>I’ve tried to isolate appsink, used multifilesink instead, and there was no memory consumption.</div><div>So there is definitely problems in appsink, and most obvious solutions seems not to be working...<br> </div><blockquote type="cite" style="margin:0 0 0 .8ex; border-left:2px #729fcf solid;padding-left:1ex"><div>Пятница, 15 сентября 2023, 2:39 +03:00 от Michael Gruner <michael.gruner@ridgerun.com>:<br> </div><div id=""><div class="js-helper js-readmsg-msg"><div><div id="style_16947347981376795412_BODY">Appsink has an internal queue. If your app does not consume samples fast enough, buffers will start accumulating in the queue.<br><br>You can limit the amount of buffers that the internal queue can hold using the "max-buffers" and "drop" properties. For example: "appsink max-buffers=10 drop=true".<br> <div class="mail-quote-collapse">> On 14 Sep 2023, at 17:32, Антон Шаров via gstreamer-devel <<a href="/compose?To=gstreamer%2ddevel@lists.freedesktop.org">gstreamer-devel@lists.freedesktop.org</a>> wrote:<br>><br>> Hi.<br>><br>> Consider following pipeline:<br>> rtspsrc ! rtph264depay ! h264parse ! tee name=vi vi. ! queue ! splitmuxsink vi. ! queue ! avdec_h264 ! jpegenc ! apsink<br>><br>> Appsink config and NewSample handler is below. My problem is that it consumes lot’s of (unmanaged) memory.<br>> There is no leak, it works ok, after .net GC run memory lower to normal values and then grows again. It looks like<br>> 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.</div></div></div></div></div></blockquote></blockquote><div><br></div><div>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.</div><div><br></div><blockquote type="cite" style="margin:0 0 0 .8ex; border-left:2px #729fcf solid;padding-left:1ex"><blockquote type="cite" style="margin:0 0 0 .8ex; border-left:2px #729fcf solid;padding-left:1ex"><div id=""><div class="js-helper js-readmsg-msg"><div><div id="style_16947347981376795412_BODY"><div class="mail-quote-collapse">><br>> Any ideas how to achieve that?<br>><br>> Thanks in advance.<br>><br>><br>> Appsink code:<br>><br>> var appSink = new AppSink("appsink_{CaptureConfig.CameraId}");<br>> appSink.NewSample += AppSinkNewSample;<br>> appSink.EmitSignals = true;<br>><br>> private void AppSinkNewSample(object o, NewSampleArgs args)<br>> {<br>> if (o is AppSink aps)<br>> {<br>> using (var sample = aps.PullSample())<br>> {<br>> using (var buf = sample.Buffer)<br>> {<br>> SomeStuff(buf);<br>> }<br>> }<br>> }<br>> }<br>><br>><br>></div></div></div></div></div></blockquote><div> <div> </div><div data-signature-widget="container"><div data-signature-widget="content"><div>--<br>С Уважением,<br>Шаров Антон</div></div></div><div> </div></div></blockquote><div><br></div><div><span></span></div></body></html>