Solved

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

Posted on 2011-02-27
4
938 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

707 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

17 Experts available now in Live!

Get 1:1 Help Now