Hello,could you please help me check this issue?

Please provide complete information as applicable to your setup.

• Hardware Platform (Jetson / GPU)
• DeepStream Version
• JetPack Version (valid for Jetson only)
• TensorRT Version
• NVIDIA GPU Driver Version (valid for GPU only)
• Issue Type( questions, new requirements, bugs)
• How to reproduce the issue ? (This is for bugs. Including which sample app is using, the configuration files content, the command line used and other details for reproducing)
• Requirement details( This is for new requirement. Including the module name-for which plugin or for which sample application, the function description)

I take this code snippet from deepstream sdk 6.3 “deepstream_image_meta_test” application ,Used in own project to get frame JPEG ,But I got memory Leak 。

static GstPadProbeReturn
pgie_sink_pad_buffer_probe(GstPad *pad, GstPadProbeInfo *info, gpointer ctx)
    long long curr_time = getCurrentTimestamp();
    SPDLOG_LOGGER_INFO(edge_logger, "Infer_sink CurTime={} infer start!", curr_time);

    GstBuffer *buf = (GstBuffer *)info->data;
    GstMapInfo inmap = GST_MAP_INFO_INIT;
    if (!gst_buffer_map(buf, &inmap, GST_MAP_READ))
        GST_ERROR("input buffer mapinfo failed");
        SPDLOG_LOGGER_INFO(edge_logger, "input buffer mapinfo failed");
        return GST_PAD_PROBE_DROP;
    NvBufSurface *ip_surf = (NvBufSurface *)inmap.data;

    NvDsObjectMeta *obj_meta = NULL;
    guint vehicle_count = 0;
    guint person_count = 0;
    NvDsMetaList *l_frame = NULL;
    NvDsMetaList *l_obj = NULL;
    NvDsBatchMeta *batch_meta = gst_buffer_get_nvds_batch_meta(buf);

    for (l_frame = batch_meta->frame_meta_list; l_frame != NULL; l_frame = l_frame->next)
        NvDsFrameMeta *frame_meta = (NvDsFrameMeta *)(l_frame->data);
        NvDsObjEncUsrArgs frameData = {0};
        frameData.isFrame = 1;
        frameData.saveImg = FALSE;
        frameData.attachUsrMeta = TRUE;
        frameData.scaleImg = FALSE;
        frameData.scaledWidth = 0;
        frameData.scaledHeight = 0;
        frameData.quality = 80;
        nvds_obj_enc_process((NvDsObjEncCtxHandle)ctx, &frameData, ip_surf, NULL, frame_meta);
        //delete frame_meta;


   // delete ip_surf;

    gst_buffer_unmap(buf, &inmap);
    return GST_PAD_PROBE_OK;

What did i miss?

This code snippet will not cause memory leaks. My guess is that you forgot to destroy the context.

  /* Destroy context for Object Encoding */
  nvds_obj_enc_destroy_context (obj_ctx_handle);

You can use valgrind to detect memory leaks

1 Like

Thank you,I will try it .

very Good ,Thank you !

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