diff options
author | Eugene Burmako <xeno.by@gmail.com> | 2012-09-24 14:31:17 +0200 |
---|---|---|
committer | Eugene Burmako <xeno.by@gmail.com> | 2012-09-27 13:48:30 +0200 |
commit | 8c7d94ef9eea927088392fd2d0e6bb37f0641ad5 (patch) | |
tree | 7633ea75b2148d4c6783224f91c7a9ba7caa31e9 /test | |
parent | cf08f25d598a1d44ed4440b1cc1097a5869aefdd (diff) | |
download | scala-8c7d94ef9eea927088392fd2d0e6bb37f0641ad5.tar.gz scala-8c7d94ef9eea927088392fd2d0e6bb37f0641ad5.tar.bz2 scala-8c7d94ef9eea927088392fd2d0e6bb37f0641ad5.zip |
SI-6412 alleviates leaks in toolboxes, attempt #2
Turns importer caches into fully weak hash maps, and also applies
manual cleanup to toolboxes every time they are used.
It's not enough, because reflection-mem-typecheck test is still leaking
at a rate of ~100kb per typecheck, but it's much better than it was before.
We'll fix the rest later, after 2.10.0-final.
For more information, see https://issues.scala-lang.org/browse/SI-6412 and
http://groups.google.com/group/scala-internals/browse_thread/thread/eabcf3d406dab8b2
In comparison with https://github.com/scala/scala/commit/b403c1d,
the original commit that implemented the fix, this one doesn't crash tests.
The problem with the original commit was that it called tryFixup() before
updating the cache, leading to stack overflows.
Diffstat (limited to 'test')
-rw-r--r-- | test/files/run/reflection-mem-typecheck.scala | 26 | ||||
-rw-r--r-- | test/pending/run/reflection-mem-eval.scala | 26 |
2 files changed, 52 insertions, 0 deletions
diff --git a/test/files/run/reflection-mem-typecheck.scala b/test/files/run/reflection-mem-typecheck.scala new file mode 100644 index 0000000000..a312c2c893 --- /dev/null +++ b/test/files/run/reflection-mem-typecheck.scala @@ -0,0 +1,26 @@ +import scala.tools.partest.MemoryTest + +trait A { type T <: A } +trait B { type T <: B } + +object Test extends MemoryTest { + lazy val tb = { + import scala.reflect.runtime.universe._ + import scala.reflect.runtime.{currentMirror => cm} + import scala.tools.reflect.ToolBox + cm.mkToolBox() + } + + override def maxDelta = 10 + override def calcsPerIter = 8 + override def calc() { + var snippet = """ + trait A { type T <: A } + trait B { type T <: B } + def foo[T](x: List[T]) = x + foo(List(new A {}, new B {})) + """.trim + snippet = snippet + "\n" + (List.fill(50)(snippet.split("\n").last) mkString "\n") + tb.typeCheck(tb.parse(snippet)) + } +}
\ No newline at end of file diff --git a/test/pending/run/reflection-mem-eval.scala b/test/pending/run/reflection-mem-eval.scala new file mode 100644 index 0000000000..9045c44cd6 --- /dev/null +++ b/test/pending/run/reflection-mem-eval.scala @@ -0,0 +1,26 @@ +import scala.tools.partest.MemoryTest + +trait A { type T <: A } +trait B { type T <: B } + +object Test extends MemoryTest { + lazy val tb = { + import scala.reflect.runtime.universe._ + import scala.reflect.runtime.{currentMirror => cm} + import scala.tools.reflect.ToolBox + cm.mkToolBox() + } + + override def maxDelta = 10 + override def calcsPerIter = 3 + override def calc() { + var snippet = """ + trait A { type T <: A } + trait B { type T <: B } + def foo[T](x: List[T]) = x + foo(List(new A {}, new B {})) + """.trim + snippet = snippet + "\n" + (List.fill(50)(snippet.split("\n").last) mkString "\n") + tb.eval(tb.parse(snippet)) + } +}
\ No newline at end of file |