为什么在嵌入式 Windows XP 下运行的 Delphi 2006 应用程序出现内存错误
我有一个使用 FastMM4 的 D2006 应用程序(例如,它在 DPR 文件中的 use 子句的开头有“FastMM4”)。我知道 Delphi 使用 FastMM4 作为内存管理器,但下载的版本有更多调试转储选项。
我最近尝试在运行嵌入式 Windows XP 的单板平板电脑型工业 PC 上运行该应用程序。该处理器是非英特尔“Vortex”芯片。该应用程序在启动时因内存错误而失败,然后退出并收到 FastMM4 关于释放内存后访问内存的投诉。
从源代码中删除 FastMM4 的所有痕迹似乎可以解决这个问题 - 应用程序运行良好。
我的问题。下载的 FastMM4 版本是什么导致了这个问题?我见过一些关于 FastMM4 和非 Intel 处理器崩溃的轶事,它们似乎与 ASM 代码的使用有关。 FastMM4 包含一个强制生成非 ASM 代码的指令,但这并不能解决问题。
我有点担心 FastMM4 的完整 D2006 版本可能仍然存在问题,只是我还没有看到它。
I have a D2006 app that uses FastMM4 (like, it has "FastMM4" in the start of the uses clause in the DPR file). I know Delphi uses FastMM4 as it's memory manager anyway, but the downloaded version has more debug dump options.
I recently tried to run the app on a single-board tablet type industrial PC running Windows XP embedded. The processor is a non-Intel "Vortex" chip. The app fails with a memory error on startup and then exits with a complaint from FastMM4 about accessing memory after it has been freed.
Removing all traces of FastMM4 from the source code seems to cure it - the app runs fine.
My question. What is it about the downloaded version of FastMM4 that causes this problem? I have seen anecdotal stuff about crashes with FastMM4 and non-Intel processors that seem to be related to the use of ASM code. FastMM4 includes a directive to force the generation of non-ASM code, but that doesn't cure the problem.
I'm a bit worried that problems might still exist with the integral D2006 version of FastMM4 and I just haven't seen it yet.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
答案是:什么也没有。
Windows XP Embedded 就是没有一些组件的 Windows XP,仅此而已。这些组件与普通 XP 中的组件相同(甚至是等价的二进制组件)。基本上,XPE是 XP,删除了一些 DLL,并且不存在一些注册表项(我知道我在这里过于简化了事情)。
因此,它对您的应用程序造成的唯一区别是某些库可能丢失并且某些组件可能未正确安装。据我所知,除了明显存在的核心 Win32 API 之外,FastMM 不依赖于任何特殊组件,否则您的应用程序根本不会运行(几乎没有任何用户模式会运行)。
因此问题不在于 FastMM4,而在于其他地方。最有可能的是对丢失的库处理不当。可能代码的某些部分动态加载 DLL,但无法验证它是否真正加载,或者从注册表读取某些设置,但无法处理丢失的数据。这会导致内存损坏,幸运的是,当您使用一个内存管理器时,这种情况会变得很明显,而使用另一种内存管理器时则不会。
The answer is: nothing.
Windows XP Embedded is JUST Windows XP without some components, nothing more. Those components that are present are the same that in normal XP (binary equivalent, even). Basically XPE is XP with some of the DLLs deleted and some of the registry entries not present (I know I'm over-simplifying things here).
So, the only difference it makes to your app is that some of libraries might be missing and some of the components might not be properly installed. As far as I know FastMM does not rely on any special components apart from the core Win32 API which is very obviously present, or your app would not run at all (and hardly anything user-mode would).
Therefore the problem is not in FastMM4 but in something else. Most likely it's bad handling of missing libraries. Probably some part of your code dynamically loads DLL but fails to verify if it's really loaded, or reads some setting from registry and fails to handle missing data. This leads to memory corruption which, by the virtue of luck, becomes apparent when you use one memory manager, but does not with the other.
规则 #1:在指责别人之前先指责自己的代码。
在您的代码中查找错误的文章:在调试模式下使用内存管理器 和 Delphi 中的内存问题 。
Rule #1: Blame your code first before blaming others.
Articles to find bug in your code: using memory manager in debug mode and memory problems in Delphi.