[R] Java memory error when reading a small xlsx file

jpm miao miaojpm at gmail.com
Sat Apr 23 21:43:14 CEST 2016


Hi,

   I tried to read a (small) xlsx file by "readWorksheetFromFile" function
of "XLConnect" package and "read.xlsx" function in "xlsx" package, but I
got this error message:

Error: OutOfMemoryError (Java): Java heap space

   I tried to follow the solution on the web
http://stackoverflow.com/questions/21937640/handling-java-lang-outofmemoryerror-when-writing-to-excel-from-r

   and I did add a line to my program
#######
options(java.parameters = "-Xmx8000m")
########
#or
########
options(java.parameters = "-Xmx1000m")
#######
   but it did not work.

   I wonder if I need to detach the packages before adding that line
########
detach("package:XLConnect", unload=TRUE)
detach("package:xlsx", unload=TRUE)
detach("package:xlsxjars", unload=TRUE)
detach("package:XLConnectJars", unload=TRUE)
detach("package:rJava", unload=TRUE)
options(java.parameters = "-Xmx8000m")
library(XLConnect)
library(xlsx)
#######
    but it did not work.

I am on a Mac, with very new OS and very new R version.

R version 3.2.4 (2016-03-10)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.11.3 (El Capitan)

    Could someone guide me how to solve the problem? Thanks!

Miao

	[[alternative HTML version deleted]]



More information about the R-help mailing list