• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 274
  • Last Modified:

problems with freemem when closing a file

My Delphi 7 program seems to behave well when it is running on Windows XP.  Yet the same program running onWindows  Server 2003 gives an error when I clos ethe program down, citing problems with Freeing up memory. is there much difference bewteen the two platforms when it comes to running Delphi (version 7). If Xp cannot find a problem, how can I find out what is wrong.

I create a number of dynamic arrays while the program is running. My  Closing instruction (when the user stops the program) is to use the finalze procedure to kill off the dynamic arrays.  Do I have to close them in any particular order?  When using XP it seems to make no difference if I finalise the dyanamic arrays or not. The program just closes down without a pronblem. It appears that Delphi 7 must embed some code to free the memory used up by dyanaic arrays.  

I notice that Delphi 2005 says that it is targetted to XP as well as to Server 2003. I wonder if I should complie my application under Delphi 2005.


0
YousefEisa
Asked:
YousefEisa
  • 2
2 Solutions
 
TheRealLokiSenior DeveloperCommented:
with dynamic array's it's just SetLength(MyArray, 0);
have you made sure all other events/threads are closed also? e.g. timer1.enabled := false;
0
 
MadshiCommented:
Delphi 7 is fully compatible with 2003. The problem must be with your code. Generally you don't need to finalize dynamic arrays. Delphi does it for you. And even if it wouldn't, Windows would in the end also do it for you.

Make sure you have stopped all threads (as TheRealLoki already said) before letting your app shut down.
0
 
YousefEisaAuthor Commented:
Thanks guys for the quick response.
My program is single threaded and i do not use timers. some dynamic arrays are global and stay active until the propgram ends. Other dynamic arrays are created within procedures but I close them before the procedures finishes.

I use setlength a lot dealing with strings to dynamically change their size. I am assuming that I do not have to wory about these as they are initially defined as string variables within functions or procedures.

But what is puzzling is that if there is something wrong with my code, why does the program behave well on XP, and gives me an error when running on Windows Server? Is XP more tolerant?
0
 
MadshiCommented:
There's no basic difference between XP and Windows 2003 Server. They're even running more or less the same kernel! Probably it's just random that it crashes on one PC but not on the other. It might also happen, that it will crash on another XP PC, but not on a 2nd 2003 Server PC.

Have you tried madExcept yet?

http://help.madshi.net/madExcept.htm
http://madshi.net/madCollection.exe
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now