Search code examples
rgarbage-collectionrjavar-xlsx

GC overhead error using xlsx


I am trying to read xlsx files in R using the xlsx library. Below is my piece of code.

options(java.parameters = "-Xmx8g")
data <- read.xlsx("data.xlsx",
                  header = FALSE, sheetName="Sheet1")

It throws the following error

Error in .jcall("RJavaTools", "Ljava/lang/Object;", "invokeMethod", cl, : java.lang.OutOfMemoryError: GC overhead limit exceeded

I have tried different method to increase java heap memory, but could not succeed. I am using java8 at ubuntu. The file size is 4MB only. I have followed different instructions at similar questions on different forums but could not succeed.

Any suggestions will be appreciated.


Solution

  • Try readxl, which AFAIK is one of the most efficient ways to read Excel files in R.