Member-only story
The 6 most common OOM issues at work
Today, let’s talk about 6 scenarios where OOM issues occur in online services. I hope it will be helpful to you.
Heap memory OOM
Heap memory OOM is the most common type of OOM.
The exception information for heap memory OOM issues is as follows:
java.lang.OutOfMemoryError: Java heap space
This OOM is due to the maximum heap value in the JVM, which is no longer sufficient.
For example:
public class HeapOOMTest { public static void main(String[] args) {
List<HeapOOMTest> list = Lists.newArrayList();
while (true) {
list.add(new HeapOOMTest());
}
}
}
A list collection is created here, and objects are continuously added to it in an infinite loop.
Execution result:
A heap memory overflow occurred with java.lang. OutOfMemoryError: Java heap space.
Many times, when exporting a large amount of data from Excel at once and querying too much data at once in the program, this OOM problem may occur.
We must avoid this situation in our daily work.