I found an article on About.com that tells you how you can manage your apps memory.
Here is the code:
procedure TrimAppMemorySize;
var
MainHandle : THandle;
begin
try
MainHandle := OpenProcess(PROCESS_ALL_ACCESS, false, GetCurrentProcessID) ;
SetProcessWorkingSetSize(MainHandle, $FFFFFFFF, $FFFFFFFF) ;
CloseHandle(MainHandle) ;
Log('Trimmed Memory Successfull!');
except
Log('Failed to trim Memory!');
end;
Application.ProcessMessages;
end;
I tried it out, works perfectly - Even when my app is doing something, and I fire buttonclicks, etc, it still does its thing, and it works like a charm. I look at my apps Memory usage in the Resource Monitor, and as far as I can see, its all good.
So.. Whats the catch? We all deal with memory issues, but is the solution really that simple? Can anyone tell me if doing this every 60 seconds is a bad thing?
I will reboot and try to run my program, and post a screenshot of my Resource Monitor.
See Question&Answers more detail:os