concurrent.futures - Scala Future does not return anything when allocating too much memory -


using scala-ide 3.0.3 (based on scala 2.10.4), following code completes correctly displaying first 10 values of computed list future future completedmessage:

import scala.concurrent._ import scala.concurrent.duration._ import scala.util.{failure, success} import executioncontext.implicits.global  object futurenonblocking extends app {      val f1: future[list[int]] = future {         val t = list.range(1, 50).filter(_ % 2 == 0)         println("done")         t     }      f1.oncomplete {         case success(value) => println(value.take(10))         case failure(e) => println("something bad happened")     }      await.complete(f1, 30 seconds) } 

however, changing range list.range(1, 50) list.range(1, 5000) not display , (the failure not triggered). logically, seems related memory issue don't understand happening there.

even stranger, running code in repl not cause issue. missing there?

it turns out whole thing not issue memory management in futures related way eclipse handles console output concurrent programs.

adding thread.sleep(1000) @ end of program let eclipse show console output, solving problem.

thank @jilen helpful comment!


Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -