1

Our Java-based server application is reporting an unusually high class loader time:

# jstat -class 10625 1000
Loaded  Bytes  Unloaded  Bytes     Time
  4781  9165.6      114   185.2   17769.35
  4781  9165.6      114   185.2   17769.85
  4781  9165.6      114   185.2   17770.36
  4781  9165.6      114   185.2   17771.11
  4781  9165.6      114   185.2   17771.73

This is on a server that had been running ~8 hours. jstat reports it has spent 17,769s (~4h56m!) doing class loading, and about 0.5-0.6 extra seconds every second! We've been tracking a performance issue and this is our best candidate for a culprit. Just to be sure, we checked our other Java services: jstat showed a very low value in the Time column (a few seconds, even after having run for hours)

Our code doesn't do constant class loading, but we can't rule out a misbehaving 3rd party library. We enabled -verbose:gc hoping to diagnose the problem. But once our server loads all of its classes (within a minute or so of heavy traffic) the verbose class log became quiet -- we were half-expecting to see a flurry of activity given the jstat data.

My questions would be:

  • Is this really indicative of a problem?
  • If so, what else could be done to diagnose it?

Would really appreciate any suggestions.

4

1 回答 1

1

这似乎是一个真正的问题。鉴于类加载时间增加而加载类的数量保持不变,我可以得出结论,应用程序会一遍又一遍地尝试加载丢失的类,例如通过Class.forNameor ClassLoader.loadClass

如果缺少一个类,JVM 会在抛出ClassNotFoundException. 如果类路径包含许多 JAR 甚至网络 URL,这可能需要很长时间。

为了进一步诊断这一点,我建议使用仪器 Class.forNameClassLoader.loadClass方法或拦截 ClassNotFoundExceptions

于 2014-10-02T13:25:13.753 回答