Click here to Skip to main content
14,734,664 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am getting the 100% CPU Usage issue in my Windows service application.

I used the performance analyzer of Visual Studio 2012 and got the below root cause which is having more than 90% CPU usage and shown as a hot path.

We are reading file from shared path and inserting the content of it in DB. Using threading mechanism for it.

We are using Regexlist of around 20 regex and matching each regex of it with file's each line text and if it is matching we are sending that line as an email.

please help if below function can be done in some other way as it is showing as highest CPU usage for the same.

please find below reged which we are using.. .*[eE][rR][rR][oO][rR].* .*[eE][xX][cC][eE][pP][tT][iI][oO][nN]*. .*Full Thread Dump.* .*possible GC.* .*left Cluster with senior member.* .*joined Cluster with senior member.*

please do let me know if is there any other method by which I can find the high CPU USAGE for my windows service application.

private bool ShouldInclude(LogLine logLine)
{
if (_includeRegexList.Count == 0)
return true;

foreach (Regex regex in _includeRegexList)
{
if (regex.IsMatch(logLine.Text))
return true;
}

return false;
}
Posted

1 solution

Percentage of the usage is not a valid metrics. Id does not depends solely on your application, it depends on what other applications do. If all other processes are idle, it's more then reasonable to have high CPU usage for some application which permanently does some real work.

Naturally, most UI applications, when not actively operated by the users, should spend 100% of time in a wait state in all the threads, which does not consume CPU time at all. From the other hand, if your service is operated on the client-server model, it should also spend zero CPU time when there are no requests from the clients. But if this service permanently does some active work, say, crunching some numbers according to some task given to it, high CPU usage would be desirable, the more the better.

Based on your limited information, it's hard to add anything else, but I hope these basic ideas can help you to understand how to analyze your problem. First of all, so far, I see no evidence that you really face any problem.

—SA
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900