This repository was archived by the owner on Mar 29, 2020. It is now read-only.
This repository was archived by the owner on Mar 29, 2020. It is now read-only.
Closed
Description
When using a PinnedDispatcher the instrumentation starts accumulating a bunch of objects on the heap. It seems like if a PinnedDispatcher is shutdown there is some part of the instrumentation that keeps a reference to it and then if the same dispatcher is used again (looked up by name) then a new set of instruments are created. If you create/shutdown often enough you will see the leak.
This is a naive piece of code that can reproduce the issue:
import akka.actor.{Actor, ActorSystem, PoisonPill, Props}
import kamon.Kamon
import kamon.kamino.KaminoReporter
import kamon.prometheus.PrometheusReporter
import scala.concurrent.Future
object Hello extends App {
Kamon.addReporter(new PrometheusReporter())
Kamon.addReporter(new KaminoReporter())
val system = ActorSystem("test")
while(true) {
for(dispatcherID <- 1 to 5) {
val folk = system.actorOf(Props[ActorWithDispatcher].withDispatcher(s"custom-dispatcher-${dispatcherID}"))
folk ! "start"
}
Thread.sleep(2000)
}
}
class ActorWithDispatcher extends Actor {
override def receive: Receive = {
case "start" =>
implicit val ec = context.dispatcher
for (_ <- 1 to 2000) {
Future {
Thread.sleep(1)
}
}
}
}
With this configuration:
custom-dispatcher-1 {
type = "PinnedDispatcher"
executor = "thread-pool-executor"
throughput = 100
thread-pool-executor {
}
}
custom-dispatcher-2 {
type = "PinnedDispatcher"
executor = "thread-pool-executor"
throughput = 100
thread-pool-executor {
}
}
custom-dispatcher-3 {
type = "PinnedDispatcher"
executor = "thread-pool-executor"
throughput = 100
thread-pool-executor {
}
}
custom-dispatcher-4 {
type = "PinnedDispatcher"
executor = "thread-pool-executor"
throughput = 100
thread-pool-executor {
}
}
custom-dispatcher-5 {
type = "PinnedDispatcher"
executor = "thread-pool-executor"
throughput = 100
thread-pool-executor {
}
}
kamon.util.filters {
"akka.tracked-dispatcher" {
includes = ["**"]
}
}
kamon.metric.tick-interval = 1 second
kamon.environment.service = "thread-pool-tests"
Metadata
Metadata
Assignees
Labels
No labels