summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIulian Dragos <jaguarul@gmail.com>2011-07-06 09:09:13 +0000
committerIulian Dragos <jaguarul@gmail.com>2011-07-06 09:09:13 +0000
commitc48953cbe1be1f2881c9623ab751741ad17787bb (patch)
tree0d098e3ea95152f335aaea18c7b5f5887c00c979 /src
parent0bfef306966569816bce407df619de275bd199bc (diff)
downloadscala-c48953cbe1be1f2881c9623ab751741ad17787bb.tar.gz
scala-c48953cbe1be1f2881c9623ab751741ad17787bb.tar.bz2
scala-c48953cbe1be1f2881c9623ab751741ad17787bb.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/reflect/internal/Required.scala4
-rw-r--r--src/compiler/scala/reflect/internal/Symbols.scala14
2 files changed, 16 insertions, 2 deletions
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)