user1656546
user1656546

Reputation: 93

CPU usage spikes

My program is all the time running at max 1% of CPU usage but sometimes since some event inside the program, that i cannot determine, it has 100% usage for about 5-10 seconds every 15 seconds. It looks like a Thread causing usage spikes but i cant determine the source of that(there are 8000 classes so thats quite hard). It's hard to test if problem still exists(for example after making some part of code "dead") because that problem is sometimes starting it's existence after few hours of Virtual Machine lifetime.

Have you got any idea what would help me find the source of that problem?

Upvotes: 1

Views: 1548

Answers (1)

thkala
thkala

Reputation: 86403

Without more information, it would be impossible to even attempt a guess at the cause of your problem.

I would suggest using a profiler, such as VisualVM, to determine which thread causes the issue and potentially what the exact circumstances are when it happens.

Using a profiler would tell you for example:

  • Which threads are active and taking up CPU resources
  • Whether they are VM or application threads
  • How much time is spent on garbage collection operations - GC is often a source of CPU usage spikes and therefore latency, although I believe that recent JVMs have improved in that regard.
  • Whether there are locking issues
  • ...

Upvotes: 5

Related Questions