22

I got following error while run dbGetQuery of RJDBC 0.2-4:

Error in .jcall(rp, "I", "fetch", stride) :    
  java.lang.OutOfMemoryError: Java heap space

Following is my code:

Sys.setenv(JAVA_HOME='C:/Program Files (x86)/Java/jdk1.7.0_25')
options(java.parameters='-Xmx1g')
library(rJava)
library(rjson)
library(RJDBC)

# Output Java version
.jinit()
print(.jcall("java/lang/System", "S", "getProperty", "java.version"))

jdbcDriver <<- JDBC(driverClass="oracle.jdbc.OracleDriver", classPath="C:/lib/dashboard_lib/ojdbc6.jar")
jdbcConnection <<- dbConnect(jdbcDriver, "...", "...", "...")
dataset <<- dbGetQuery(jdbcConnection, "select * from OPR_DATA.MV_REG_CTRY_MS_QUARTER_AMT")

Can anyone help me with this, thanks very much in advance

1
  • 4
    Have you tired to make increase the memory to 4g instead of 1g. I mean set options for the java parameters to be -Xmx4g instead of -Xmx1g Commented Oct 29, 2014 at 17:35

4 Answers 4

21

Simply change the java.parameters to 8GB before load RJDBC package:

options(java.parameters = "-Xmx8048m")
library("RJDBC")
Sign up to request clarification or add additional context in comments.

Comments

5

It would fail for me using:

options(java.parameters = "-Xmx8048m")
library("RJDBC")

However,

options(java.parameters = "-Xmx8g")
library("RJDBC")

worked.

Comments

4

You can increase the memory as below and restart your Rstudio and it worked for me.

memory.limit(size=10000000000024)

Comments

1

Commenting in case anyone else comes across this thread with the same error. Updating RJDBC (install.packages("RJDBC")) worked for me.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.