The parallel collector will throw an OutOfMemoryError if too much time is being spent in garbage collection: if more than 98% of the total time is spent in garbage collection and less than 2% of the heap is recovered, an OutOfMemoryError will be thrown. This feature is designed to prevent applications from running for an extended period of time while making little or no progress because the heap is too small. If necessary, this feature can be disabled by adding the option
-XX:-UseGCOverheadLimit
to the command line.
Common solutions in this case are:
1) Optimize your code to use less memory and/or reuse objects instead of creating new ones thus reducing the number of times the garbage collector runs. If you create a lot temporary objects (e.g in a loop) you should try to reuse them.
2) Increase heap size using Xmx switch e.g.
-Xmx512m
3) Disable the error check using
-XX:-UseGCOverheadLimit
The third approach will only result in another kind of error messages – heap related java.lang.OutOfMemoryError.
No comments:
Post a Comment