How can we resolve java lang OutOfMemoryError in Java

+1 vote
When I am trying to run my code, I am getting java.lang.OutOfMemoryError. How to solve this?
Jun 5, 2018 in Java by Daisy
• 8,140 points
• 2,622 views

1 answer to this question.

0 votes
  1. Work with smaller batches of HashMap Objects to process at once if possible.
  2. Use the HashMap(int initialCapacity, float loadFactor) constructor.
  3. Specify more memory like you mentioned , try something in between like -Xmx512m.
answered Jun 5, 2018 by sharth
• 3,370 points

Related Questions In Java

0 votes
4 answers

How can we compare dates in java?

public static String daysBetween(String day1, String day2) ...READ MORE

answered Sep 5, 2018 in Java by Sushmita
• 6,920 points
• 3,748 views
0 votes
1 answer

How can we get file extension in Java?

In Java, you can find the file ...READ MORE

answered Apr 3, 2024 in Java by kevin

edited Mar 5, 2025 • 4,988 views
0 votes
2 answers

How can I solve java.lang.NoClassDefFoundError in Java?

NoClassDefFoundError means that the class is present ...READ MORE

answered Sep 11, 2018 in Java by Sushmita
• 6,920 points
• 36,616 views
0 votes
2 answers

How can we remove an element from an array in Java?

You can use ArrayUtils class remove method ...READ MORE

answered May 24, 2018 in Java by UshaK
• 4,578 views
0 votes
1 answer

What is ArrayIndexOutOfBoundsException ?

If You check System.out.print(names.length); you will get 3 ...READ MORE

answered May 11, 2018 in Java by sharth
• 3,370 points
• 2,688 views
0 votes
1 answer

How can we resolve ClassNotFoundException in Java?

Your classpath is broken. Depending on how you ...READ MORE

answered May 22, 2018 in Java by Akrati
• 3,190 points
• 3,158 views
0 votes
1 answer

java.lang.OutOfMemoryError: GC overhead limit exceeded Error

This simply means that for some reason ...READ MORE

answered May 31, 2018 in Java by misc.edu04
• 1,450 points
• 5,983 views
0 votes
1 answer

How to resolve the java.net.ConnectException in Java?

If you are getting java.net.ConnectionException, it means ...READ MORE

answered Jun 4, 2018 in Java by Akrati
• 3,190 points
• 3,971 views
0 votes
6 answers

How can we define global variables in java?

To define Global Variable you can make ...READ MORE

answered Dec 15, 2020 in Java by Gitika
• 65,730 points
• 124,036 views
0 votes
3 answers

How can we use java.String.format in Scala?

String aString = "world"; int aInt = 20; String.format("Hello, ...READ MORE

answered Aug 29, 2018 in Java by Daisy
• 8,140 points
• 4,063 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP