diff options
author | Eugene Burmako <xeno.by@gmail.com> | 2012-09-23 18:58:50 +0200 |
---|---|---|
committer | Eugene Burmako <xeno.by@gmail.com> | 2012-09-24 14:28:58 +0200 |
commit | 291d1f033a790e97298210de29f09a9796406ae3 (patch) | |
tree | 4e3e6d564f1e3c7877fa512d867389eddc2fab16 /src/partest | |
parent | 6ba05fdf09e8ff81dda1b946d9f89b2bba9ad33b (diff) | |
download | scala-291d1f033a790e97298210de29f09a9796406ae3.tar.gz scala-291d1f033a790e97298210de29f09a9796406ae3.tar.bz2 scala-291d1f033a790e97298210de29f09a9796406ae3.zip |
SI-6412 fixes leaks in Types.uniques
This is the most blatant leak in reflection. There are others, but their impact
is much smaller, therefore we'll fix them 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
Diffstat (limited to 'src/partest')
-rw-r--r-- | src/partest/scala/tools/partest/MemoryTest.scala | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/partest/scala/tools/partest/MemoryTest.scala b/src/partest/scala/tools/partest/MemoryTest.scala new file mode 100644 index 0000000000..58d25d2f01 --- /dev/null +++ b/src/partest/scala/tools/partest/MemoryTest.scala @@ -0,0 +1,38 @@ +package scala.tools.partest + +abstract class MemoryTest { + def maxDelta: Double + def calcsPerIter: Int + def calc(): Unit + + def main(args: Array[String]) { + val rt = Runtime.getRuntime() + def memUsage() = { + import java.lang.management._ + import scala.collection.JavaConverters._ + val pools = ManagementFactory.getMemoryPoolMXBeans.asScala + pools.map(_.getUsage.getUsed).sum / 1000000d + } + + val history = scala.collection.mutable.ListBuffer[Double]() + def stressTestIter() = { + var i = 0 + while (i < calcsPerIter) { calc(); i += 1 } + 1 to 5 foreach (_ => rt.gc()) + history += memUsage + } + + 1 to 5 foreach (_ => stressTestIter()) + val reference = memUsage() + 1 to 5 foreach (_ => stressTestIter()) + 1 to 5 foreach (_ => rt.gc()) + val result = memUsage() + history += result + + val delta = result - reference + if (delta > maxDelta) { + println("FAILED") + history foreach (mb => println(mb + " Mb")) + } + } +} |