close method

void close()

Free Runtime and Context. After dispose, the engine cannot be reopened. After close without dispose, the next evaluate recreates the engine.

Implementation

void close() {
  try {
    releaseHostCaches();
  } catch (_) {}
  final rt = _rt;
  if (rt == null) return;
  try {
    _executePendingJob();
  } catch (_) {}
  final referenceLeak = _freeContext(rt);
  _rt = null;
  localContext.clear();
  dartContext.clear();
  _needsInitialization = true;
  try {
    jsFreeRuntime(rt);
  } on String catch (e) {
    throw JSError(e);
  }
  if (referenceLeak != null) throw JSError(referenceLeak);
}