Search code examples
javarexcelxlsx

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


The title really says it all. I'm trying to write a df with dimensions 49947x13 to an excel file and it's failing with the following error.

> write.xlsx(combined_data, 
+            paste0("data/processed/combined_data/",id,"/",id,"_",timepoint,"_full.xlsx"))
Error in .jcall("RJavaTools", "Ljava/lang/Object;", "invokeMethod", cl,  : 
  java.lang.OutOfMemoryError: Java heap space

R is running in a Ubuntu 20 VM and has more than enough RAM. enter image description here


Solution

  • Temporary solution was to use the writexl library instead

    writexl::write_xlsx(combined_data, 
                        path = paste0("data/processed/combined_data/",id,"/",id,"_",timepoint,"_full.xlsx"))
    

    No problems.