0

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.

tomka
  • 2,516
  • 7
  • 31
  • 45
  • While I have no experience with this package, but it would seem there's some calculations running in parallel. To do this, it probably spawns extra R sessions. Can you shut them down between runs (of `i`)? – Roman Luštrik May 30 '19 at 17:42
  • @RomanLuštrik `set_bart_machine_num_cores` defines the number of parallel sessions. I do not know how to explicitly shut them down though. – tomka May 30 '19 at 17:50

0 Answers0