反复查询之后资源耗尽,请问如何释放掉每次查询站用的内存!
代码如下:
procedure TF_Main.TreeVClassMouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
  FindStr1,FindId,MotherIdMid,StrMid,TableName1,TableName2:String;
  I:Integer;
begin
  FindStr1:=RightStr(TreeVClass.Selected.Text,Length(TreeVClass.Selected.Text)-Pos('|',TreeVClass.Selected.Text));
  if FindStr1='' then Exit;
  FindId:=RightStr(FindStr1,Length(FindStr1)-Pos('>',FindStr1));
  MotherIdMid:=LeftStr(FindStr1,Pos('>',FindStr1)-1);
  if not IsInt(FindId) or (FindId='') then
    Exit;
  with F_Data.Query_Main do
  begin
    Close;
    SQL.Clear;
    SQL.Add('Select MainTName,BannerTName,CID from CTree where CID='+MotherIdMid);
    try
      Open  //多次查询后这里显示内存不够!
    except
      Close;
      Exit;
    end;
    if RecordCount=0 then Exit;
    TableName1:=Fields[0].AsString;
    TableName2:=Fields[1].AsString;
    Close;
    SQL.Clear;
    SQL.Add('Select LowId,Detail from '+TableName1+' where LowId='+FindId);
    try
      Open
    except
      Close;
      Exit;
    end;
    First;
    if RecordCount=0 then Exit;
    dbRichEdit1.Clear;
    dbRichEdit1.Text:=Fields[1].AsString;
    dbRichEdit1.SelStart:=0;
    Close;
  end;
end;