|
Post by Macaos on Apr 22, 2009 5:12:51 GMT -5
Based on some conditionals I delete files in a zip archive. If these conditionals happen to cause all the files in the archive to be deleted i get memory leaks:
37 - 44 bytes: UnicodeString x 1 45 - 52 bytes: TSortedZip x 1
The code below wil produce these memory leaks:
var VCLZip: TVCLZip; MS: TMemoryStream; i: Integer; begin MS:=TMemoryStream.Create; MS.LoadFromFile('test.zip'); VCLZip:=TVCLZip.Create(nil); VCLZip.ArchiveStream:=MS; VCLZip.ReadZip; for i := 0 to VCLZip.Count - 1 do VCLZip.Selected[i]:=True; VCLZip.DeleteEntries; MS:=TMemoryStream(VCLZip.ArchiveStream); MS.Free; VCLZip.ArchiveStream:=nil; VCLZip.Free;
Memory leaks will also occur when calling deleteEntries with no file loaded into archivestream:
45 - 52 bytes: TSortedZip x 1
var VCLZip: TVCLZip; MS: TMemoryStream; begin MS:=TMemoryStream.Create; VCLZip:=TVCLZip.Create(nil); VCLZip.ArchiveStream:=MS; VCLZip.DeleteEntries; MS:=TMemoryStream(VCLZip.ArchiveStream); MS.Free; VCLZip.ArchiveStream:=nil; VCLZip.Free;
Is this a bug or is there a way to avoid these memory leaks?
Ørjan Nilsen
|
|
|
Post by Kevin on Apr 22, 2009 6:43:11 GMT -5
Hi Ørjan,
I will take a look and see what I can find.
1) What version of VCLZip are you using?
2) And what version of Delphi are you using?
3) And, just to be sure I understood, in the first case, the only time there is a memory leak is if all of the files are deleted from the archive? So if there are any entries left, there is no memory leak?
Thanks!
Kevin
|
|
|
Post by Macaos on Apr 22, 2009 7:14:55 GMT -5
1. VCLZip 4.50 2. Delphi 2009 3. You understood correct!
Ørjan
|
|
|
Post by Kevin on Apr 22, 2009 7:21:57 GMT -5
OK, thanks. That helps narrow it down. I will take a look and get back. It may be tomorrow before I have something to report.
Kevin
|
|
|
Post by Kevin on Apr 23, 2009 8:48:50 GMT -5
I'm still looking at this. I did not get a chance to look yesterday.
Kevin
|
|
|
Post by Kevin on Apr 23, 2009 9:33:59 GMT -5
I have a question... Do you set the SortMode property to anything besides ByName in your code?
|
|
|
Post by Macaos on Apr 23, 2009 11:57:42 GMT -5
No I dont change the SortMode property.
|
|
|
Post by Macaos on May 6, 2009 1:29:07 GMT -5
Are you still looking at this Kevin?
Ørjan
|
|
|
Post by Kevin on May 6, 2009 7:12:31 GMT -5
Yes, sorry about getting distracted, but we wanted to get the fix for ansi filenames out as quickly as possible. I will continue looking at this one again today. I have a pretty good idea where the problem is, I just have to verify that I am right.
Kevin
|
|
|
Post by Kevin on May 7, 2009 7:02:33 GMT -5
Ørjan,
I sent you a fix for this by email last night, to try out, and verify that it works for you too. Did you get that?
Kevin
|
|
|
Post by Macaos on May 7, 2009 23:51:28 GMT -5
Thanks. That did the trick. The memory leak is gone now.
|
|