In Eclipse IDE, if your program is consuming a lot of memory (loading big data) then it will throw java.lang.OutOfMemoryError: Java heap space issue.
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at java.util.HashMap.<init>(HashMap.java:209)
at java.util.LinkedHashMap.<init>(LinkedHashMap.java:181)
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at java.util.HashMap.<init>(HashMap.java:209)
at java.util.LinkedHashMap.<init>(LinkedHashMap.java:181)
1. Solution – VM arguments
On Eclipse menu, clicks
Run -> Run Configurations.., select the Java application you want to run, clicks on the Arguments tab, update the VM arguments with the following options-Xms<size> - Set initial Java heap size
-Xmx<size> - Set maximum Java heap size
For example, -Xms512M -Xmx1024M
If you still face the java.lang.outofmemoryerror gc overhead limit exceeded eclipse
Steps to Solve the above issue in Eclipse
On Eclipse menu, clicks
Run -> Run Configurations.., select the Java application you want to run, clicks on the Arguments tab, update the VM arguments with the following options
-Xms6144M -Xmx12288M
-XX:+UseG1GC
-XX:+UseStringDeduplication





















