title: SetProcessWorkingSetSize - What's the catch?
body: <p>I found an <a href="http://delphi.about.com/od/windowsshellapi/ss/setprocessworkingsetsize-delphi-program-memory-optimize_5.htm" rel="nofollow noreferrer">article on About.com that tells you how you can manage your apps memory.</a></p>
  
  <p>Here is the code:</p>
  
  <pre><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;
  </code></pre>
  
  <p>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.</p>
  
  <p>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?</p>
  
  <p>I will reboot and try to run my program, and post a screenshot of my Resource Monitor.</p>