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!
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