memory leak on custom meta data insert

tom tomschuring at gmail.com
Mon Mar 7 03:11:21 UTC 2022


Hello,

I'm trying to write a simple plugin that only inserts data as meta data to
the stream.
My plugin is derived from GstBaseTransform

typedef struct GstMtdataMetaInject
{
GstBaseTransform base_mtdataplugins;

and i've created a simple meta data like: (see attached files)

struct _MtdataMeta
{
GstMeta meta;
gchar *jsonstring;
};


and to insert the meta data (on every frame for now)


static GstFlowReturn
gst_mtdata_meta_inject_prepare_output_buffer(GstBaseTransform *trans,
GstBuffer *input, GstBuffer **outbuf)
{
GstMtdataMetaInject *self = GST_MTDMETAINJECT(trans);
GstFlowReturn ret;
ret = GST_BASE_TRANSFORM_CLASS(gst_mtdata_meta_inject_parent_class)->
prepare_output_buffer(trans, input, outbuf);
if (ret != GST_FLOW_OK)
return ret;
*outbuf = gst_buffer_make_writable(input);
if (*outbuf != NULL)
{
// string hello = StringUtils::current_date_time_string();
// string hello = "12345678901234";
string hello = StringUtils::random_string(14);

MtdataMeta *in = gst_buffer_add_mtdata_meta(*outbuf, (gchar *)hello.c_str
());

GST_WARNING("Added metdata: %s", in->jsonstring);
}
return ret;
}
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.
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.

Do I need to go to the last element in the stream and 'free' the meta data
so it doesn't add up ?
Kind regards,
Tom
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20220307/2015bd5c/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mtdata_meta.h
Type: application/octet-stream
Size: 692 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20220307/2015bd5c/attachment-0004.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mtdata_meta.cpp
Type: application/octet-stream
Size: 2063 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20220307/2015bd5c/attachment-0005.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gstmtdmetainject.h
Type: application/octet-stream
Size: 4618 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20220307/2015bd5c/attachment-0006.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gstmtdmetainject.cpp
Type: application/octet-stream
Size: 16836 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20220307/2015bd5c/attachment-0007.obj>


More information about the gstreamer-devel mailing list