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

Denis Shienkov denis.shienkov at gmail.com
Mon Dec 18 08:23:22 UTC 2017


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




More information about the gstreamer-devel mailing list