指针操作无效 - Delphi XE [英] Invalid Pointer Operation - Delphi XE
问题描述
当我告诉编译器在无效指针操作错误中断时,它不会做任何事情,但挂起程序。在这一点上,我不得不终止或终止这个过程。
你如何看待这一个?
提前感谢
当内存管理器尝试释放无效内存时,抛出无效的指针异常。有三种方法可以发生。
最常见的是因为您正在尝试释放已经释放的对象。如果您打开FastMM的FullDebugMode,它会检测到这一点,直接指向问题。 (但请确保构建一个地图文件,以便它具有创建有用的堆栈跟踪所需的信息。)
第二种方法是如果您尝试可用内存被分配到除内存管理器以外的其他位置。从Delphi EXE传递一个字符串到没有使用共享内存管理器功能的Delphi DLL时,我已经看过这个了。
第三种方法是直接用指针搞乱,可能不适用于你。如果您尝试
FreeMem
或 Dispose
一个不指代FastMM分配的实际内存块的错误指针,你会得到这个错误。 这很可能是第一个。使用FullDebugMode,您可以轻松找到问题的根源。
I can't seem to figure this one out. My program compiles and runs successfully, but during debugging only it pops up a message box saying "Invalid Pointer Operation" when shutting the program down. I have painstakingly checked all the FormCloseQuery and FormDestory events for any syntax or logical error. I found none and they execute as expected without any error.
When I do tell the compiler to break at Invalid Pointer Operation error, it doesn't do anything but hangs up the program. At which point, I had to terminate or kill the process.
How do you figure this one out?
Thanks in advance,
An Invalid Pointer exception is thrown by the memory manager when it tries to free invalid memory. There are three ways this can happen.
The most common is because you're trying to free an object that you've already freed. If you turn on FastMM's FullDebugMode, it will detect this and point you directly to the problem. (But make sure to build a map file so it will have the information it needs to create useful stack traces from.)
The second way is if you're trying to free memory that was allocated somewhere other than the memory manager. I've seen this a few times when passing a string from a Delphi EXE to a Delphi DLL that wasn't using the shared memory manager feature.
And the third way involves messing around with pointers directly and probably doesn't apply to you. If you try to FreeMem
or Dispose
a bad pointer that doesn't refer to an actual block of memory allocated by FastMM, you'll get this error.
It's most likely the first one. Use FullDebugMode and you'll find the source of the problem easily.
这篇关于指针操作无效 - Delphi XE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!