Learn how to clean up the memory used by your Delphi program using the SetProcessWorkingSetSize Windows API function.
Memory Usage of a Program / Application / ProcessTake a look at the screen shot of the Windows Task Manager...
The two rightmost columns indicate CPU (time) usage and memory usage. If a process impacts on either of these severely, your system will slow down.
The kind of thing that frequently impacts on CPU usage is a program that is looping (ask any programmer that has forgotten to put a "read next" statement in a file processing loop). Those sorts of problems are usually quite easily corrected.
Memory usage on the other hand is not always apparent, and needs to be managed more than corrected. Assume for example that a capture type program is running.
This program is used right throughout the day, possibly for telephonic capture at a help desk, or for some other reason. It just doesn’t make sense to shut it down every twenty minutes and then start it up again. It’ll be used throughout the day, although at infrequent intervals.
If that program relies on some heavy internal processing, or has lots of art work on its forms, sooner or later its memory usage is going to grow, leaving less memory for other more frequent processes, pushing up the paging activity, and ultimately slowing down the computer.
Read on to find out how to design your program in such a way that it keeps its memory usage in check...
Note: if you want to know how much memory your application is currently using, and since you cannot ask the user of the application to look at the Task Manager, here's a custom Delphi function: CurrentMemoryUsage