[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

problems with freemem when closing a file

Posted on 2005-05-12
4
Medium Priority
?
271 Views
Last Modified: 2010-04-05
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
Comment
Question by:YousefEisa
  • 2
4 Comments
 
LVL 17

Assisted Solution

by:TheRealLoki
TheRealLoki earned 300 total points
ID: 13991819
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
 
LVL 20

Expert Comment

by:Madshi
ID: 13993775
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
 

Author Comment

by:YousefEisa
ID: 13994775
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
 
LVL 20

Accepted Solution

by:
Madshi earned 450 total points
ID: 13995073
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

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

868 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question