Java tries to grab memory

How good is the catch attempt at catching exceptions from memory? I have no experience writing software that low-level controls its own memory, but I could imagine an approach to this.

I don’t know how Java actually handles memory exceptions. Is it possible that there is not enough memory in the memory management program? When can I try to catch an exception in memory and fail to catch the exception?

Thank!

+3
source share
5 answers

How good is the catch attempt at catching exceptions from memory?

It works great on one level ... but on another level, it can be risky and / or useless. See below.

Is it possible that there is not enough memory in the memory management program?

"" . AFAIK, . , , , JVM.

?

JVM. , OOME , .


, / .

, OOME . , ( ) , "up stack", , . , , . ( - ? - ... ?)

, OOME Java... - "" , . OOME ... ... , - , OOME . , , OOME. ... , JVM , OOME ( ). .

, , OOME. , OOME, , , .

, , /, - OOME, .

+1

- , , . . JVM OOM , , , .

:

  • , , , , , OOM. , , JVM.
  • , , , (, LogRecord StringBuilder, ), .

, " "; "" . , , , , , , , 10 , .

+2

java Out Of Memory , . - , . , .

export JVM_ARGS="-Xmx1024m -XX:MaxPermSize=256m"
0

OutOfMemory - , . , , , , , .

You will only catch something, if you think that something can be done to recover from this error / exception, you cannot do anything to recover from OutOfMemory.

0
source


First of all, from memory Error in java, not an exception. We can only handle exceptions from java using the try-catch construct or the throws clause.

Both classes of errors and exceptions extend the Throwable class. But an error is a condition of irrevocability, and an exception is in manual mode.

For your situation, go to the Garbage Collection in java.

-4
source

All Articles