How to handle outofmemoryerror in Java?
•
Java
See English answers > how to deal with "Java. Lang. outofmemoryerror: Java heap space" error (64MB heap size) 17
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space at java.util.Arrays.copyOfRange(UnkNown Source) at java.lang.String.<init>(UnkNown Source) at java.io.BufferedReader.readLine(UnkNown Source) at java.io.BufferedReader.readLine(UnkNown Source) at org.girs.TopicParser.dump(TopicParser.java:23) at org.girs.TopicParser.main(TopicParser.java:59)
What should I do?
Solution
Ideally, refactor your code to reduce memory For example, maybe you can stream output instead of keeping the entire content in memory
Alternatively, simply use the - Xmx option to provide more memory for the JVM
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码