XLConnect Java Virtual Machine out of memory error

2019-06-07 22:41发布

问题:

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)