我已经在Delphi2010中为Firebird数据库编写了自己的dbx4。该驱动程序是一个dynalink驱动程序,它可以很好地与TSQLConnection配合使用。
最近,我尝试使用Delphi2010发布的DataExplorer.exe,但遇到错误:
"Attempted to read or write protected memory.
This is often an indication that other memory is corrupt".在跟踪源代码后,我发现以下导出方法可能是导致问题的原因:
function DBXLoader_GetDriver(Count: TInt32; Names, Values: TWideStringArray;
ErrorMessage: TDBXWideStringBuilder; out pDriver: TDBXDriverHandle):
TDBXErrorCode; stdcall;调试此方法时,Names和Values参数包含损坏的值。我不知道是什么导致了这个问题。也许DataExplorer.exe有一些内存管理问题(.net问题?)
经过一些尝试和错误之后,我尝试将方法更改为:
type
TWideStringArray2 = array of PChar;
function DBXLoader_GetDriver(Count: TInt32; Names, Values: TWideStringArray2;
ErrorMessage: TDBXWideStringBuilder; out pDriver: TDBXDriverHandle):
TDBXErrorCode; stdcall;这一次,错误消失了,在退出此方法后不久,同样的错误再次出现
"Attempted to read or write protected memory.
This is often an indication that other memory is corrupt".你知道问题的原因是什么吗?
发布于 2011-05-03 05:05:39
看起来你有一些内存分配问题。你最终会使用SimpleShareMem吗?
http://docwiki.embarcadero.com/CodeExamples/en/SimpleShareMem_Sample -介绍如何使用它。
http://www.codexterity.com/memmgr.htm -还包含一些关于内存分配的见解,但使用FastSharemem模块的旧方法。
https://stackoverflow.com/questions/4267634
复制相似问题