<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Hey Tom<div class=""><br class=""></div><div class="">Is this line ok?</div><div class=""><br class=""></div><div class=""> *outbuf = gst_buffer_make_writable(input);</div><div class=""><br class=""></div><div class="">Shouldn’t it be:</div><div class=""><br class=""></div><div class=""> *outbuf = gst_buffer_make_writable(*outbuf);</div><div class=""><br class=""></div><div class="">The way it is right now you are leaking the outbuf creating when calling:</div><div class=""><br class=""></div><div class=""> ret = GST_BASE_TRANSFORM_CLASS(gst_mtdata_meta_inject_parent_class)->prepare_output_buffer(trans, input, outbuf);<br class=""><div><br class=""></div><div>Michael </div><div><br class=""><blockquote type="cite" class=""><div class="">On 6 Mar 2022, at 21:11, tom via gstreamer-devel <<a href="mailto:gstreamer-devel@lists.freedesktop.org" class="">gstreamer-devel@lists.freedesktop.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="">Hello,</div><div class=""><br class=""></div><div class="">I'm trying to write a simple plugin that only inserts data as meta data to the stream.</div><div class="">My plugin is derived from GstBaseTransform</div><div class=""><br class=""></div><div class=""><div style="color:rgb(212,212,212);background-color:rgb(30,30,30);font-family:Menlo,Monaco,"Courier New",monospace;font-size:12px;line-height:18px;white-space:pre" class=""><div class=""><span style="color:rgb(86,156,214)" class="">typedef</span> <span style="color:rgb(86,156,214)" class="">struct</span> <span style="color:rgb(78,201,176)" class="">GstMtdataMetaInject</span></div><div class="">{</div><div class=""> GstBaseTransform base_mtdataplugins;</div></div></div><div class=""><br class=""></div><div class="">and i've created a simple meta data like: (see attached files)</div><div class=""><br class=""></div><div class=""><div style="color:rgb(212,212,212);background-color:rgb(30,30,30);font-family:Menlo,Monaco,"Courier New",monospace;font-size:12px;line-height:18px;white-space:pre" class=""><div class=""><span style="color:rgb(86,156,214)" class="">struct</span> <span style="color:rgb(78,201,176)" class="">_MtdataMeta</span></div><div class="">{</div><div class=""> GstMeta meta;</div><div class=""> gchar <span style="color:rgb(180,180,180)" class="">*</span>jsonstring;</div><div class="">};</div><br class=""></div></div><div class=""><br class=""></div><div class="">and to insert the meta data (on every frame for now)</div><div class=""><br class=""></div><div class=""><div class=""><div id="gmail-:13s" class="gmail-Ar gmail-Au gmail-Ao"><div id="gmail-:13o" class="editable gmail-Am gmail-tS-tW gmail-Al gmail-LW-avf gmail-tS-tY" aria-label="Message Body" role="textbox" aria-multiline="true" tabindex="1" style="direction:ltr;min-height:700px"><div dir="ltr" class="gmail_signature"><div dir="ltr" class=""><div style="color:rgb(212,212,212);background-color:rgb(30,30,30);font-family:Menlo,Monaco,"Courier New",monospace;font-size:12px;line-height:18px;white-space:pre" class=""><div class=""><span style="color:rgb(86,156,214)" class=""><br class=""></span></div><div class=""><span style="color:rgb(86,156,214)" class="">static</span> <span style="color:rgb(78,201,176)" class="">GstFlowReturn</span></div><div class=""><span style="color:rgb(200,200,200)" class="">gst_mtdata_meta_inject_prepare_output_buffer</span>(<span style="color:rgb(78,201,176)" class="">GstBaseTransform</span> <span style="color:rgb(180,180,180)" class="">*</span><span style="color:rgb(127,127,127)" class="">trans</span>, <span style="color:rgb(78,201,176)" class="">GstBuffer</span> <span style="color:rgb(180,180,180)" class="">*</span><span style="color:rgb(127,127,127)" class="">input</span>, <span style="color:rgb(78,201,176)" class="">GstBuffer</span> <span style="color:rgb(180,180,180)" class="">**</span><span style="color:rgb(127,127,127)" class="">outbuf</span>)</div><div class="">{</div><div class=""> <span style="color:rgb(78,201,176)" class="">GstMtdataMetaInject</span> <span style="color:rgb(180,180,180)" class="">*</span><span style="color:rgb(200,200,200)" class="">self</span> <span style="color:rgb(180,180,180)" class="">=</span> <span style="color:rgb(189,99,197)" class="">GST_MTDMETAINJECT</span>(<span style="color:rgb(127,127,127)" class="">trans</span>);</div><div class=""> <span style="color:rgb(78,201,176)" class="">GstFlowReturn</span> <span style="color:rgb(200,200,200)" class="">ret</span>;<br class=""></div><div class=""> <span style="color:rgb(200,200,200)" class="">ret</span> <span style="color:rgb(180,180,180)" class="">=</span> <span style="color:rgb(189,99,197)" class="">GST_BASE_TRANSFORM_CLASS</span>(<span style="color:rgb(200,200,200)" class="">gst_mtdata_meta_inject_parent_class</span>)-><span style="color:rgb(218,218,218)" class="">prepare_output_buffer</span>(<span style="color:rgb(127,127,127)" class="">trans</span>, <span style="color:rgb(127,127,127)" class="">input</span>, <span style="color:rgb(127,127,127)" class="">outbuf</span>);</div><div class=""> <span style="color:rgb(86,156,214)" class="">if</span> (<span style="color:rgb(200,200,200)" class="">ret</span> <span style="color:rgb(180,180,180)" class="">!=</span> <span style="color:rgb(184,215,163)" class="">GST_FLOW_OK</span>)</div><div class=""> <span style="color:rgb(86,156,214)" class="">return</span> <span style="color:rgb(200,200,200)" class="">ret</span>;</div><div class=""> <span style="color:rgb(180,180,180)" class="">*</span><span style="color:rgb(127,127,127)" class="">outbuf</span> <span style="color:rgb(180,180,180)" class="">=</span> <span style="color:rgb(189,99,197)" class="">gst_buffer_make_writable</span>(<span style="color:rgb(127,127,127)" class="">input</span>);<br class=""></div><div class=""> <span style="color:rgb(86,156,214)" class="">if</span> (<span style="color:rgb(180,180,180)" class="">*</span><span style="color:rgb(127,127,127)" class="">outbuf</span> <span style="color:rgb(180,180,180)" class="">!=</span> <span style="color:rgb(189,99,197)" class="">NULL</span>)<br class=""></div><div class=""> {</div><div class=""><span style="color:rgb(87,166,74)" class=""> // string hello = StringUtils::current_date_time_string();</span></div><div class=""><span style="color:rgb(87,166,74)" class=""> // string hello = "12345678901234";</span></div><div class=""> <span style="color:rgb(78,201,176)" class="">string</span> <span style="color:rgb(200,200,200)" class="">hello</span> <span style="color:rgb(180,180,180)" class="">=</span> <span style="color:rgb(78,201,176)" class="">StringUtils</span>::<span style="color:rgb(200,200,200)" class="">random_string</span>(<span style="color:rgb(181,206,168)" class="">14</span>);</div><br class=""><div class=""> <span style="color:rgb(78,201,176)" class="">MtdataMeta</span> <span style="color:rgb(180,180,180)" class="">*</span><span style="color:rgb(200,200,200)" class="">in</span> <span style="color:rgb(180,180,180)" class="">=</span> <span style="color:rgb(200,200,200)" class="">gst_buffer_add_mtdata_meta</span>(<span style="color:rgb(180,180,180)" class="">*</span><span style="color:rgb(127,127,127)" class="">outbuf</span>, (<span style="color:rgb(78,201,176)" class="">gchar</span> <span style="color:rgb(180,180,180)" class="">*</span>)<span style="color:rgb(200,200,200)" class="">hello</span>.<span style="color:rgb(200,200,200)" class="">c_str</span>());</div><br class=""><div class=""> <span style="color:rgb(189,99,197)" class="">GST_WARNING</span>(<span style="color:rgb(214,157,133)" class="">"Added metdata: %s"</span>, <span style="color:rgb(200,200,200)" class="">in</span>-><span style="color:rgb(218,218,218)" class="">jsonstring</span>);</div><div class=""> }</div><div class=""> <span style="color:rgb(86,156,214)" class="">return</span> <span style="color:rgb(200,200,200)" class="">ret</span>;</div><div class="">}</div></div></div></div></div></div></div></div><div class="">however i'm getting a quite fast memory leak that i can see in gst-launch-1.0 where it goes from 30% memory up to 60% in a matter of a minute.<br class="">the funny think is that if i change the meta data string to be something constant like "12345678901234" with the same length, there is no memory leak and it stays on 28% forever.</div><div class=""><br class="">Do I need to go to the last element in the stream and 'free' the meta data so it doesn't add up ?</div><div class="">Kind regards,</div><div class="">Tom</div><div class=""><br class=""></div></div>
<span id="cid:f_l0g4ce1u0"><mtdata_meta.h></span><span id="cid:f_l0g4ce291"><mtdata_meta.cpp></span><span id="cid:f_l0g4hp2m2"><gstmtdmetainject.h></span><span id="cid:f_l0g4hp2v3"><gstmtdmetainject.cpp></span></div></blockquote></div><br class=""></div></body></html>