Skip to content

Instantly share code, notes, and snippets.

@matsu-chara
Last active Aug 5, 2016
Embed
What would you like to do?
akkaのdispatcherでOOM
import akka.actor.{Actor, ActorSystem, Props}
import scala.concurrent.{blocking, Future}
object OOM extends App {
val system = ActorSystem()
val actor = system.actorOf(Props[OOMActor])
(1 to 10000).foreach(actor ! _)
Thread.sleep(10000)
system.terminate()
}
class OOMActor extends Actor {
override def receive: Receive = { case i => Future(blocking(Thread.sleep(1000)))(context.dispatcher) }
}
name := """akka-sandbox"""
version := "1.0"
scalaVersion := "2.11.8"
lazy val akkaVersion = "2.4.8"
libraryDependencies ++= Seq(
"com.typesafe.akka" %% "akka-actor" % akkaVersion
)
javaOptions += "-Xmx1G"
javaOptions += "-Xms1G"
Uncaught error from thread [default-akka.actor.default-dispatcher-2028] shutting down JVM since 'akka.jvm-exit-on-fatal-error' is enabled for ActorSystem[default]
java.lang.OutOfMemoryError: unable to create new native thread
at java.lang.Thread.start0(Native Method)
at java.lang.Thread.start(Thread.java:714)
at scala.concurrent.forkjoin.ForkJoinPool.tryCompensate(ForkJoinPool.java:2343)
at scala.concurrent.forkjoin.ForkJoinPool.managedBlock(ForkJoinPool.java:3638)
at akka.dispatch.MonitorableThreadFactory$AkkaForkJoinWorkerThread.blockOn(ThreadPoolBuilder.scala:167)
at scala.concurrent.package$.blocking(package.scala:123)
at OOMActor$$anonfun$receive$1$$anonfun$applyOrElse$1.apply$mcV$sp(OOM.scala:16)
at OOMActor$$anonfun$receive$1$$anonfun$applyOrElse$1.apply(OOM.scala:16)
at OOMActor$$anonfun$receive$1$$anonfun$applyOrElse$1.apply(OOM.scala:16)
at scala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1$1(Future.scala:24)
at scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:24)
at akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:40)
at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(AbstractDispatcher.scala:397)
at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment