Memory leak in nvosd

Please provide complete information as applicable to your setup.

• Hardware Platform (Jetson / GPU) AGX
• DeepStream Version 5.1
• JetPack Version (valid for Jetson only) 4.5.1
• Issue Type( questions, new requirements, bugs) question or bug, we will see

I have a memory leak in my software using DS 5.1. I managed to narrow down the issue to two requirements:

  1. I need to have an nvdsosd in my pipeline
  2. I need to dynamically edit the pipeline (e.g. changing the sink from time to time). The more frequent the sink changes the faster the memory consumption.

After some more digging, I realized if I comment the last 2 lines of the following code snippet, the memory leak disappears.

display_meta = nvds_acquire_display_meta_from_pool(frame_meta->base_meta.batch_meta);
nvds_add_display_meta_to_frame(frame_meta, display_meta);
++display_meta->num_labels;
NvOSD_TextParams *txt_params = &display_meta->text_params[0];
const size_t MAX_DISPLAY_LEN{64};
txt_params->display_text = (char *)g_malloc0(MAX_DISPLAY_LEN);
snprintf(txt_params->display_text, MAX_DISPLAY_LEN, "Frame Number =  %d", frame_number);

My first question is: who is responsible to free the memory, that was g_malloc0-d on the sixth line? I assumed that DS takes care of it (especially because in deepstream_test1_app.c nobody cares about freeing it), but since I have memory leak related to these lines, I became unsure.

Thank you for reporting this problem. Can you reproduce the memory leak with latest DeepStream 6.1?

I do not have a device with DS 6.1 right now, and even if it may be fixed there it may not help me, because my customer insists on DS 5.1 (Jetpack 4.5.1).
Anyway I can reproduce the issue on both DS 5.1 and DS 6.0 (Jetpack 4.6)

The old DeepStream versions are not supported in the forum. Please try with latest DeepStream 6.1.

Right now I cannot update, all of my dev devices are in use.
Can I get at least an answer for my question at the end of the opening post?

The metadata is attached to GstBuffer, so it is released when the GstBuffer is released. When the metadata is released, g_free() will be evoked to release the “display_text”. You don’t need to care about it. (GstBuffer)

Thanks. Today I upgraded one of the devices, and I managed to reproduce the leak on DS v6.1 too.

I reduced my pipeline to simple one. This pipeline does not makes sense, it lacks inference and encodings, it only has fakesinks, but it is enough to reproduce the leak.

I uploaded this code here:
cmakelists.txt: CMakeLists.txt - Pastebin.com
main.cpp: https://pastebin.com/pwu9NT04

You need to edit the uri=... line in main.cpp to add your rtsp camera uri, compile and run it and then see how the memory usage is increasing.

Thank you in advance!

Did anyone from nvidia manage to look into this?

I can’t access the links

Strange, I can access them even in incognito mode. Anyway, I have uploaded them here too:
https://zerobin.net/?d240846881536562#XtdqY8k4ItqYVjDjpDX9CSpHZr+KmRXgMyUE0sSZDQw=
https://zerobin.net/?c418fecc9528974c#LjNfjN7I2mzPdIAmLMH9yuAnz7dSNMTglXIOukrmf4w=

Did anyone from nvidia manage to look into this?

I do not reproduce the memory leak with the attached code.
main.cpp (11.3 KB)

Thank you for checking. What version did you try?

Meanwhile I updated to the recently released JP 5.0.2 / DS 6.1.1 and in that version I also could not reproduce the issue yet. Now I am trying to run my original (non-reduced) pipeline in this version but I have run into another issue, I open another ticket about that one in a minute. If I manage to solve that one, I will be able to test this one as well, and hopefully close this one too.

Hello @tamas2 Can we close this topic for now?

Hi yingliu,
Well, Fiona still have not answer to this question:

I still could not run my original pipeline in DS 6.1.1, because the other issue is blocking me. But since the reduced pipeline is not leaking in 6.1.1, I guess we can close it, in worst case I open a new one if I am still experiencing an issue.

There is no update from you for a period, assuming this is not an issue anymore.
Hence we are closing this topic. If need further support, please open a new one.
Thanks

DeepStream 6.1 and DeepStream 6.1.1

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.