memory leak in rtpbin

李鹏飞 pflinuaa at gmail.com
Wed Aug 31 13:05:59 UTC 2016


I use rtpbin to send rtp data in my project. But I met some problem in
using rtpbin.

When the program exits, I find there is memory leak.

Finally, I find that, when I call gst_element_get_request_pad (rtpbin,
"send_rtp_sink_0"), the rtpbin created two sockets, but when the rtpbin is
released, the two sockets fd are not returned to the OS.

My code is as below. Is there anybody giving me some help?


Thanks very much. I will appreciate your any suggestions.



TEST(PlayAnnounce, RtpBinEncodeTest)
{
GstElement *rtpbin;
GstPad *rtp_sink, *rtp_src, *rtcp_src;
GObject *session;
gint count = 1;

wait_msg("####start#####...");

rtpbin = gst_element_factory_make ("rtpbin", "rtpbin");
wait_msg("create rtpbin done....");

while (count--) {
/* request session 0 */
rtp_sink = gst_element_get_request_pad (rtpbin, "send_rtp_sink_0");
fail_unless (rtp_sink != NULL);
ASSERT_OBJECT_REFCOUNT (rtp_sink, "rtp_sink", 2);
wait_msg("get send_rtp_sink_0 done....");

/* this static pad should be created automatically now */
rtp_src = gst_element_get_static_pad (rtpbin, "send_rtp_src_0");
fail_unless (rtp_src != NULL);
ASSERT_OBJECT_REFCOUNT (rtp_src, "rtp_src", 2);
wait_msg("get send_rtp_src_0 done....");

/* we should be able to get an internal session 0 now */
g_signal_emit_by_name (rtpbin, "get-internal-session", 0, &session);
fail_unless (session != NULL);

wait_msg("get get-internal-session done....");

g_object_unref (session);


/* get the send RTCP pad too */
rtcp_src = gst_element_get_request_pad (rtpbin, "send_rtcp_src_0");
fail_unless (rtcp_src != NULL);
ASSERT_OBJECT_REFCOUNT (rtcp_src, "rtcp_src", 2);
wait_msg("get send_rtcp_src_0 done....");

gst_element_release_request_pad (rtpbin, rtp_sink);

wait_msg("release rtp_sink done....");

/* we should only have our refs to the pads now */
ASSERT_OBJECT_REFCOUNT (rtp_sink, "rtp_sink", 1);
ASSERT_OBJECT_REFCOUNT (rtp_src, "rtp_src", 1);
ASSERT_OBJECT_REFCOUNT (rtcp_src, "rtp_src", 2);

/* the other pad should be gone now */
fail_unless (gst_element_get_static_pad (rtpbin, "send_rtp_src_0") == NULL);

/* internal session should still be there */
g_signal_emit_by_name (rtpbin, "get-internal-session", 0, &session);
fail_unless (session != NULL);
g_object_unref (session);

/* release the RTCP pad */
gst_element_release_request_pad (rtpbin, rtcp_src);
wait_msg("release rtcp_src done....");

/* we should only have our refs to the pads now */
ASSERT_OBJECT_REFCOUNT (rtp_sink, "rtp_sink", 1);
ASSERT_OBJECT_REFCOUNT (rtp_src, "rtp_src", 1);
ASSERT_OBJECT_REFCOUNT (rtcp_src, "rtp_src", 1);

/* the session should be gone now */
g_signal_emit_by_name (rtpbin, "get-internal-session", 0, &session);
fail_unless (session == NULL);

/* unref the request pad and the static pad */
gst_object_unref (rtp_sink);
gst_object_unref (rtp_src);
gst_object_unref (rtcp_src);

wait_msg("release pad done....");
}

gst_object_unref (rtpbin);
wait_msg("release rtpbin done....");
}


When the program run to "release rtpbin done....". But I find that socket
file handle not released. like this:

[root at ms2 ~]#
[root at ms2 ~]# ll /proc/30263/fd
total 0
lrwx------ 1 root root 64 Sep  1 14:40 0 -> /dev/pts/3
lrwx------ 1 root root 64 Sep  1 14:40 1 -> /dev/pts/3
lrwx------ 1 root root 64 Sep  1 14:40 2 -> /dev/pts/3
lrwx------ 1 root root 64 Sep  1 14:41 3 -> socket:[11628779]
lrwx------ 1 root root 64 Sep  1 14:41 4 -> socket:[11628780]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20160831/03f14c04/attachment.html>


More information about the gstreamer-devel mailing list