Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Invalid Pointer Exception

Status
Not open for further replies.

shuesty

Programmer
Jul 10, 2004
15
DE
I'm getting an invalid pointer exception as my program closes which is baffeling me. Looking at the project code ... it pass the Application.Run line and reaches end. Which you would think it would pass over and terminate the program. But appearantly on that line is where the exception occurs. I have looked through all of the OnClose function and it gets through them all. Any ideas why the exception is thrown?

Shuesty

Shuesty
 
Check any memory you have allocated is freed.
Also check that any memory you free hasn't already been freed i.e.
Code:
  if Assigned(xyz) then
    xyz.Free;
Hope this helps!

Clive [infinity]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"To err is human, but to really foul things up you need a computer."
Paul Ehrlich
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To get the best answers from this forum see: faq102-5096
 
So I've made some progress into locating the error but I'm still at a loss at to why the error occurs. I have written 3 dlls to accompany the application which I appearantly prematurely destroy. When I trace into the 'end.' line in the application project I get to the main dll's 'begin' line. It is on this line that the EInvalidPointer exception is raised. Know why this is happening and how to prevent it?

Shuesty
 
show some source code, maybe we can help...

--------------------------------------
What You See Is What You Get
 
Ok here's the lines inside my executable
Code:
begin
  Application.Initialize;
  (create a bunch of forms)
  Application.Run;
end.

And inside a dll
Code:
exports
  FileRead,
  FileWrite,
  FileTypesRead,
  FileTypesWrite;

begin
end.

I'm not doing anything fancy whatsoever. But somehow while the program is closing there is a Invalid Pointer. It reaches the 'end' within the executable and is sent off to the DLL to go through the implementation there and at the 'begin' is where is crashes. I am not 100% positive that it's due to the DLL prematurely being destroyed because I don't destroy the DLL, but it is the only thing that makes sense.

Thanks to all to take a look at this.

Shuesty
 
I found the error. While cleaning up the files I had alphebetized the various components in the uses clause ... including the reference to ShareMem. I was finally reminded that ShareMem must go first by going back to a 'Write a DLL 101' page ... gotta love those pages.

Shuesty
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top