title: R - Decreasing memory usage of using caret to train a random forest
body: <p>I am trying to create a random forest given ~100 thousand inputs. To accomplish them, I am using <code>train</code> from the caret package with <code>method = "parRF"</code>. Unfortunately, my machine with 128 GBs of memory still runs out. Therefore, I need to cut down on how much memory I use.</p>
  
  <p>Right now, the training method I am running is:</p>
  
  <pre><code>&gt; trControl &lt;- trainControl(method = "LGOCV", p = 0.9, savePredictions = T)
  &gt; model_parrf &lt;- train(x = data_preds, y = data_resp, method = "parRF",
                       trControl = trControl)
  </code></pre>
  
  <p>However, because each forest is kept, the system quickly runs out of memory. If my understanding of <code>train</code> and <code>randomForest</code> is correct, each random forest made stores about <code>500 * 100,000</code> doubles at the very least. Therefore, I would like to throw away the random forests I no longer need. I tried passing the <code>keep.forest = FALSE</code> into <code>randomForest</code> using</p>
  
  <pre><code>&gt; model_parrf &lt;- train(x = data_preds, y = data_resp, method = "parRF",
                         trControl = trControl, keep.forest = FALSE)
  Error in train.default(x = data_preds, y = data_resp, method = "parRF",  : 
    final tuning parameters could not be determined
  </code></pre>
  
  <p>In addition, this warning was thrown repeatedly:</p>
  
  <pre><code>In eval(expr, envir, enclos) :
    predictions failed for Resample01: mtry=2 Error in predict.randomForest(modelFit, newdata) : 
    No forest component in the object
  </code></pre>
  
  <p>It seems that for some reason, caret requires the forests to be kept in order to compare models. Is there any way I can use caret with less memory?</p>