Home > Windows API > Using SetProcessWorkingSetSize or EmptyWorkingSet

Using SetProcessWorkingSetSize or EmptyWorkingSet

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

Call SetProcessWorkingSetSize or EmptyWorkingSet.

Usage

SetProcessWorkingSetSize( GetCurrentProcess(), -1, -1 );
//or
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.

Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: