OutOfMemoryError 应该catch吗?

来源:互联网 发布:宝宝起名取名软件 编辑:程序博客网 时间:2024/05/21 10:53

see: http://stackoverflow.com/questions/2679330/catching-java-lang-outofmemoryerror

There are a number of scenarios where you may wish to catch an OutOfMemoryError and in my experience (on Windows and Solaris JVMs), only very infrequently is OutOfMemoryError the death-knell to a JVM.

There is only one good reason to catch an OutOfMemoryError and that is to close down gracefully, cleanly releasing resources and logging the reason for the failure best you can (if it is still possible to do so).

0 1
原创粉丝点击