diff options
author | David Svensson Fors <davidsf@axis.com> | 2019-09-03 10:38:13 +0200 |
---|---|---|
committer | Tim-Philipp Müller <tim@centricular.com> | 2019-09-08 19:42:59 +0000 |
commit | e6bd5b41935f125bf43e030dcb909c3537d33b31 (patch) | |
tree | c7ee76da798697e394cc53489c21c6c842ec95b4 | |
parent | 94ba1cea88788fd3ad72fadcc2ceb7884ed6df50 (diff) |
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
-rw-r--r-- | gst/gstminiobject.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/gst/gstminiobject.c b/gst/gstminiobject.c index b55ff5822..d5c28baa1 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); } } |