#jvm

Fix Java OutOfMemoryError

Problem: For a university project I had to implement a simple Java application that uses the Twitter4J Java library for the Twitter API to collect data (tweets) based on different criteria and then analyze those data and generate statistics. For the data analysis I used the natural language processing toolkit developed by Stanford (called Stanford CoreNLP). The problem was, that the data were too large and when running the NLP algorithms I encountered the OutOfMemoryError. Solution: increase the heap size of the Java virtual machine JVM using the flags -Xmx and -Xms. The flag Xmx specifies the maximum memory allocation pool for a (JVM), while Xms specifies the initial memory allocation pool. How to do this in Intellij? Open the "Run/Debug Configurations" of your application and in the field "VM options" add the flags -Xmx and -Xms with the desired memory amount (e.g. -Xms4g -Xmx8g).
Subscribe to #jvm