문제

I know that -XX:+HeapDumpOnOutOfMemoryError will enable heap dump on OutOfMemoryError.

Is there anything similar for thread dump? I need this in case when error happens on server - I don't have access to process itself when it happens

도움이 되었습니까?

해결책

The exact point of execution where an OutOfMemoryError is raised is very much random (unless you have a single threaded application), so I don't think it would make too much sense to get a thread dump upon OOM. At least this is true if it's the 'Java heap space' sort of OOM, but probably for the other sorts of OOM errors as well.

Anyway, take a look at this older post addressing the same question.

However a better way to tackle an OOM error is to use the Eclipse Memory Analyzer Tool to inspect the heapdump. It helps you to identify memory leaks by transforming the object graph into a so-called dominator tree. This structure reveals the keep-alive dependencies among objects, so it becomes very easy to identify the ones responsible for retaining the biggest chunks of memory (see Shallow vs. Retained Heap).

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top