Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

CPU utilization goes from 10% to 100% gradually over ~60mins of use

Posted on 2004-09-19
11
Medium Priority
?
596 Views
Last Modified: 2008-02-01
I have a CPU creep problem in my application and don't know how to troubleshoot it.  What happens is I will start up the app and turn on perfmon looking specifically at the CPU utilization of the application process and thread count.  The app will start off using about 10% CPU and 8-10 threads.  It gradually increases its load on the CPU and thread consumption over the course of about 60 mins after which time it is using 100% CPU and 60 threads.  I have to suspect that this is some how related to the multithreading but have no idea how to look at what part of the app is causing the CPU creep.  This is my first serious multithreaded app and i'm really at a loss.  I will award points for ideas about how to investigate the problem because it doesn't seem likely that anyone will be able to tell me what line of code is causing the problem... ;-)  Thanks!
0
Comment
Question by:stealth188
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
  • +2
11 Comments
 
LVL 7

Expert Comment

by:sj_hicks
ID: 12099601
Process Explorer from http://www.sysinternals.com give lots of info about running processes such as threads, handles etc.  This might be helpful.
0
 
LVL 18

Accepted Solution

by:
armoghan earned 750 total points
ID: 12102018
0
 

Assisted Solution

by:samitt
samitt earned 150 total points
ID: 12105636
For starters.. you could go to Perfmon and add counter ".NET CLRLocksAndThreads" for your application instance. Keep an eye on total no. of Contentions, Contention rate per second..
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:stealth188
ID: 12105671
I was using spy++ and saw that there was contention happening, but I don't know how much is 'bad'.  How would I determine that such and such code is producing the contention?  Can you offer any advice?
0
 

Expert Comment

by:samitt
ID: 12106118
It's never very easy to debug... the way I would approach it is to break the app into smaller pieces.. write out log / trace messages at each thread start / stop  and probably with every other line of code..
In a well synchronized world any amount of thread contention should be avoided (but may not always be feasible).
0
 

Expert Comment

by:samitt
ID: 12106130
Are you user a 1 processor system? How is the GC implemented?
0
 
LVL 1

Author Comment

by:stealth188
ID: 12107186
I am using a 3.06 intel with HT.  Not sure how to answer GC question... If that gives you any indication ;)
0
 
LVL 1

Author Comment

by:stealth188
ID: 12107470
Took a look at the Contention Rate/sec.  It starts at about 1/sec and then after a while the couter increments with larger numbers.  It is at that point that the CPU starts to take off so it seems pretty reasonable to conclude that the two are related.  When you posted earlier you talked about writing trace messages when threads start/stop.  What information would be useful and should be included in the trace messages?  Contention is where multiple threads want to use a global variable correct?  there is only one situation where i use synclock in the app so I assume that has to be the source of the problem.  I tried to implement it using the smallest "footprint" possible.  Can you offer some advice on how to structure the synclocks?  Or possibly an alternative?  I am using Synclock to batch some SQL together and have included a code snipet below.  Thanks!

        SyncLock BatchSQL
            BatchSQL.Append(strSQL)
            BatchSQL.Append(";")
            BatchSQLCount += 1

            If BatchSQLCount >= 250 Then
                'If the SQL batch is big enough then copy the batch to a temp string variable and clear the global string variable
                SQLTemp = BatchSQL.ToString

                BatchSQL.Remove(0, BatchSQL.Length)
                BatchSQLCount = 0

                ExecuteBatch = True
            End If
        End SyncLock
0
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 12113540
that is not a long held lock and should not cause too much of an issue.

(form previous questions) there are other variables used within your app that are shared the async io on the socket is a good example.
0
 
LVL 1

Author Comment

by:stealth188
ID: 12115688
I took a look at the .net memory profiler.  I am new to the multithreading scene so it is taking me a while to understand what I am looking at.  What I think I have discovered is that a class I am creating to pass data to a thread is not being freed after the thread is finished.  So the question I think that I want to ask is how do I make sure that I have properly "disposed" of a class that has been used to send data to a thread after the thread has completed its job?
0
 
LVL 37

Assisted Solution

by:gregoryyoung
gregoryyoung earned 600 total points
ID: 12115732
the object is a holder class and will be picked up during garbage collection. This is normal.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

688 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