关于内存和资源泄露的第三方工具,我用了MemProof、Sleuth CodeWatch 3
和BoundsChecker来测试我的程序,但均发现报告DELPHI5、6中有许多内存和
资源泄露,在许多VCL库中都有,如Graphics、Controls、Forms、System等,
主要错误有Live pointer、Virtual memory、Pen、Brush、Font
MemProof对于Live pointer的错误定位,举个例子:
***Graphics for d5***
function TResourceManager.AllocResource(const ResData): PResource;
var
ResHash: Word;
begin
ResHash := GetHashCode(ResData, ResDataSize);
Lock;
try
Result := ResList;
while (Result <> nil) and ((Result^.HashCode <> ResHash) or
not CompareMem(@Result^.Data, @ResData, ResDataSize)) do
Result := Result^.Next;
if Result = nil then
begin
GetMem(Result, ResDataSize + ResInfoSize); ****软件定位于这行
with Result^ do
begin
Next := ResList;
RefCount := 0;
Handle := TResData(ResData).Handle;
HashCode := ResHash;
Move(ResData, Data, ResDataSize);
end;
ResList := Result;
end;
Inc(Result^.RefCount);
finally
Unlock;
end;
end;
软件建议用FreeMem释放,但我在finally后面加入FreeMem(Result)以后再用MemProof
还是一样
还有Virtual memory错误,软件建议VirtualFree由VirtualAlloc释放...
还请高人指点个中奥妙!
和BoundsChecker来测试我的程序,但均发现报告DELPHI5、6中有许多内存和
资源泄露,在许多VCL库中都有,如Graphics、Controls、Forms、System等,
主要错误有Live pointer、Virtual memory、Pen、Brush、Font
MemProof对于Live pointer的错误定位,举个例子:
***Graphics for d5***
function TResourceManager.AllocResource(const ResData): PResource;
var
ResHash: Word;
begin
ResHash := GetHashCode(ResData, ResDataSize);
Lock;
try
Result := ResList;
while (Result <> nil) and ((Result^.HashCode <> ResHash) or
not CompareMem(@Result^.Data, @ResData, ResDataSize)) do
Result := Result^.Next;
if Result = nil then
begin
GetMem(Result, ResDataSize + ResInfoSize); ****软件定位于这行
with Result^ do
begin
Next := ResList;
RefCount := 0;
Handle := TResData(ResData).Handle;
HashCode := ResHash;
Move(ResData, Data, ResDataSize);
end;
ResList := Result;
end;
Inc(Result^.RefCount);
finally
Unlock;
end;
end;
软件建议用FreeMem释放,但我在finally后面加入FreeMem(Result)以后再用MemProof
还是一样
还有Virtual memory错误,软件建议VirtualFree由VirtualAlloc释放...
还请高人指点个中奥妙!
解决方案 »
- 发一小小工具:系统路径设置
- 问一个比较菜的问题,怎样在界面上加一个图片??
- 事件影射问题
- 对于一个动态创建的构件,如何在它的事件中加入代码?
- WIN2000下打印quick rep自定义纸张报表
- 类似c语言中的malloc和realloc函数是什么??
- delphi简单问题,在线等待......
- 有没有做GIS的朋友?哪里可以下载北京市的电子地图?学习GIS/GPS测试用。不用很精确,比例尺大一点也可以,有的话可以和我联系,谈谈价格
- 请问怎么建立程序与文件之间的关联?
- Help...Me 各位高手你们有谁会DB2数据库?只要给我提供信息我一定给分!相信我,没错的!
- 内详
- 请问messagebox用法?
你应该Free后再Create看消耗内存有没增加,
而不应该Free后看内存是否减小。
MemProof也不一定可靠的,Borland不会那么傻吧?有问题都不知道?
ly_liuyang(Liu Yang)
老兄,MemProof也不一定可靠,但Sleuth CodeWatch呢,它可是连续3年夺得
国外第三方软件评测第一名,BoundsChecks也是大名鼎鼎!
FreeMem就说是泄漏。li_liuyang说的"Borland不会那么傻吧?有问题都不知道?"问题是Borland他明知有问题也不管!别的不说,单单说dbexpress, Delphi 7的Release Notes上说:
MSSQL driver - Known issues
---------------------------
2) Master detail: a) When trying to open a master-detail as a nested
dataset and if the detail link field is an INTEGER
type and defined NOT NULL you will get a SQL Error
"SQL State:HY000, SQL Error Code: 0, Invalid Input
parameter values. Check the status values for
details" A patch will be made available >>>soon<<< at Borland's
support download site.
直到去年10月份发布MSSQL Driver Update也没有解决这个问题,你说这个问题不解决,它又不公开源码,MSSQL Driver for dbexpress 怎么用?