Reducing Working Set With EmptyWorkingSet

December 7, 2009 04:14 by Anton

If you develop a desktop based application, you’ll notice that the working set size is quite big. For an empty windows form application, the size can be around 20 MB.

While this is not a problem, sometimes you may want to ‘trick’ the user that your running application has low memory consumption. By using P/Invoke this is possible.

 


[DllImport("psapi.dll")]
static extern int EmptyWorkingSet(IntPtr hwProc);

static void ClearMemory()
{
	  try
      {
            EmptyWorkingSet(Process.GetCurrentProcess().Handle);
      }
      catch
      {
      }
}

 

I got this information from this article. You need to remember that this method will only affect the working set, not the private bytes.


Comments

August 16. 2010 06:35

Good article! I have been looking thru yahoo for several hours looking for relevant info on this, they absolutely should position your website on the first page!

high speed satellite internet

August 28. 2010 10:32

Not sure if anyone pointed this out, I did not read all the remarks, your web sites' layout is really a litte off in Mozilla running on Windows 98.

//gogorton.com/handyman-services.htmlhardi siding

August 28. 2010 10:55

Not sure if anyone pointed this out, I didn't read all of the remarks, your sites' design is really a litte tweaked in Mozilla running on Vista.

metal roofing spokane

August 28. 2010 11:00

Unsure if anybody pointed this out, I failed to read all of the comments, your websites' design is a litte tweaked in Firefox working on Windows7.

west richland siding company

August 30. 2010 05:25

hardi siding

August 30. 2010 05:27

hardie siding

Add comment




  Country flag

Click to change captcha
biuquote
  • Comment
  • Preview
Loading