Java memory error when reading a small xlsx file

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Java memory error when reading a small xlsx file

miao
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]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Java memory error when reading a small xlsx file

jholtman
Try using the openxlsx package; it does not require Java.


Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.

On Sat, Apr 23, 2016 at 3:43 PM, jpm miao <[hidden email]> wrote:

> 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]]
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.