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
OutOfMemoryError: Java heap space. 1) An easy way to solve OutOfMemoryError in java is to increase the maximum heap size by using JVM options "-Xmx512M", this will immediately solve your OutOfMemoryError.
The solution to fix this problem is to increase the heap space(Default value maybe 128 MB). We can customize the heap space by specifying the JVM parameters -Xmx and -XX: MaxPermSize.
OutOfMemoryError exception. Usually, this error is thrown when there is insufficient space to allocate an object in the Java heap. In this case, The garbage collector cannot make space available to accommodate a new object, and the heap cannot be expanded further.
Simply change the java.parameters to 8GB before load RJDBC package:
options(java.parameters = "-Xmx8048m")
library("RJDBC")
It would fail for me using:
options(java.parameters = "-Xmx8048m")
library("RJDBC")
However,
options(java.parameters = "-Xmx8g")
library("RJDBC")
worked.
You can increase the memory as below and restart your Rstudio and it worked for me.
memory.limit(size=10000000000024)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With