I wrote a list manipulation function in both F # and Scala to compare performance. To test this function, I need to initialize a list from 1 to 100000000.
F #:
let l = [1..100000000];;
Real: 00: 00: 32.954, CPU: 00: 00: 34.593, GC gen0: 1030, gen1: 520, gen2: 9
It works.
Scala: Scala -J-Xmx2G option
val l = (1 to 10000000).toList // works val l = (1 to 100000000).toList // no response long while and finally got java.lang.OutOfMemoryError: Java heap space
With 100,000,000 (100,000,000) unanswered for a long time (hour) from 75% to 90% of the processor load and 2 GB memory usage and finally java.lang.OutOfMemoryError: Java heap space.
Am I doing something wrong in Scala?
source share