Re: CPU increasing slowly up to 100%

From: Paul Lutus (nospam_at_nosite.zzz)
Date: 10/18/04


Date: Sun, 17 Oct 2004 22:53:42 -0700

SLL wrote:

/ ...

> Any ideas for further investigation?

After my first post, I thought about this some more and realized two other
possibilities.

1. I think you should look for examples of one process waiting for another
to complete, but waiting in inefficient ways.

Generic example:

while(otherProcessNotComplete);

Sometimes people think if this sort of wait is placed in a thread, there's
no harm in it -- but this sort of wait can eat CPU time like crazy.

Alternative:

while(otherProcessNotComplete) {
        Thread.sleep(1000);
}

I hope this is not too terribly obvious. I raise it because of your report
that if you kill off one JVM, the problem goes away. This made me think of
various kinds of time-eaters and deadlocks.

2. On the topic of deadlocks, and again at the risk of saying the obvious,
never stop a thread externally. If you must stop a thread, set a flag that
is visible to the thread, have the thread's code detect the state of the
flag and exit on its own.

This is also a classic way to create the kind of problem you are seeing, and
it is also possibly entirely too obvious.

I apologize in advance if these are simply not sophisticated enough to rank
as possibilities in your situation.

-- 
Paul Lutus
http://www.arachnoid.com


Relevant Pages

  • Re: Find Previous Instance on another computer?
    ... It has been suggested you use some sort of flag and you have ... running instances. ... > check a second computer for the same reason. ...
    (microsoft.public.vb.general.discussion)
  • Re: Strange CListCtrl Sorting problem
    ... I had Sort flag set to ascending in the resource editor. ... >> If the first time I populate the CListCtrl and sort it, ... >> AliR. ...
    (microsoft.public.vc.mfc)
  • Re: Strange CListCtrl Sorting problem
    ... I had Sort flag set to ascending in the resource editor. ... > If the first time I populate the CListCtrl and sort it, ... > AliR. ...
    (microsoft.public.vc.mfc)
  • Re: OO, I just dont get it.
    ... write a program that can forward sort lines of text from standard ... Now add in a command line option to "sort in reverse". ... tells the algorithm which which item goes first, ... Now add a command line flag to sort numerically. ...
    (comp.object)