My application with appsrc eats whole memory (is it a memory leak) ?

Denis Shienkov denis.shienkov at gmail.com
Mon Dec 18 15:32:51 UTC 2017


Hi, Edward

 > Are you releasing the buffers (and content)
 > you are passing to appsrc?

As I see from the doc, it say that the gst_app_src_push_buffer()
function takes ownership of buffer... so, I'm don't care about
the buffer releasing.

 > see the documentation for gst_buffer_new_wrapped_full()

I use some different way:

void StreamProducerControl::presentImage(const QImage &image)
{
     ...

     m_image = image;

     const auto buffer = gst_buffer_new_and_alloc(m_image.byteCount());
     const auto bytesCopied = ::gst_buffer_fill(
                 buffer, 0, m_image.constBits(), m_image.byteCount());

     GST_BUFFER_PTS(buffer) = m_timestamp.nsecsElapsed();

     const auto result = ::gst_app_src_push_buffer(
                 GST_APP_SRC(m_appsrc), buffer);

     ...
}


18.12.2017 17:06, Edward Hervey пишет:
> Hi,
>
>    Are you releasing the buffers (and content) you are passing to appsrc
> ? That's most likely the culprit.
>
>    Make sure the buffers you provide to appsrc have a destroynotify (see
> the documentation for gst_buffer_new_wrapped_full()).
>
>     Edward
>
> On Mon, 2017-12-18 at 11:23 +0300, Denis Shienkov wrote:
>> Hi all,
>>
>> I faced with a problem, that my application eats whole
>> memory when I start it with this pipeline (without using
>> of a videoenc element in pipeline):
>>
>> void Grabber::initializeGst()
>> {
>>       ::gst_init(nullptr, nullptr);
>>
>>       m_appsrc = ::gst_element_factory_make(
>>                   "appsrc", "source");
>>
>>       ::g_object_set(G_OBJECT(m_appsrc),
>>                      "stream-type", GST_APP_STREAM_TYPE_STREAM,
>>                      "is-live", true,
>>                      "format", GST_FORMAT_TIME,
>>                      nullptr);
>>
>>       const auto caps = ::gst_caps_new_simple(
>>                   "video/x-raw",
>>                   "format", G_TYPE_STRING, "BGRA",
>>                   "width", G_TYPE_INT, 800,
>>                   "height", G_TYPE_INT, 600,
>>                   "framerate", GST_TYPE_FRACTION, 0, 1,
>>                   nullptr);
>>
>>       ::g_object_set(G_OBJECT(m_appsrc),
>>                      "caps", caps,
>>                      nullptr);
>>
>>        const auto conv = ::gst_element_factory_make(
>>                   "videoconvert", "conv");
>>
>>       const auto videoenc = ::gst_element_factory_make(
>>                   "x264enc", "video_encoder");
>>
>>       const auto payloader = ::gst_element_factory_make(
>>                   "rtph264pay", "payloader");
>>
>>       ::g_object_set(G_OBJECT(payloader),
>>                      "config-interval", 3,
>>                      nullptr);
>>
>>       m_pipeline = ::gst_pipeline_new("pipeline");
>>
>>       const auto udpsink = ::gst_element_factory_make(
>>                   "udpsink", "udpsink");
>>
>>       ::g_object_set(G_OBJECT(udpsink),
>>                      "host", "127.0.0.1",
>>                      "port", 50666,
>>                      nullptr);
>>
>>       ::gst_bin_add_many(GST_BIN(m_pipeline),
>>                          m_appsrc,
>> //                       conv,
>>                          videoenc,
>>                          payloader,
>>                          udpsink,
>>                          nullptr);
>>
>>       const auto result = ::gst_element_link_many(m_appsrc,
>> //                                                conv,
>>                                                   videoenc,
>>                                                   payloader,
>>                                                   udpsink,
>>                                                   nullptr);
>>
>>       if (!result) {
>>           qDebug() << "Unable to initialize the GST";
>>       } else {
>>           // Play.
>>           const auto status = ::gst_element_set_state(m_pipeline,
>> GST_STATE_PLAYING);
>>           qDebug() << "Status:" << status;
>>       }
>> }
>>
>> I use the gst_app_src_push_buffer() function directly when
>> I get a ready buffer from the some external entity.
>>
>> I have tried it on Windows and on Linux, and the behavior is same:
>> the CPU load ~10%, but the RAM consumption increases very quickly,
>> and after ~10 seconds it eatch all memory.
>>
>> But, when I insert the 'videoconvert' element, then the RAM
>> consumption
>> stabilized on ~300 MBytes, and the CPU consumption increases up to
>> ~80%.
>>
>> In ideally, I do not need to use an 'videoconvert' elament, because
>> I want to send it in an original format as BGRA.
>>
>> What I doing wrong?
>>
>> BR,
>> Denis
>>
>>
>> _______________________________________________
>> gstreamer-devel mailing list
>> gstreamer-devel at lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel



More information about the gstreamer-devel mailing list