-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathakka-oom.sc
43 lines (34 loc) · 1021 Bytes
/
akka-oom.sc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import $ivy.`com.typesafe.akka::akka-http:10.1.1`
import $ivy.`com.typesafe.akka::akka-stream:2.5.12`
import akka.actor.Actor
import akka.actor.ActorSystem
import akka.actor.Props
import sys.process._
import java.io.File
import ammonite.ops._, ImplicitWd._
import scala.util.Random
import scala.concurrent.duration._
import scala.concurrent.ExecutionContext.Implicits.global
case object Produce
class Parent extends Actor {
override def receive: Receive = {
case Produce =>
val child = context.system.actorOf(Props[Child])
child ! Produce
}
}
class Child extends Actor {
val data = new Array[Byte](2000000)
override def receive: Receive = {
case Produce =>
Random.nextBytes(data)
}
}
@main
def main() = {
val actorSystem = ActorSystem()
val actor = actorSystem.actorOf(Props[Parent])
actorSystem.scheduler.schedule(2 seconds, 500 millis, actor, Produce)
Console.println("Press enter")
Console.readLine() //I need a few seconds to attach VisualVM to the process ;)
}