Search code examples
delphidelphi-7

Memory Error While Closing The Application


While closing the application in Delphi 7, I am getting following error:

"The instruction at 0x011c34a6 referenced memory at 0x018333f4. The memory could not be read."

Any idea what is causing this issue ?


Solution

  • That is an Access Violation exception. It is raised when your program attempts to access an invalid memory address.

    The most obvious cause is that you are accessing memory that has been deallocated and returned to the system. I recommend that you execute under the debugger and let the debugger break at the code that raises the exception. This will tell you what object you are referencing and then you've got to work out why you are referencing it after the object has been destroyed.

    Having said that, the instruction pointer value of 0x011c34a6 doesn't look like it's in your exe which will be based at 0x00400000. So perhaps the exception is raised in a DLL which may make the fault a little more tricky to debug.

    I recommend that you use the FastMM memory manager with full debug options rather than the default Borland MM from Delphi 7. FastMM has lots of debugging tools to help locate and diagnose faults such as this. It may help track down this fault, but if not it will for sure help you find other faults in the future.