I use R
(version 3.0.2) on a Ubuntu 64bit (14.04) and the package read.xlsx
to read several xlsx sheets. I do it like this:
options(java.parameters = "-Xmx4g" )
require(xlsx)
d1 = read.xlsx2(file, sheetName=sheet.1)
d2 = read.xlsx2(file, sheetName=sheet.2)
d3 = read.xlsx2(file, sheetName=sheet.3)
This works principally, but R
need more ad more memory and when it starts swapping it doesn't terminate in a appropriate time. I think the problem is that the memory used to read the xlsx files is not freed after the function terminated, because even if I remove all data (remove(d1)
, ...) the memory is still occupied. I tried to find any old objects used by read.xlsx
using ls()
but there are no temporary objects...
A solution which works is to read files until the memory is full. Then save the workspace, close R
, reopen R
and load the saved workspace. But this is certainly not the best solution! Hence, the actual question: how can I force read.xlsx
to free the memory (and kill subprocesses) after it finished?