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

trincot
  • 317,000
  • 35
  • 244
  • 286
user3567601
  • 241
  • 1
  • 2
  • 4
  • 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` – mallet Oct 29 '14 at 17:35

4 Answers4

21

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

options(java.parameters = "-Xmx8048m")
library("RJDBC")
fc9.30
  • 2,293
  • 20
  • 19
5

It would fail for me using:

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

However,

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

worked.

Sam
  • 468
  • 8
  • 9
4

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

memory.limit(size=10000000000024)
msanford
  • 11,803
  • 11
  • 66
  • 93
Nages
  • 763
  • 1
  • 9
  • 12
0

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