I suspect in my application that an outofmemoryerror is causing a a run() to exit, however because there were no logs, the error wasn't visible.
What should i do in this case?
I suspect in my application that an outofmemoryerror is causing a a run() to exit, however because there were no logs, the error wasn't visible.
What should i do in this case?
You should run your JVM with this flag: -XX:+HeapDumpOnOutOfMemoryError
to see whats happening inside the JVM while the OOM happens. This will write a HPROF file, which you can analyze with a profiler, Eclipse MAT is a good one for this. Use -XX:HeapDumpPath=/tmp
to configure the path where to write the HPROF to.
I don't know about others, but never (IMHO) catch
or throws
anything that extends Error
. The followig statement from the javadoc states:
A method is not required to declare in its throws clause any subclasses of Error that might be thrown during the execution of the method but not caught, since these errors are abnormal conditions that should never occur.
An Error
is printed with System.err
and if you want to avoid OutofMemoryException
, increase your heapsace instead.