Java – capture outofmemoryerror

Is there any memory error (Java. Lang. outofmemoryerror) in Java?

Solution

Yes Here are several examples to illustrate this:

>If you want to handle it by closing the program normally > if you want to show the user a problem or log an error > according to your design, you can even clear the memory and return to work

However, please note that usually (unless you are in one place and you will allocate a large amount of memory at a time), you may not capture outofmemoryerror specifically for these situations, but capture throwable at your main entry point at the top

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>