[Libav-user] avformat_find_stream_info memory leak

Zanelli Franco fzanelli at tecnosens.it
Tue Aug 21 16:13:11 CEST 2012


I experienced that avformat_find_stream_info(), during the stream scan 
of an ip camera, has a strong memory leakage, maybe because it buffers 
the data to probe. Did someone experience the same problem? Is there a 
way to free the memory?

thank you

ps: this is my code:

// format context
     AVFormatContext *fc = avformat_alloc_context();
     params->clock = clock();
     AVIOInterruptCB int_cb = {interrupt_cb, params};
     fc->interrupt_callback = int_cb;

     // options. Es. rtsp_transport tcp
     AVDictionary *opts = 0;
     if (jopts != NULL) {
         int stringCount = (*env)->GetArrayLength(env, jopts);

         int i;
         for (i = 0; i < stringCount; i += 2) {
             jstring jopt = (jstring) (*env)->GetObjectArrayElement(env, 
jopts, i);
             jstring jval = (jstring) (*env)->GetObjectArrayElement(env, 
jopts, i + 1);
             const char *opt = (*env)->GetStringUTFChars(env, jopt, 0);
             const char *val = (*env)->GetStringUTFChars(env, jval, 0);

             av_dict_set(&opts, opt, val, 0);
         }
     }

     // start the input stream
     int res;
     res = avformat_open_input(&fc, url, 0, &opts);
     if (res != 0) {
         char response[2048];
         av_strerror(res, response, sizeof (response));
         printlog(LOG_TYPE_ERROR, dec_id, "av_format_open_input: %s", 
response);
         return res;
     }

     // stream  info
     res = avformat_find_stream_info(fc, &opts);
     if (!(res >= 0)) {
         char response[2048];
         av_strerror(res, response, sizeof (response));
         printlog(LOG_TYPE_ERROR, dec_id, "avformat_find_stream_info: 
%s", response);
         avformat_free_context(fc);
         return res;
     }

....


More information about the Libav-user mailing list