From ed7755b781bd1b444d38329cb22eacaa3fc1c005 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Mon, 24 Feb 2014 15:37:14 +0100 Subject: Avoid memory leaks on repeated compilation. Several measures: 1. Invalidate classOfId and superIdOfClass in ContextBase after each run. These contain local classes that should become inaccessible. 2. Also clear implicitScope cache that maps types to their implicit scopes after each run. (not sure whether this is needed; it did show up in paths from root, but on second thought this might have been a gc-able cycle. 3. Avoid capturing contexts in lazy annotations. 4. Avoid capturing contexts in functions that compute souceModule and moduleClass 5. Avoid capturing contexts in Unpickler's postReadOp hook. --- src/dotty/tools/dotc/typer/Implicits.scala | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/dotty/tools/dotc/typer/Implicits.scala') diff --git a/src/dotty/tools/dotc/typer/Implicits.scala b/src/dotty/tools/dotc/typer/Implicits.scala index 7d03b1edf..008fe8966 100644 --- a/src/dotty/tools/dotc/typer/Implicits.scala +++ b/src/dotty/tools/dotc/typer/Implicits.scala @@ -347,6 +347,8 @@ trait ImplicitRunInfo { self: RunInfo => val useCount = new mutable.HashMap[TermRef, Int] { override def default(key: TermRef) = 0 } + + def clear() = implicitScopeCache.clear() } /** The implicit resolution part of type checking */ -- cgit v1.2.3