OutOfMemoryError
Error cause: java.lang.outofmemoryerror: Java heap space heap memory overflow
solution: adjust the size of the heap memory
// -Xms1m -Xmx10m -XX:+PrintGCDetails
List<Object> listObject = new ArrayList<>();
for (int i = 0; i < 10; i++) {
System.out.println("i:" + i);
Byte[] bytes = new Byte[1 * 1024 * 1024];
listObject.add(bytes);
}
System.out.println("Added successfully...");
StackOverflowError
Cause of error: java.lang.stackoverflowerror is expressed as stack overflow, which generally occurs in recursive calls
solution: set the maximum thread call depth, which is 1m by default
//-Xss5m Set the maximum call depth
public class StackTest {
private static int count;
public static void count(){
try {
count++;
count();
} catch (Throwable e) {
System.out.println("the maximum depth:"+count);
e.printStackTrace();
}
}
public static void main(String[] args) {
count();
}
}
Read More:
- How to Solve Errors encountered by maven
- [Solved] Error launching IDEA: Failed to create JVM. JVM Path…
- [Solved] IntelliJ IDEA Start Error: Failed to create JVM.JVM Path
- [JVM] stack overflow error stackoverflowerror [How to Solve]
- [Solved] Initialization of anonymous inner class member variable causes java.lang.stackoverflowerror
- How to Solve Error: No suitable driver found for
- kakfa Create topic Error: java.util.concurrent.ExecutionException: org.apache.kafka.common.errors.InvalidReplicationFactorException: Replication factor: 3 larger than available brokers: 2.
- [Solved] Method threw ‘java.lang.StackOverflowError‘ exception. Cannot evaluate
- [Solved] java.Lang.outofmemoryerror: wrappedjavafileobject
- How to Solve IBM MQ Connect Error Code 2035
- How to Solve Junit Unit Test Error: “No runnable methods“
- Java.lang.stackoverflowerror error [How to Solve]
- How to Solve JUnit Debugging initializationerror ERROR
- How to Solve Flick operate Error: not serialized
- Error:java: OutOfMemoryError: insufficient memory [How to Solve]
- [Solved] IDEA startup Error: Java lang.StackOverflowError
- How to Solve Mockito mockedStatic NotAMockException Error
- How to Solve Springboot Upload Files Error: The field XXX exceeds its maximum permitted size of 1048576 bytes
- How to Solve classnotfoundexception error in spark without Hadoop runtime
- [Solved] Hibernate Error: java.lang.StackOverflowError at java.lang.Integer.toString(Integer.java:402)