From c48953cbe1be1f2881c9623ab751741ad17787bb Mon Sep 17 00:00:00 2001 From: Iulian Dragos Date: Wed, 6 Jul 2011 09:09:13 +0000 Subject: Don't populate 'originalOwner' in presentation ... Don't populate 'originalOwner' in presentation compiler runs. This is a source of memory leaks, as the map is never cleared. A better, more consistent mechanism should be developed for such maps, and ensure they are cleared on a new Run, or in resetTyper. no review. --- src/compiler/scala/reflect/internal/Required.scala | 4 ++++ src/compiler/scala/reflect/internal/Symbols.scala | 14 ++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/compiler/scala/reflect/internal/Required.scala b/src/compiler/scala/reflect/internal/Required.scala index 73b739a319..d1501c29c2 100644 --- a/src/compiler/scala/reflect/internal/Required.scala +++ b/src/compiler/scala/reflect/internal/Required.scala @@ -14,4 +14,8 @@ trait Required { self: SymbolTable => val gen: TreeGen { val global: Required.this.type } def settings: MutableSettings + + def forInteractive: Boolean + + def forScaladoc: Boolean } diff --git a/src/compiler/scala/reflect/internal/Symbols.scala b/src/compiler/scala/reflect/internal/Symbols.scala index 141c197a22..8704eb4bec 100644 --- a/src/compiler/scala/reflect/internal/Symbols.scala +++ b/src/compiler/scala/reflect/internal/Symbols.scala @@ -587,8 +587,13 @@ trait Symbols /* extends reflect.generic.Symbols*/ { self: SymbolTable => def owner: Symbol = rawowner final def owner_=(owner: Symbol) { - if (originalOwner contains this) () - else originalOwner(this) = rawowner + // don't keep the original owner in presentation compiler runs + // (the map will grow indefinitely, and the only use case is the + // backend). + if (!forInteractive) { + if (originalOwner contains this) () + else originalOwner(this) = rawowner + } rawowner = owner } @@ -1319,8 +1324,13 @@ trait Symbols /* extends reflect.generic.Symbols*/ { self: SymbolTable => /** Return the original enclosing method of this symbol. It should return * the same thing as enclMethod when called before lambda lift, * but it preserves the original nesting when called afterwards. + * + * @note This method is NOT available in the presentation compiler run. The + * originalOwner map is not populated for memory considerations (the symbol + * may hang on to lazy types and in turn to whole (outdated) compilation units. */ def originalEnclosingMethod: Symbol = { + assert(!forInteractive, "originalOwner is not kept in presentation compiler runs.") if (isMethod) this else { val owner = originalOwner.getOrElse(this, rawowner) -- cgit v1.2.3