Browse files

Fix SI-7130: Memory leaked caused by Statistics

As described in the ticket, we were leaking memory by holding reference
to Global through by-name argument that was captured by an instance of
a class stored in global HashMap `qs`.

The fix is simple: do not register quantities in HashMap unless statistics
is enabled. This way, if Statistics is disabled we do not store any

We still leak memory in case of statistics being enabled.
  • Loading branch information...
1 parent 466fc67 commit c8ab5b33b9d02c48b93b0ea6b7174e6057917614 @gkossakowski gkossakowski committed Feb 14, 2013
Showing with 1 addition and 1 deletion.
  1. +1 −1 src/reflect/scala/reflect/internal/util/Statistics.scala
@@ -109,7 +109,7 @@ quant)
* Quantities with non-empty prefix are printed in the statistics info.
trait Quantity {
- if (prefix.nonEmpty) {
+ if (enabled && prefix.nonEmpty) {
val key = s"${if (underlying != this) underlying.prefix else ""}/$prefix"
qs(key) = this

0 comments on commit c8ab5b3

Please sign in to comment.