He-Pin commented on issue #2412:
URL: https://github.com/apache/pekko/issues/2412#issuecomment-3475955597
The implementation is quite ok.
```test
"memory safe" in {
val count = new AtomicInteger(0)
Source(1 to 1000000)
.mapAsync(parallelism = 100) { _ =>
Future {
count.incrementAndGet()
new Array[Byte](100 * 1024)
}(system.dispatcher)
}
.map(x => {
println(s"More ${count.decrementAndGet()} elements need to be
processed")
if (count.get() > 100) {
throw new IllegalStateException("OOM likely occurred, too many
elements in flight")
}
x
})
.runWith(Sink.ignore)
.onComplete(_ => println("Completed without OOM"))(system.dispatcher)
}
```
You can see, it will never exceed 100
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]