1

I know this issue has been visited several times, but I haven't found the solution to my problem:

I reserve 1024 MB for the virtual machine with

> options(java.parameters = "-Xmx1024m")
> library(XLConnect)

xlcMemoryReport finds only around 15 MB and xlcFreeMemory doesn't help (actually sometimes further reduces available memory)

> xlcMemoryReport()
Amount of free memory in the Java Virtual Machine (JVM): 14.79472 MB
> xlcFreeMemory()
> xlcMemoryReport()
Amount of free memory in the Java Virtual Machine (JVM): 15.05308 MB

when I try to load a 26 MB file it fails, but actually frees up the memory:

> res <- readWorksheet(loadWorkbook("bigFile.xlsx"),sheet=1)
error in evaluating the argument 'object' in selecting a method for function 'readWorksheet': Error: OutOfMemoryError (Java): Java heap space

> xlcMemoryReport()
Amount of free memory in the Java Virtual Machine (JVM): 947.3003 MB

> res <- readWorksheet(loadWorkbook("bigFile.xlsx"),sheet=1)
error in evaluating the argument 'object' in selecting a method for function 'readWorksheet': Error: OutOfMemoryError (Java): Java heap space

> xlcMemoryReport()
Amount of free memory in the Java Virtual Machine (JVM): 936.7464 MB

  1. Why xlcMemoryReport does not find the reserved memory at first but finds it after I try reading the file?
  2. Is it possible that >900 MB is not sufficient for XLConnect to load a 26 MB file?
  3. Any idea how I can make this work? (of course I could use CSV files, but that is an inconvenience for my users)
polTo
  • 290
  • 1
  • 4
  • 12
  • 1
    Welcome to SO. Connecting between R and Excel using the JVM seems to take a ridiculous amount of memory. See this other question for some tips. http://stackoverflow.com/questions/21937640/handling-java-lang-outofmemoryerror-when-writing-to-excel-from-r – Richie Cotton Mar 03 '14 at 11:30
  • 1
    Thank you! Followed the links carefully again and found a suggestion for a workaround (http://r.789695.n4.nabble.com/Problem-with-xlsx-package-td3298470.html): SAVE AS .xls. – polTo Mar 03 '14 at 12:02
  • Ive had the out of memory problem several times now as Ubuntu updates Java or the package rJava is updated. Your options() solution has worked for me as has the unlim -c unlimited command in the shell. But Im done chasing this problem. Ive migrated to openxlsx, which drops any dependence on Java and relies instead on C++. Ive never looked back. – Brad Horn Sep 08 '15 at 06:54

0 Answers0