none
CPU Usage of my appplication.. RRS feed

  • Question

  • Hi,

    I have written a windows application which connects to serail ports and TCP/IP. I am using multithreading for this and when I run my application, the cpu usage is going to 100% and when I close my application it is being less then 5%.
    How can I manage this?

    Thanks.
    Thursday, March 5, 2009 9:30 AM

Answers

  • Standard recipe for high cpu load:

    1) Run the application though a profiler (ants is pretty decent, and they even have a free 14 day trial)
    2) see where all the cpu cycles are being burned, fix problem
    3) Goto 1 until cpu load is low enough for your liking.
    • Marked as answer by Zhi-Xin Ye Wednesday, March 11, 2009 8:56 AM
    Friday, March 6, 2009 2:32 PM

All replies

  • Look for loops that can be replaced by events and timers.
    Thursday, March 5, 2009 9:53 AM
  • Hi,

    Even I use timer and events also I am getting the same result. The problem is coming from the serail port thread which is always communicating to the serail port. when I stop that thread see the CPU usage it is nothing and not more then 2%. I again start serial port thread it is going to more than 50%.
    I have no idea where exactly I am doing wrong.
    Any Idea? If want the code which i wrote in serial port thread I can send.

    Thanks.
    Friday, March 6, 2009 7:01 AM
  • Change the subject line of your post since you know that you problem is in your serial port coding.  Something like "High CPU usage on serial port thread".
    Friday, March 6, 2009 10:46 AM
  • Meh, change it to "Problem with my code [code not included]".
    Hans Passant.
    Friday, March 6, 2009 11:13 AM
    Moderator
  • Standard recipe for high cpu load:

    1) Run the application though a profiler (ants is pretty decent, and they even have a free 14 day trial)
    2) see where all the cpu cycles are being burned, fix problem
    3) Goto 1 until cpu load is low enough for your liking.
    • Marked as answer by Zhi-Xin Ye Wednesday, March 11, 2009 8:56 AM
    Friday, March 6, 2009 2:32 PM