How to deal with java.lang.OutOfMemoryError
First, when java.lang.OutOfMemoryError error thrown? - when there is insufficient space to allocate an object in the Java heap - when there is insufficient native memory to support the loading of a Java class - when an excessive amount of time is being spent doing garbage collection and little memory is being freed Check, Was it thrown - because the Java heap is full? - because the native heap is full? Particularly, investigate right after the full GC happen. - Mainly, it's about allocation and reference. - Using profiler to check allocation and reference are on its purpose. - soft reference / weak reference Look into Code. - Estimate the size of memory needed in the application. - Evaluate how much you can reduce the amount of memory. - get the leak point. Rarely - increase max heap size - scale-up/out machine References - https://docs.oracle.com/javase/8/docs/technotes/guides/troubleshoot/memleaks002.html - https:/...