Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
482 views
in Technique[技术] by (71.8m points)

debugging - Invalid Pointer Operation - Delphi XE

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.

enter image description here

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,

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...