SetProcessWorkingSetSizeEx and the 'system' process CPU usage

My application, when running in terminal server, takes about 80Mb of ram and more.
The server is 2003 standard 32bit with 2 DualCore CPU's and 4Gb.
I found a way to reduce the amount of working set used by my application with the SetProcessWorkingSetSizeEx method but the more users connecting to the terminal server I noticed that the 'system' process is using 25% of the CPU (100% of one core) after running this method to the level where it 'hurts ' the server performance.

BTW, after running the method, it reduces the size of the WS form 80Mb to 5Mb. Also, I'm running this method every 1 minute.

1. why is that process using the 'system' process?
2. is it possible to reduce the usage of this process?
3. if not, any other way to trim the memory of the application?

Who is Participating?
I'll post the disclaimer that I haven't played in this realm so I'm just guessing but...

You're probably forcing garbage collection to cycle too frequently.  Assuming you're only working with managed memory I presume one could reduce the working set to force gc to run more frequently, keeping the memory footpring smaller but at the cost of a less efficient gc process.  You might use a memory profile tool to be sure you aren't leaking any managed objects, and then you could try tuning the working set size.  I presume as you gradually decrease the working set size you can use perfmon to watch the gc cycles and you'll see the gc frequency increase.  
I'm not sure we can answer your question without knowing a bit more about your application... what does it do?
OrenRozenAuthor Commented:
partial solution given
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.