Aug 232007

Everseen memory usage of a program go down as soon as it’s minimized. Well how to achieve this programmatically?

Call SetProcessWorkingSetSize or EmptyWorkingSet.


SetProcessWorkingSetSize( GetCurrentProcess(), -1, -1 );
EmptyWorkingSet( GetCurrentProcess() );

MSDN: If both dwMinimumWorkingSetSize and dwMaximumWorkingSetSize have the value -1, the function temporarily trims the working set of the specified process to zero. This essentially swaps the process out of physical RAM memory.

Caution: Read MSDN carefully before you start using this function, there are some caveats which should be carefully considered.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.