3

After full gc happens, we may want to know how it happens. Without heap dump, I think it is hard to do, but in production environment, we usually can't get it in time. So I want to use HeapDumpBeforeFullGC in my application when it runs online.

My question is should HeapDumpBeforeFullGC be used in product environment? Will it bring some bad effects(if we don't consider disk usage)? Or do we have other effective way to find what cause full gc in production environment?

Thanks!

gatesking
  • 43
  • 5
  • Do you have problems with full GCs occuring and trouble diagnosing them? – the8472 Jul 03 '18 at 18:16
  • Yes, and these problems are hard to reproduce in test environment. So I want a way to diagnosing them. – gatesking Jul 04 '18 at 01:46
  • Well, it does not only take disk space, it takes time to make. And remember the old saying, “if it isn’t broken, don’t try to fix it”. Only use that option when you suppose that there actually is a problem. – Holger Jul 04 '18 at 07:26
  • @Holger That means when full gc happens, we can only try to reproduce it in test environment? Do you have any sugguestion to deal with this? I want a more effective way to find how full gc happens. Thanks! – gatesking Jul 04 '18 at 07:47
  • No, when you know there is a problem, which can only be reproduced in production environment, I’d say, there is no way around using that option in production environment, until you have gathered enough information. It will bring some “bad effects” and you know precisely which, hence, you are able to decide whether solving the problem is worth accepting the bad effects for some time. – Holger Jul 04 '18 at 08:07

1 Answers1

3

If you consider a full GC a problem in production then yes, adding a heap dump may help. But it will make the pause times on a full GC even worse.

As alternatives you can turn on detailed GC logging which are often a good start to identify the general cause (insufficient heap size, leaks, allocation spikes, misconfiguration, swapping, ...). You can also use less invasive profilers (e.g. async-profiler or jmc) to spot excessive allocations

the8472
  • 40,999
  • 5
  • 70
  • 122