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

Антон Шаров sharov_am at mail.ru
Mon Sep 18 17:14:23 UTC 2023


Hi, Sebastian ! Thank you for reply!
 
There is really smth strange happens here — if I use Large Object Heap to store my frames from rtsp (put it simply, 
I back each video file in memory frame by frame, each frame is byte[200k] which is stored in LOH) then  gst allocates lots of memory (Gst.Memory). It reserves alot from virtual memory. There is no magic in my code, just get byte[] from gst.buffer, and store it in list of frames(list of bytes, basically). If I don’t store byte[] in list, then everything seems to be ok, no huge memory consumption, GC works regulary and memory consumption is no greater then 450Mb (which is ok for now). I mean I get
byte[] from buffer and do nothing with that, don’t store in list. If I storem then gst going crazy for some reason.
 
Also, I’ve notice that Gst.Memory objects resides in gen1  only. For some reason they stay longer than should.
 
So, it seems that there is very strange interference or interaction between gst (appsink ?) and my attempt to store byte arrays in memory. From some moment in time, gst seems to trying to reserve as much as possible memory.
 
Also my settigns like Drop=true, max_buffers =100 seems to have no effect.
  
>Пятница, 15 сентября 2023, 17:30 +03:00 от Sebastian Dröge <sebastian at centricular.com>:
> 
>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/20230918/bfbbdb4b/attachment.htm>


More information about the gstreamer-devel mailing list