加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

delphi – 遇到错误使用DataExplorer.exe连接到本地生长的DBX4驱

发布时间:2020-12-15 10:18:58 所属栏目:大数据 来源:网络整理
导读:我在Delphi 2010中为Firebird数据库编写了自己的DBX 4。该驱动程序是一个动态链接驱动程序,它工作正常与TSQLConnection。 最近我尝试使用Delphi 2010发布的DataExplorer.exe遇到错误: "Attempted to read or write protected memory. This is often an ind
我在Delphi 2010中为Firebird数据库编写了自己的DBX 4。该驱动程序是一个动态链接驱动程序,它工作正常与TSQLConnection。

最近我尝试使用Delphi 2010发布的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".

你有什么想法可能是什么原因的问题?

解决方法

看起来你有一些内存分配问题。您是否使用SimpleShareMem finalualy?

http://docwiki.embarcadero.com/CodeExamples/en/SimpleShareMem_Sample – 介绍如何使用它。

http://www.codexterity.com/memmgr.htm – 还包含一些关于内存分配的见解,但使用FastSharemem模块的旧版本。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读