Delphi/DBExpress导致内存泄漏

前端之家收集整理的这篇文章主要介绍了Delphi/DBExpress导致内存泄漏前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我的应用程序遇到了一个奇怪的问题,它的内存使用量一下子不断上升几百兆,最终应用程序冻结了.该应用程序是用Delphi编写的,它使用数据库,COM(用于OPC)和TCP / IP.

使用FastMM,我已经关注了内存使用情况的屏幕截图.我不完全确定如何读取该表,但看起来有些东西已经分配了296463552个字节(0x100fb000,这是“幻数”?)三次.

有任何想法吗?有没有办法跟踪非Delphi-MM内存分配?

我正在使用Delphi 2007和FastMM 4.96.

编辑:

我使用IMallocSpy编写了一个小助手类来跟踪COM内存分配.这是我得到的摘录:

00119023    5:52:27.484 [4496] TCOMAllocSpy.PreRealloc size: 269462304
00119024    5:52:27.734 [4496] (0002760C){ntdll.dll   } [7C82860C] KiFastSystemCallRet + $0 
00119025    5:52:27.734 [4496] (0009F83A){MyApp.exe} [004A083A] JclDebug.JclCreateThreadStackTrace (Line 3943,"JclDebug.pas" + 7) + $1E 
00119026    5:52:27.734 [4496] (003D496A){MyApp.exe} [007D596A] ComLeakHelper.TCOMAllocSpy.DebugStack (Line 46,"ComLeakHelper.pas" + 2) + $9 
00119027    5:52:27.734 [4496] (003D4B52){MyApp.exe} [007D5B52] ComLeakHelper.TCOMAllocSpy.PreRealloc (Line 125,"ComLeakHelper.pas" + 4) + $2 
00119028    5:52:27.734 [4496] (000053B6){MyApp.exe} [004063B6] System.@WStrAsg (Line 14090,"sys\system.pas" + 10) + $0 
00119029    5:52:27.734 [4496] (002E4490){MyApp.exe} [006E5490] DBXCommon.TDBXCommand.SetText (Line 5304,"..\..\..\..\..\src\pas\dbx\driver\DBXCommon.pas" + 13) + $5 
00119030    5:52:27.734 [4496] (0010A340){MyApp.exe} [0050B340] WideStrings.TWideStrings.GetValue (Line 580,"common\WideStrings.pas" + 3) + $D 
00119031    5:52:27.734 [4496] (002E1AFC){MyApp.exe} [006E2AFC] DBXCommon.TDBXProperties.GetValue (Line 4046,"..\..\..\..\..\src\pas\dbx\driver\DBXCommon.pas" + 1) + $7 
00119032    5:52:27.734 [4496] (002E3FC9){MyApp.exe} [006E4FC9] DBXCommon.TDBXConnectionEx.GetProductName (Line 5071,"..\..\..\..\..\src\pas\dbx\driver\DBXCommon.pas" + 1) + $E 
00119033    5:52:27.734 [4496] (003765FA){MyApp.exe} [007775FA] sqlExpr.TsqlConnection.DoConnect (Line 2467,"..\..\..\..\..\src\pas\dbx\vcl\sqlExpr.pas" + 66) + $21 
00119034    5:52:27.734 [4496] (0011876D){MyApp.exe} [0051976D] DB.TCustomConnection.SetConnected (Line 2628,"DB.pas" + 8) + $4 
00119035    5:52:27.734 [4496] (00118728){MyApp.exe} [00519728] DB.TCustomConnection.Open (Line 2611,"DB.pas" + 0) + $4 
00119036    5:52:27.734 [4496] (00375D6F){MyApp.exe} [00776D6F] sqlExpr.TsqlConnection.CheckConnection (Line 2302,"..\..\..\..\..\src\pas\dbx\vcl\sqlExpr.pas" + 4) + $2 
00119037    5:52:27.734 [4496] (00379241){MyApp.exe} [0077A241] sqlExpr.TCustomsqlDataSet.CheckConnection (Line 3955,"..\..\..\..\..\src\pas\dbx\vcl\sqlExpr.pas" + 2) + $2 
00119038    5:52:27.734 [4496] (0037968A){MyApp.exe} [0077A68A] sqlExpr.TCustomsqlDataSet.OpenCursor (Line 4045,"..\..\..\..\..\src\pas\dbx\vcl\sqlExpr.pas" + 3) + $4 
00119039    5:52:27.734 [4496] (00125EA9){MyApp.exe} [00526EA9] DB.TDataSet.SetActive (Line 9245,"DB.pas" + 12) + $7 
00119040    5:52:27.734 [4496] (00125CA1){MyApp.exe} [00526CA1] DB.TDataSet.Open (Line 9201,"DB.pas" + 1) + $6 
...

所以,问题似乎是在数据库连接中.我正在使用来自Upscene的Firebird 2.1,DBExpress和InterXpress for Firebird驱动程序.

EDIT2:
这似乎分析了类似的问题,至少重点在于这里:http://www.yac.com.pl/mt.texts.sqlexpr-2.en.html

解决方法

问题是Delphi 2007 DbExpress中存在多线程环境中的错误(毕竟它不是线程安全的).更多信息: http://www.yac.com.pl/mt.texts.sqlexpr-2.en.html

猜你在找的Delphi相关文章