Memory leak in zlib with void[]
torhu
no at spam.invalid
Fri Nov 9 07:52:17 PST 2007
Ald Sannes wrote:
> Hello.
> I have the following code:
>
> int zipFileSize = getSize(fileName);
>
> void[] zipFileContent = uncompress(read(fileName), 0, 24);
>
> delete zipFileContent;
>
> return cast (char []) zipFileContent;
>
> I am unzipping some 50 Mbytes of data, and some 50 Mbytes are not being freed.
>
> The delete statement was added to check for memory leaks, and it is there to check is memory leak.
>
> The program does nothing else (commented out).
>
> Where to free the memory?
You can't free zipFileContent, and then use it afterwards. Free it when
you don't need it anymore. You might also want to look at std.zip,
which is higher level than std.zlib.
More information about the Digitalmars-d-learn
mailing list