delphi 内存释放问题

breez123 2014-07-10 07:58:24
本人刚学delphi 做一小程序在跑一段时间后自动关闭。用CheckMem.pas工具查得下面结果:

===== Project1.exe,2014/7/10 7:49:15 =====

可用地址空间 : 1024 KB(1048576 Byte)
未提交部分 : 992 KB(1015808 Byte)
已提交部分 : 32 KB(32768 Byte)
空闲部分 : 29 KB(30416 Byte)
已分配部分 : 1 KB(2016 Byte)
全部小空闲内存块 : 2 KB(2552 Byte)
全部大空闲内存块 : 27 KB(27864 Byte)
其它未用内存块 : 0 KB(0 Byte)
内存管理器消耗 : 0 KB(336 Byte)
地址空间载入 : 0%

当前出现 1 处内存漏洞 :
0) 000000000131C914 - 55($0037)字节 - (未命名): TStringList (48 字节) - In Classes.pas
可这个地方怎么查找到对应该的delphi源码上?
请大神赐教
...全文
217 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
breez123 2014-07-10
  • 打赏
  • 举报
回复
function MyFun(p: Pointer): Integer; stdcall; var Item: TListItem; mylist5:Tstringlist; i,t,g:integer; success: Integer; hostname: PWideChar; port: Integer; channelNum: Integer; termType: PWideChar; widthInChars: Integer; heightInChars: Integer; pixWidth: Integer; pixHeight: Integer; n: Integer; pollTimeoutMs: Integer; cmdOutput:widestring; begin try for i:=0 to mylist3.Count-1 do begin begin g:=0; for t:=0 to mylist4.Count-1 do begin if g<mylist4.Count then begin try mylist5:=Tstringlist.create; mylist5.Clear; try success := ssh.UnlockComponent('30-day trial'); if (success <> 1) then begin mylist5.Add(ssh.LastErrorText); end; hostname := DoStrToWideChar( mylist4.Strings[g]); port := 22; success := ssh.Connect(hostname,port); if (success <> 1) then begin mylist5.Add(ssh.LastErrorText); end; ssh.IdleTimeoutMs :=4000; //sleep(4000); success := ssh.AuthenticatePw(Form1.Edit11.text,mylist3.Strings[i]); if (success <> 1) then begin mylist5.Add(ssh.LastErrorText); end; channelNum := ssh.OpenSessionChannel(); if (channelNum < 0) then begin mylist5.Add(ssh.LastErrorText); end; termType := 'dumb'; widthInChars := 120; heightInChars := 40; pixWidth := 0; pixHeight := 0; success := ssh.SendReqPty(channelNum,termType,widthInChars,heightInChars,pixWidth,pixHeight); if (success <> 1) then begin mylist5.Add(ssh.LastErrorText); end; success := ssh.SendReqShell(channelNum); if (success <> 1) then begin mylist5.Add(ssh.LastErrorText); end; success := ssh.ChannelSendString(channelNum,'ls'+ #13#10,'ansi'); if (success <> 1) then begin mylist5.Add(ssh.LastErrorText); end; success := ssh.ChannelSendEof(channelNum); if (success <> 1) then begin mylist5.Add(ssh.LastErrorText); end; pollTimeoutMs:=2000; n := ssh.ChannelReadAndPoll(channelNum,pollTimeoutMs); if (n < 0) then begin mylist5.Add(ssh.LastErrorText); end; success := ssh.ChannelSendClose(channelNum); if (success <> 1) then begin mylist5.Add(ssh.LastErrorText); end; success := ssh.ChannelReceiveToClose(channelNum); if (success <> 1) then begin mylist5.Add(ssh.LastErrorText); end; cmdOutput := ssh.GetReceivedText(channelNum,'us-ascii'); if (Length(cmdOutput) = 0 ) then begin mylist5.Add(ssh.LastErrorText); end; mylist5.Add(cmdOutput); ssh.Disconnect(); except end; if (POS('#',mylist5.text)>0) or (POS('$',mylist5.text)>0) then begin Item := Form1.ListView1.Items.Add; Item.Caption:=inttostr(Form1.ListView1.Items.Count); Item.SubItems.Add(Form1.Edit11.text); Item.SubItems.Add(mylist3.Strings[i]); Item.SubItems.Add(mylist4.Strings[g]); Item.SubItems.Add(DateTimeToStr(now())); // Form1.Memo7.Lines.Add('用户名:'+b+' '+'密码:'+a+' '+'ip地址:'+c); end; // Form1.listview2.Items[0].SubItems.strings[0]:=mylist3.Strings[i]; Form1.listview2.Items[0].SubItems.strings[1]:=mylist4.Strings[g]; g:=g+100; mylist5.Free; except end; end; if i= mylist3.Count-1 then begin Form1.listview2.Items[0].SubItems.strings[2]:='完成'; end; ClearMemory; end; end; end; except end; Result :=0; end;
一如当初 2014-07-10
  • 打赏
  • 举报
回复
看上去是TStringList没有Free。
breez123 2014-07-10
  • 打赏
  • 举报
回复
代码太长了!我把Tstring去掉也是提示这个。
luxuewei5214 2014-07-10
  • 打赏
  • 举报
回复
看看那个对象没有free;或者装个Eurekalog查一下就知道了
fang 2014-07-10
  • 打赏
  • 举报
回复
如果代码不多的话,把源码也贴出来看看。
hj8090 2014-07-10
  • 打赏
  • 举报
回复
安全用法: aList := TStringList.Create; try //.... finally aList .Clear; aList .Free; end;

5,392

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧