SetProcessWorkingSetSizeEx and the 'system' process CPU usage

Posted on 2009-02-16
Last Modified: 2013-12-17
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?

Question by:OrenRozen
    LVL 41

    Expert Comment

    I'm not sure we can answer your question without knowing a bit more about your application... what does it do?
    LVL 21

    Accepted Solution

    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.  
    LVL 3

    Author Comment

    partial solution given

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (…
    In my previous two articles we discussed Binary Serialization ( and XML Serialization ( In this article we will try to know more about SOAP (Simple Object Acces…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now