From: David Svensson Fors Date: Tue, 3 Sep 2019 08:38:13 +0000 (+0200) Subject: miniobject: free qdata array when the last qdata is removed X-Git-Tag: 1.16.2~21 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fupstream%2Fgstreamer.git;a=commitdiff_plain;h=e6bd5b41935f125bf43e030dcb909c3537d33b31 miniobject: free qdata array when the last qdata is removed In cases with many long-lived buffers that have qdata only very briefly, the memory overhead of keeping an array of 16 GstQData structs for each buffer can be significant. We free the array when the last qdata is removed, like it was done in 1.14. Fixes #436 --- diff --git a/gst/gstminiobject.c b/gst/gstminiobject.c index b55ff58..d5c28ba 100644 --- a/gst/gstminiobject.c +++ b/gst/gstminiobject.c @@ -506,7 +506,12 @@ remove_notify (GstMiniObject * object, gint index) /* remove item */ priv_data->n_qdata--; - if (index != priv_data->n_qdata) { + if (priv_data->n_qdata == 0) { + /* we don't shrink but free when everything is gone */ + g_free (priv_data->qdata); + priv_data->qdata = NULL; + priv_data->n_qdata_len = 0; + } else if (index != priv_data->n_qdata) { QDATA (priv_data, index) = QDATA (priv_data, priv_data->n_qdata); } }