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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Memory problems; how to handle?

Status
Not open for further replies.

CHeighlund

Programmer
Jun 11, 2007
163
US
I am working with a program designed to hit a remote database. Due to the requested format for information being passed to the user, I've been running tests across the full database range, and I've run across an interesting little problem. My first test always runs effectively, but a second test, on a different subset of the db, done immediately afterwards will fail with an out of memory error - if the first result set was large enough.

To me, this seems to indicate that I'm requesting memory and not having it freed up when the run ends. I admit what I'm testing over isn't likely to be used by the end user, but 'not likely' isn't the same as 'never going to happen' and I'd like to be prepared if it does. Does anyone have any suggestions as to how I would force this memory to be freed up?
 
Is every Create method in your code followed immediately by a try..finally block, where the finally block contains a Free method for the same object?

Do you use GetMem? Make sure any such calls have appropriate FreeMem calls structured with try..finally blocks.

Are you using any 3rd party components (not supplied with Delphi)? It's possible that these are leaking memory.

If you're not using Delphi 2006 and later, download and use FastMM ( Not only is a better memory manager than the built in Delphi one, but it can also provide information on memory leaks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top