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
Invalid pointer operations occur when you tell the Delphi memory manager to release memory that doesn't belong to it. There are three ways that might happen:
FreeMem
to free something that was allocated by some other memory manager (such as GlobalAlloc
or CoTaskMemAlloc
).Somewhere in your program, you are doing one of those things. The debugger has detected the exception thrown by the memory manager, so do some debugging. From the stack trace, you should be able to see which variable you're trying to free. Check the rest of your program for other ways that variable is used.
Tools like MadExcept and Eureka Log can help you find double-free errors. They can keep track of where the pointer in question got allocated and where it was freed the first time, and that is sometimes enough information to figure out your mistake and stop freeing things multiple times.