Log in

View Full Version : Memory leak with MPEG2Dec3 v1.00?


jonny
6th March 2003, 20:49
#include<windows.h>
#include<vfw.h>
#include<stdio.h>


void main()
{
PAVIFILE PAviFile;
AVIFILEINFO AviFileInfo;
char *AviFileName = "test.avs";



AVIFileInit();


for (int i = 1; i <= 1000; i++)
{
printf("Open: %i\n", i);


if (AVIFileOpen(&PAviFile, AviFileName, OF_READ, 0) != 0)
{
printf("AVIFileOpen failed\n");
goto Exit;
}


if (AVIFileInfo(PAviFile, &AviFileInfo, sizeof(AviFileInfo)) != 0)
{
printf("AVIFileInfo failed\n");
AVIFileRelease(PAviFile);
goto Exit;
}
else
{
printf(" %ix%i\n", AviFileInfo.dwWidth, AviFileInfo.dwHeight);
}


AVIFileRelease(PAviFile);
}


Exit:
AVIFileExit();
}


I'm using this script and monitoring the memory usage with the Task Manager under Wondows 2000 SP3:


LoadPlugin("c:\yv12\MPEG2Dec3\MPEG2Dec3.dll")
mpeg2source("D:\regina\reg.d2v")
crop(0,72,720,432)
LanczosResize(704,432,0,0.75)
trim(50000, 50999)


Opening/closing the script seems to leak a lot of memory.
The same happen if you open/close more than one time the file with VDubMod.


Using AviSynth 2.0.7 and the usual mpeg2dec works correctly.


I'm using VC 6.0 SP5 to compile the test program:

cl test.cpp /link vfw32.lib

(source + binary attached, simply put test.exe in a folder where you have "test.avs")
Or you can download here: http://jonny.leffe.dnsalias.com/doom9/test.zip


My apologies if i'm missing something, anyway i can't figure out what happen (if this isn't a memory leak)

sh0dan
6th March 2003, 21:21
I only get a 0-byte ZIP file. Could you reattach it?

jonny
6th March 2003, 21:27
It's strange, i've tried to reattach but a message pop up, telling that the file is already uploaded :confused:

You can download here:
http://jonny.leffe.dnsalias.com/doom9/test.zip

sh0dan
6th March 2003, 21:48
As for the leaks - it is very possible. MPEG2DEC3 has some internal buffering, and I'm not sure if Marc deallocates them, when the filter is unloaded.

I looked loosely through the code, and there are no obvious leaks. It is too complex to track each allocation manually - unless someone has several hours available.