hi, I found a memory leak in the program, my programs take up more and more memory. I want to know why.
this is my system information:
xavier nx
Jetpack 4.4.1[L4T 32.4.4]
CUDA 10.2.89
TensorRt 7.1.3.0
VPI 0.4.4
this is my code:
GMainLoop *main_loop;
main_loop = g_main_loop_new(NULL, FALSE);
GstPipeline *gst_pipeline = nullptr;
string launch_string;
guint frameCount = 0;
ostringstream launch_stream;
GstAppSinkCallbacks callbacks = {appsink_eos, NULL, new_buffer};
launch_stream
<< "rtspsrc location=rtsp://192.168.1.160:8554/0 ! "
<< "rtph264depay ! h264parse ! nvv4l2decoder enable-max-performance=1 ! "
<< "nvvidconv ! video/x-raw,width=3840,height=2160,format=RGBA ! "
<< "videoconvert ! video/x-raw,format=BGR ! "
<< "appsink name=mysink ";
launch_string = launch_stream.str();
frameCount = 0;
GError *error = nullptr;
gst_pipeline = (GstPipeline *) gst_parse_launch(launch_string.c_str(), &error);
if (gst_pipeline == nullptr) {
g_print("Failed to parse launch: %s\n", error->message);
exit(0);
}
if (error) g_error_free(error);
GstElement *appsink_ = gst_bin_get_by_name(GST_BIN(gst_pipeline), "mysink");
gst_app_sink_set_callbacks(GST_APP_SINK(appsink_), &callbacks, (gpointer) & frameCount, NULL);
gst_element_set_state((GstElement *) gst_pipeline, GST_STATE_PLAYING);
sleep(10);
//send EOS
GstMessage *msg;
gst_element_send_event((GstElement *) gst_pipeline, gst_event_new_eos());
// Wait for EOS message
GstBus *bus = gst_pipeline_get_bus(GST_PIPELINE(gst_pipeline));
msg = gst_bus_poll(bus, GST_MESSAGE_EOS, GST_CLOCK_TIME_NONE);
gst_message_unref(msg);
gst_object_unref(bus);
gst_element_set_state((GstElement *) gst_pipeline, GST_STATE_NULL);
gst_object_unref(GST_OBJECT(gst_pipeline));
g_main_loop_unref(main_loop);
return 0;
this is my valgrind inofrmation:
==24341== 6,804 (40 direct, 6,764 indirect) bytes in 1 blocks are definitely lost in loss record 177 of 197
==24341== at 0x4845138: malloc (vg_replace_malloc.c:307)
==24341== by 0xAACA773: ???
==24341== by 0xA9C53D7: ???
==24341== by 0xA9B9947: ???
==24341== by 0xA9B4947: ???
==24341== by 0xA97AE77: ???
==24341== by 0x6C2A5BF: v4l2_ioctl (in /usr/lib/aarch64-linux-gnu/tegra/libnvv4l2.so)
==24341== by 0x6BF9DB7: ??? (in /usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstnvvideo4linux2.so)
==24341== by 0x6BFDC2B: ??? (in /usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstnvvideo4linux2.so)
==24341== by 0x68A814F: ??? (in /usr/lib/aarch64-linux-gnu/libgstvideo-1.0.so.0.1405.0)
==24341==
==24341== 17,099 (16,840 direct, 259 indirect) bytes in 7 blocks are definitely lost in loss record 180 of 197
==24341== at 0x4845138: malloc (vg_replace_malloc.c:307)
==24341== by 0x4A6757F: g_malloc (in /usr/lib/aarch64-linux-gnu/libglib-2.0.so.0.5600.4)
==24341==
==24341== 67,064 (66,640 direct, 424 indirect) bytes in 1 blocks are definitely lost in loss record 191 of 197
==24341== at 0x4845138: malloc (vg_replace_malloc.c:307)
==24341== by 0xA9C5077: ???
==24341== by 0xA9B9947: ???
==24341== by 0xA9B4947: ???
==24341== by 0xA97AE77: ???
==24341== by 0x6C2A5BF: v4l2_ioctl (in /usr/lib/aarch64-linux-gnu/tegra/libnvv4l2.so)
==24341== by 0x6BF9DB7: ??? (in /usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstnvvideo4linux2.so)
==24341== by 0x6BFDC2B: ??? (in /usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstnvvideo4linux2.so)
==24341== by 0x68A814F: ??? (in /usr/lib/aarch64-linux-gnu/libgstvideo-1.0.so.0.1405.0)
==24341==
==24341== LEAK SUMMARY:
==24341== definitely lost: 84,858 bytes in 18 blocks
==24341== indirectly lost: 16,327 bytes in 29 blocks
==24341== possibly lost: 8,460 bytes in 71 blocks
==24341== still reachable: 8,996,319 bytes in 29,277 blocks
==24341== of which reachable via heuristic:
==24341== length64 : 3,112 bytes in 67 blocks
==24341== newarray : 1,936 bytes in 41 blocks
==24341== suppressed: 0 bytes in 0 blocks
==24341== Reachable blocks (those to which a pointer was found) are not shown.
==24341== To see them, rerun with: --leak-check=full --show-leak-kinds=all