bartMachine builds up memory usage when executed repeatedly

127 Views Asked by At

I have made the observation that bartMachine in R builds up memory usage when executed repeatedly. To illustrate:

options(java.parameters = "-Xmx8g")
library(bartMachine)

data(iris)
iris2 = iris[51:150,]
iris2$Species = factor(iris2$Species)

#build BART classification model
set_bart_machine_num_cores(4)
do.bart = function(){
for(i in 1:30){
bart_machine = build_bart_machine(iris2[ ,1:4], iris2$Species)
}
}

do.bart()

The first run will only use around 100MB, later runs several 100s, and even later round 1-2 Gb (on my machine). It seems that somehow the memory is not emptied between runs. At some point (in other applications) this causes the memory to overflow the memory reserved.

Is there anything one can do about this, like emptying the memory between repeated runs? Of course one can restart the R session but this measure seems to extreme and is not very practical.

0

There are 0 best solutions below