Reputation: 3614
I'm iterating over a large data set, with regular calls to play.mvc.Results.Chunks.Out.write(...)
from within onReady
.
Because writes happen faster than data is sent to the client, I'll often run out of memory after a while... So what's the proper way to do this?
Upvotes: 4
Views: 454
Reputation: 3251
Unfortunately this is a limitation of Play's Java API in Play at the moment. There is no way in the Java API to get back pressure from the client, so it's easy to overwhelm the client. This will be fixed in Play 3 when we provide a better streams API to Java clients, probably based on Akka Streams.
If you really need to solve this problem then you may be able to write a small program in Scala based on Play's Enumerators and then wrap it so you can access it from your Java program.
Upvotes: 3