My JVM-based app runs on Amazon ECS. Under some conditions that I cannot reproduce on test environments it crashes with an OutOfMemoryError. I want to capture the JVM heap dump (using HeapDumpOnOutOfMemoryError
) to see what's going on. But there is a problem - because my app uses a lot of memory, the heap dumping takes very long time and ECS kills the container in the middle of it, because the health checks fail. I end up with an unusable, truncated dump file.
I can obtain a correct heap dump by changing the health-check configuration but it potentially affects the ECS service, because without good health-check the cluster can be running unresponsive instances.
I'm looking for a way, that will let me capture the heap dumps automatically with smallest possible impact to the production cluster.