Re: Java app takes 100% of CPU

From: Mark Murphy (n-murphy_at_charter.net)
Date: 12/01/04


Date: Tue, 30 Nov 2004 22:13:04 -0800

Randolf Richardson wrote:
> "Roman Levandovsky <roman@none.com>" wrote in comp.lang.java:
>
>
>>Wendy S wrote:
>>
>>
>>>We've been provided a Java app to use for a homework assignment on
>>>databases. It's my own fault for writing inefficient queries, but it
>>>keeps taking 100% of my CPU and it takes several minutes to get the
>>>Task Manager open and kill it.
>>>
>>>Is there a way, maybe with command line argument, to restrict the
>>>amount of resources it can consume?
>>
>>If it takes 100% of the CPU that means it is wasting resources either
>>because of a memory leak or because of too many threads or because of
>>excessive polling. Did you actually write the application?
>
>
> I agree with all of those possibilities except the "memory leak." A
> memory leak typically consumes memory rather than CPU cycles. If your system
> gets stuck at 100% CPU utilization due to a memory leak, then there's likely
> something else wrong with your system that needs a closer look.
>
Might be time to learn what a profiler does. I had the same problem with
some code and discovered that it was one routine. Fixed that and
everything works alot better.

Personally I think a profiler can help teach students better
programming. Every project should be profiled and the student should
comment on the results.

Learn a profiler before you learn an IDE.



Relevant Pages

  • Re: Java app takes 100% of CPU
    ... > If it takes 100% of the CPU that means it is wasting resources either ... memory leak typically consumes memory rather than CPU cycles. ...
    (comp.lang.java)
  • Re: [PATCH 0/2] x86: fix memory leaks when doing CPU hotplug
    ... Usually this memory leak is not a big deal (for normal CPU hotplug ... But during stress tests with lots of CPU offline/online cycles ...
    (Linux-Kernel)
  • [BUG] mm_struct leak on cpu hotplug (s390/ppc64)
    ... there is an mm_struct memory leak when using cpu hotplug. ... start_secondary in smp.c initializes active_mm of the cpu's idle task ... send the line "unsubscribe linux-kernel" in ...
    (Linux-Kernel)
  • Re: [PATCH 0/2] x86: fix memory leaks when doing CPU hotplug
    ... Usually this memory leak is not a big deal (for normal CPU hotplug ... But during stress tests with lots of CPU offline/online cycles ...
    (Linux-Kernel)
  • Re: QueryPerformanceCounter question
    ... up and thread affinity set to a single CPU. ... maybe 1 thread per CPU, but even that's probably pushing it). ... the 2 QPC calls then my result will be affected. ... The best way to do profiling is to use a profiler. ...
    (microsoft.public.win32.programmer.kernel)