aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/SymbolLoaders.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-02-24 15:37:14 +0100
committerMartin Odersky <odersky@gmail.com>2014-02-24 18:56:48 +0100
commited7755b781bd1b444d38329cb22eacaa3fc1c005 (patch)
tree2eb43f71741310e77248111f5fa5c39203e33c8d /src/dotty/tools/dotc/core/SymbolLoaders.scala
parentcdeafeafd252b20a0df5440e0420211af95e0cdc (diff)
downloaddotty-ed7755b781bd1b444d38329cb22eacaa3fc1c005.tar.gz
dotty-ed7755b781bd1b444d38329cb22eacaa3fc1c005.tar.bz2
dotty-ed7755b781bd1b444d38329cb22eacaa3fc1c005.zip
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.
Diffstat (limited to 'src/dotty/tools/dotc/core/SymbolLoaders.scala')
-rw-r--r--src/dotty/tools/dotc/core/SymbolLoaders.scala7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/dotty/tools/dotc/core/SymbolLoaders.scala b/src/dotty/tools/dotc/core/SymbolLoaders.scala
index 6161d0e57..2484165f3 100644
--- a/src/dotty/tools/dotc/core/SymbolLoaders.scala
+++ b/src/dotty/tools/dotc/core/SymbolLoaders.scala
@@ -49,7 +49,7 @@ class SymbolLoaders {
modFlags: FlagSet = EmptyFlags, clsFlags: FlagSet = EmptyFlags, scope: Scope = EmptyScope)(implicit ctx: Context): Symbol = {
val module = ctx.newModuleSymbol(
owner, name.toTermName, modFlags, clsFlags,
- (modul, _) => completer.proxy withDecls newScope withSourceModule modul,
+ (module, _) => completer.proxy withDecls newScope withSourceModule (_ => module),
assocFile = completer.sourceFileOrNull)
enterNew(owner, module, completer, scope)
enterNew(owner, module.moduleClass, completer, scope)
@@ -142,8 +142,9 @@ class SymbolLoaders {
/** Load contents of a package
*/
- class PackageLoader(override val sourceModule: TermSymbol, classpath: ClassPath)
+ class PackageLoader(_sourceModule: TermSymbol, classpath: ClassPath)
extends SymbolLoader {
+ override def sourceModule(implicit ctx: Context) = _sourceModule
def description = "package loader " + classpath.name
private[core] val preDecls: MutableScope = newScope
@@ -242,7 +243,7 @@ class ClassfileLoader(val classfile: AbstractFile) extends SymbolLoader {
else
ctx.newModuleSymbol(
rootDenot.owner, rootDenot.name.toTermName, Synthetic, Synthetic,
- (module, _) => new NoCompleter() withDecls newScope withSourceModule module)
+ (module, _) => new NoCompleter() withDecls newScope withSourceModule (_ => module))
.moduleClass.denot.asClass
}
if (rootDenot is ModuleClass) (linkedDenot, rootDenot)