Author |
Message |
Rod Kinnison
| Posted on Thursday, November 25, 2004 - 4:36 am: | |
I sent an e-mail to Winston regarding this problem but I'll post it here in case he doesn't get around to working on it for a while. (What? Someone who writes freeware has a life?) I originally tested Dennis Spreen's HTML parser years ago, which is what Winston based his code on, for use in a web crawling bot. Testing is about as far as I got. When his code was used to parse thousands of html files, it would crash the program. After much gnashing of teeth, (and a few swear words) I eventually determined it to be a memory leak but I never could find it. I downloaded Winston's version of this parser and seeing Spreen's name, decided to test it. I modified Winston's demo program as follows: procedure TForm1.Button1Click(Sender: TObject); var Parser: THyperParse; x,i, j: integer; dolist:tstringlist; begin dolist:=tstringlist.create; for x:=1 to 1000 do begin Parser := THyperParse.Create; Parser.FileName := FileBox.Text; dolist.clear; label2.caption:=inttostr(x); {just a label I stuck in to show iterations.} Parser.Execute; for i := 0 to Parser.Count - 1 do begin if Parser[i].IsTag = true then // Parser is an HTML tag begin dolist.add('TAG: ' + Parser[i].TagName); for j := 0 to Parser[i].ParamCount - 1 do dolist.Add(' Params[' + IntToStr(j) + ']: ' + Parser[i].Params[j].Param); end else // Parser is plain text (not a tag) begin dolist.Add('TXT: ' + Parser[i].Text); end; end; Parser.Free; end; dolist.free; end; (This code was formatted, the msg board stripped out the extra spaces.) Now, unless my Delphi is really bad, this loop shouldn't keep gobbling up memory unless there's a leak somewhere. However, after 1000 parses of a 500+ line HTML file Winston's lil demo program grew from 5 megs memory usage to around 75 megs. Again, I briefly looked over the code for the parser and nothing jumped out at me, then again, I'm a Turbo Pascal hack in an OOP world. Just be aware that if you're parsing a few files, you should be fine. If you're parsing 1000's... have lots of ram. If anyone should happen to find this leak, please let me know as well. |
Anonymous
| Posted on Thursday, February 24, 2005 - 10:18 am: | |
I'm having the same trouble - I lose around 5K each time the parser (version 1.02) is used. |
Nataly
| Posted on Saturday, April 16, 2005 - 1:56 pm: | |
Also noticed memory leak in HyperParse. But I also have found a place in code :-)). I use unit HyperParse version 1.02. Code with memory leak: destructor THtmlInfo.Destroy; var i:integer; begin FParamList.Free; inherited Destroy; end; Must be: destructor THtmlInfo.Destroy; var i:integer; begin for i:=0 to FParamList.Count-1 do dispose(FParamList[i]); FParamList.Free; inherited Destroy; end; So, if it will help anyone, I'l be glad.
|
Anonymous
| Posted on Thursday, May 12, 2005 - 5:11 pm: | |
Hey thanks!!! I just made your changes! |
Marius
| Posted on Tuesday, March 28, 2006 - 1:38 am: | |
Hi All, I have applied the changes suggested by Nataly in Hyperparse but FastMM4 is still mowning about memory leaks. Does anybody have the same / advice? Thanks in advance! |
dennis
| Posted on Wednesday, March 29, 2006 - 2:04 am: | |
Hi all, looks like my old-fast-coded-happy-whacky units are still alive (with the bugs in there since years). FastMM reports the leak and the position, doesn't it? (turn debug=true or something in the fastmm.unit) Regards Dennis Spreen |
dennis
| Posted on Wednesday, March 29, 2006 - 2:45 am: | |
ok, me again. I've changed some lines, used fastmm and Rod Kinnison demo code. no leaks. check it out: http://www.spreendigital.de/delphi/thyperparse102a .zip Regards Dennis |
Raymond
| Posted on Thursday, April 06, 2006 - 5:51 pm: | |
Thank you!!!! I have been using this unit and it has worked very well for me!!! This will even be better with your changes!!! -Raymond |
|