Hello,

I've got rather simple code, but it seems that some memory is not
cleaned up after it (the Task Manager shows memory growing, but not
being released). Can someone please point out what I'm missing?

The memory "held" is a lot - I'd say around 150MBs per 500 or so video
files of various formats.

The code:

---8<---
AVFormatContext *pFormatCtx = NULL;

// Register all formats and codecs
avcodec_register_all();
avdevice_register_all();
av_register_all();

register_protocol(&ufile_protocol);

int err = -1;
try
{
        char utf8url[4096];
        modify_file_url_to_utf8(utf8url, sizeof(utf8url), strPath);

        err = av_open_input_file(&pFormatCtx, utf8url, NULL, 0, NULL);
} catch(...)
{
        ASSERT(FALSE);
        return -1;
}

if(err < 0)
{
        ASSERT(FALSE);
        return -1; // Couldn't open file
}

// Retrieve stream information
{ __declspec(align(32)) int dummystackaligner = 0; }
try
{
        if(av_find_stream_info(pFormatCtx) < 0)
        {
                ASSERT(FALSE);
                return -1; // Couldn't find stream information
        }
} catch(...)
{
        ASSERT(FALSE);
        return -1;
}

if(pFormatCtx->duration != (__int64)0x8000000000000000)
{
        nDuration = (int)pFormatCtx->duration / AV_TIME_BASE;
}

// Find the first video stream
int videoStream=-1;
for(unsigned int i=0; i<pFormatCtx->nb_streams; i++)
{
    if(pFormatCtx->streams[i]->codec->codec_type==CODEC_TYPE_VIDEO)
    {
        videoStream=i;
        break;
    }
}
if(videoStream!=-1)
{
        char buf[255] = {0};

        { __declspec(align(32)) int dummystackaligner = 0; }
        avcodec_string(buf, sizeof(buf),
pFormatCtx->streams[videoStream]->codec, false);
}

// Find the first audio stream
int audioStream=-1;
for(unsigned int i=0; i<pFormatCtx->nb_streams; i++)
{
    if(pFormatCtx->streams[i]->codec->codec_type==CODEC_TYPE_AUDIO)
    {
        audioStream=i;
        break;
    }
}
if(audioStream!=-1)
{
        char buf[255] = {0};

        { __declspec(align(32)) int dummystackaligner = 0; }
        avcodec_string(buf, sizeof(buf),
pFormatCtx->streams[audioStream]->codec, false);
}

// Close the video file
{ __declspec(align(32)) int dummystackaligner = 0; }
av_close_input_file(pFormatCtx);


---8<---

Have I missed something to clean up?

Thanks in advance,

   Dennis

P.S. I've posted the same question to ffmpeg-user, but probably this is
the more proper list.


_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user

Reply via email to