Does high cpu usage affect JAVA GC?

1.7k views Asked by At

Recently I am developing an android app for video conferencing. I observed that when the cpu usage is less than 95%, there is half free memory left. However when the cpu usage goes up, the memory usage will soon reach 90% and even more. I don`t have much knowledge with JVM or GC and I was wondering is the GC performance somehow related two the cpu usage?

If it is, is there a advice that I can follow to balance cpu and memory usage?

Thank you in advance.

2

There are 2 answers

0
pranavrao1 On

http://www.dynatrace.com/en/javabook/impact-of-garbage-collection-on-performance.html

That link should explain how gc works. In general high memory means you have too many objects open and garbage collection cannot close them. Not the other way around.

Based on the stats you have provided it looks like as your app does more processing it needs more memory not allowing information to be removed.

0
Stephen C On

I suspect that the causal relationship is the other way around.

  • Your heap is getting too full.
  • That is causing the GC to run frequently.
  • That is causing the CPU usage to peak.

If this is the problem, you should be looking for what is causing your heap to get too full; e.g. look for memory leaks.