MemoryError in R while read.xlsx

user1703914 picture user1703914 · Sep 27, 2012 · Viewed 21.4k times · Source

I am using the following R code (that utilizes the Java parameter to increase memory as well):

library(xlsx)
options(java.parameters = "-Xmx1g")
library(XLConnect)
NiVe <- read.xlsx("version1.xlsx",1)

The version1.xlsx file is 13 MB in size. I get the following error:

Error in .jcall("RJavaTools", "Ljava/lang/Object;", "invokeMethod", cl,  : 
  java.lang.OutOfMemoryError: Java heap space

Can someone help?

Answer

Chandra Sekhar picture Chandra Sekhar · Sep 27, 2012

Try to increase java Heap size(sufficient), by using:

options(java.parameters = "-Xmx1000m")

If you are using 32 bit R make sure you are also using 32 bit Java and if you re using 64 bit R make sure you are also using 64 bit Java. If you get a Java heap space message indicating that it is out of memory see this post.

this thread may help you, to use Garbage Collection.

Reference:
exchanging_data_between_r_and_ms_windows_apps_excel_etc
stats-rosuda-devel_001621