大家帮我看看这个函数,内存越来越大!线程的
Function FindLrc(p: Pointer): DWORD; stdcall;var ss: UTF8String; Reg: TPerlRegEx; i: Integer; ResultList1: TStrings; begin EnterCriticalSection(MyCs); //进入临界区 ResultList1 := TStringList.Create; Reg := TPerlRegEx.Create(); Reg.Options := [preMultiLine, preCaseLess]; // 重要:设置匹配模式:多行 try ss := Form1.QQEdit2.Text; if Trim(ss) <> '' then begin if SuperLrcSearch=True then begin for i := 0 to Length(Lrcrecord) - 1 do begin Reg.Subject :=Lrcrecord[i].Content+Lrcrecord[i].Name; Reg.RegEx :='(.*?)('+ss+')(.*?)$'; if Reg.Match then ResultList1.Add(Lrcrecord[i].Name+'【'+reg.MatchedText+'】'); end; end else begin for i := 0 to Form1.resultlist.Count - 1 do begin Reg.Subject := Form1.resultlist.Strings[i]; Reg.RegEx :='^'+ss; if Reg.Match then ResultList1.Add(Form1.resultlist.Strings[i]); end; end; Form1.lst1.Items.Clear; Form1.lst1.Items.AddStrings(ResultList1); // LabeledEdit1.EditLabel.Caption:='共'+inttostr(lst1.Items.Count) +'首歌词->搜索:'; Form1.MyShape1.Text := '共' + inttostr(Form1.lst1.Items.Count) + '首歌词->搜索:'; end; finally Reg.Free; ResultList1.Free; LeaveCriticalSection(MyCs); //离开临界区 CloseHandle(hThread); end;result:=0;end;procedure TForm1.LabeledEdit1Change(Sender: TObject);var ID:DWORD;beginhThread:=CreateThread(nil, 0, @Findlrc, nil, 0, ID);//TThread.CreateAnonymousThread(Findlrc).Start;end;