简体   繁体   中英

Why the processes runs after error - java.lang.OutOfMemoryError: Requested array size exceeds VM limit?

We come across the error "java.lang.OutOfMemoryError: Requested array size exceeds VM limit" in the log files and also we observed other process also running after this error

  1. Why the server is not stopped and other process is also running after the above error?
  2. Does all the java.lang.OutOfMemoryError errors will block the entire application or not?
  3. Assume there are 10 threads out of which one thread got failed with OutofMemory error. In such a case will all the threads will be blocked or other 9 threads will continue the process

Example logger message:

example...(QuartzScheduler.java:2166) - Job (DEFAULT.jobLaunchStatusPoller threw an exception. org.quartz.SchedulerException: Job threw an unhandled exception. [See nested exception: java.lang.OutOfMemoryError: Requested array size exceeds VM limit] at org.quartz.core.JobRunShell.run(JobRunShell.java:210) at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:546) Caused by: java.lang.OutOfMemoryError: Requested array size exceeds VM limit [Mar 17 13:32:24] [3578814] WARN [PollingScheduler_Worker-19] (JobExecutor.java:54) - Job Execution Started.

Thanks.

The OutOfMemoryError means that JVM does not have enough space to allocate memory for a new object and the garbage collector can not give additional space. This error is thrown by the instruction causing the memory overflow but does not kill the thread. OutOfMemoryError is a throwable object that you can catch.

You should read some thread about how to configure your heapspace : Increase heap size in Java

the -XmX parameter when starting the VM, allows you to change the RAM allocated for the JVM.

java -XmX100G myClass 

However, be generous with the amount of memory yougive it, other processes may need it.

@Thomas gave nice response, but I dont agree with one thing.

According to Javadoc for Error class, you should never try to catch Error or any Subclass.

Make sure you will never end up here and IF YOU EXPECT ERROR = BAD DESIGN/ALGORITHM

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM