D
Dv
Unregistered / Unconfirmed
GUEST, unregistred user!
XP sp2, D7, APRO 4.06, FastMM 4.78应用程序动态创建TApdComPort,TApdDataPacket.在TApdDataPacket.OnTimeOut事件中释放TApdComPort,TApdDataPacket.FastMM4提示有内存泄露.代码是要在超时一定次数后释放创建的对象.//==========================================================var I: Integer; FComPort: TApdComPort; FDataPacket: TApdDataPacket;...procedure CreateCOMOjbect;begin FComPort := TApdComPort.Create(nil); with FComPort do try //定义端口属性; .... FDataPacket := TApdDataPacket.Create(nil); with FDataPacket do try ComPort := FComPort; //定义通讯规则 .... //超时设置 TimeOut := 10; //触发事件 OnTimeOut := PacketTimeOut; except FDataPacket.Free; end; except FComPort.Free; end; I := 0;end;procedure PacketTimeOut(Sender: TObject);begin Inc(I); if I > 2 then begin FDataPacket.Free; FComPort.Free; end else FDataPacket.Enabled := True;end;//==========================================================也试过APRO 4.07,故障依然出现.不知原因何在?请高人赐教.谢谢!