2

I am attempting to make use of the Stanford NLP tools (Java) in R, using the rJava package. When attempting to create a StanfordCoreNLP object I get the following error:

Error in .jnew("edu/stanford/nlp/pipeline/StanfordCoreNLP", props) : java.lang.OutOfMemoryError: Java heap space

To resolve this, I have attempted to initialise the JVM with a larger maximum heap size, using variations of the following code:

.jinit(parameters=c("-Xms1g","-Xmx4g"))

When the maximum heap is set to 1GB using -Xmx1g the JVM loads but I continue to get the OutOfMemoryError. When the maximum heap size is set to 2 or 3 GB (-Xmx2g or -Xmx3g), R will stop responding. When set to 4GB or higher -Xmx4g I will get the following message:

Error in .jinit(parameters = c("-Xms1g", "-Xmx4g"), force.init = TRUE) : Cannot create Java virtual machine (-6)

How do you successfully initialise the JVM using rJava to values larger than 1GB? I am using 32bit versions of Java (v8 u51) and R (v3.2.0)

littlefeltfangs
  • 396
  • 2
  • 17

1 Answers1

0

I am using 32bit versions of Java (v8 u51) and R (v3.2.0)

That's your problem right there. Switch to 64bit versions.

the8472
  • 40,999
  • 5
  • 70
  • 122
  • 1
    Okay, having read a bit more on the subject you are quite right (nice summary in this question: [link](http://stackoverflow.com/questions/1434779/maximum-java-heap-size-of-a-32-bit-jvm-on-a-64-bit-os)). Frustratingly this will probably need another question, as I am using the 32bit version in the first place due to needing to access a database which only has 32bit ODBC drivers, where all the advice is "just use the 32bit version". – littlefeltfangs Jul 27 '15 at 08:20
  • I'm in the same situation as @littlefeltfangs where I don't have a choice to use 64 bit and it's very frustrating not to have any solution within 32bit version – CaffeineConnoisseur Jul 06 '16 at 20:49