Solved

My C# Application causing high CPU. How to debug?

Posted on 2011-02-27
4
960 Views
Last Modified: 2012-05-11
I have a C# application which I have made. It does 100+ different tasks and recently I made some changes in my code that has started to cause random high CPU usage.

Unfortunately I have lost track of the last set of changes I had made and trying to troubleshoot it by disabling 1 function at a time would be very time consuming.

My program also runs about 40 different threads so using the debugger to chase the code 1 step at a time isn't very helpful either.

I know my program doesn't generally use so much CPU. So I have some logic error somewhere but very hard to find!

Any tips on how I can troubleshoot this better? Pehaps theres a better way to make use of the debugger tool?
0
Comment
Question by:ultramoo
4 Comments
 
LVL 3

Accepted Solution

by:
sergiobg57 earned 500 total points
ID: 34991196
Use a profiler.
It will tell how many times methods were called and how long it took them to complete.

I just know one which is free of charge:
http://www.eqatec.com/Profiler/

Open in new window

0
 
LVL 11

Expert Comment

by:Sudhakar Pulivarthi
ID: 34996168
Hi,

You can get some more free profilers.
http://csharp-source.net/open-source/profilers

Download a free trial of these performance testing tool for solving ur issue.
http://www.red-gate.com/products/dotnet-development/ants-performance-profiler/
0
 

Author Closing Comment

by:ultramoo
ID: 34996171
Thanks didn't know such programs existed.

The profiler says how long it took but doesn't say how much CPU cycles it took - Some of my methods have Thread.Sleep commands so the length doesn't really help.

Still I was able to figure out a lot from this. If you know of any profiler that can show CPU cycles used that would be great!

I'll keep searching around.
0
 
LVL 15

Expert Comment

by:Russell_Venable
ID: 35000114
Why don't you use process explorer or process monitor from systeminternals.com it's free and it allows you to learn how your program works and show's CPU usage as well as threading operations among other hard to track down problems.
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

832 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