Catching OutOfMemoryError
in the path of all possible places where it occurs ... it's not really possible as it can occurs in any Java codes, and internally in the JVM.
When the JVM emits an OOME, sometimes it's recoverable but usually not, so catching it inside your will generally lead to nothing as the JVM will be unusable (it is in a state where it cannot allocate more memory so you cannot process any step in your program)
If you need to know whether or not your application generate OOME and a way to take action, you need to do this from an external point, the easiest way to do this is to use the standard way that the JVM offers you using some jvm starting option.
Usually, for dealing with OOME you use the following JVM starting options:
-XX:+HeapDumpOnOutOfMemoryError
tells the JVM to generate a heap dump on OOME so you can analyse it further (for example with Eclipse MAT: http://www.eclipse.org/mat/)
-XX:OnOutOfMemoryError="<cmd args>;<cmd args>"
tells the JVM to launch a command on the host in case of OOME. By this you can for example send an email and restart your server!
More informations on statup options ca be found here : http://docs.oracle.com/javase/8/docs/technotes/tools/unix/java.html