flushAnalysisState method

Future<void> flushAnalysisState({
  1. bool elementModels = true,
})

Plugin implementations can use this method to flush the state of analysis, so reduce the used heap size, after performing a set of operations, e.g. in afterNewContextCollection or handleAffectedFiles.

The next analysis operation will be slower, because it will restore the state from the byte store cache, or recompute.

Implementation

Future<void> flushAnalysisState({
  bool elementModels = true,
}) async {
  var contextCollection = _contextCollection;
  if (contextCollection != null) {
    for (var analysisContext in contextCollection.contexts) {
      if (elementModels) {
        analysisContext.driver.clearLibraryContext();
      }
    }
  }
}