[R] JRI memory leak?

andzsin andzsinszan at gmail.com
Thu Jun 18 11:16:14 CEST 2009


Dear List,

R     2.8.0
JRI   0.4-1
OS  WinXP Pro
Java  1.6

I am calling R from Java through JRI.
My process runs an iteration endlessly, and (supposedly) cleans  up
after each turn :

   rm(list=ls(all=TRUE)
   gc(reset=TRUE)

In Java:

   rengine.eval("rm(list=ls(all=TRUE)); gc(reset=TRUE)");

Still, memory.size() keeps increasing:

iter 820 mem: 13.168 MB
iter 840 mem: 13.362 MB
iter 860 mem: 13.046 MB
iter 880 mem: 13.211 MB
..
iter 15380 mem: 78.125 MB

Btw, there is a nice linear correlation between iterationN and
mem.size:

cor(iter,mem)
[1] 0.9936346

I also checked the number of objects by  length(ls()) which was zero
at the end of each iteration.
So rm() is OK, but not so gc().
In RGUI (using same R build) running a dummy iteration with gc()
worked OK (no leaks),  so I guess my problem is related to JRI.

Anyone with similar problems?

Perhaps time to upgrade JRI -> rJava ?

Best,

Gabor




More information about the R-help mailing list