Avatar ·

java.lang.OutOfMemoryError: GC overhead limit exceeded — what to do?

Hello everyone! I am a beginner Java developer writing a small application for log processing. The program reads a large text file (about 500 MB), splits lines into words, and collects statistics — how many times each word occurs. I use HashMap. Everything worked fine on small files, but when I ran it on real data, after a couple of minutes an error occurred: Exception in thread "main" java.lang.OutOfMemoryError: GC overhead limit exceeded Here is the simplified code: ```java public class LogAnalyzer { public static void main(String[] args) throws IOException { Map wordCount = new HashMap<>(); BufferedReader reader = new BufferedReader(new FileReader("large_log.txt")); String line; while ((line = reader.readLine()) != null) { String[] words = line.split("\\s+"); for (String word : words) { wordCount.merge(word, 1, Integer::sum); } } } }