为什么Scala并行集合有时会导致OutOfMemoryError? [英] Why do Scala parallel collections sometimes cause an OutOfMemoryError?

查看:235
本文介绍了为什么Scala并行集合有时会导致OutOfMemoryError?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这需要大约1秒

 (1到1000000).map(_ + 3)



虽然这会提供 java.lang.OutOfMemoryError:Java堆空间

 (1到1000000).par.map(_ + 3)

EDIT:



我有标准的scala 2.9.2配置。我在scala提示符下键入这个。在bash我可以看到[-n$ JAVA_OPTS] || JAVA_OPTS = - Xmx256M -Xms32M



我没有在我的环境中设置JAVA_OPTS。



<整数= 8MB,
创建列表两次= 16MB

解决方案

和到存储Parralel集合所需的内存。例如:

  scala> (1到1000000).par.map(_ + 3)

$ c> OutOfMemoryError 第三次尝试评估它,而

  scala> (1到1000000).par.map(_ + 3).seq 

问题不是计算它的Parrallel集合的存储。


This takes around 1 second

(1 to 1000000).map(_+3)

While this gives java.lang.OutOfMemoryError: Java heap space

(1 to 1000000).par.map(_+3)

EDIT:

I have standard scala 2.9.2 configuration. I am typing this on scala prompt. And in the bash i can see [ -n "$JAVA_OPTS" ] || JAVA_OPTS="-Xmx256M -Xms32M"

AND i dont have JAVA_OPTS set in my env.

1 million integers = 8MB, creating list twice = 16MB

解决方案

It seems definitely related to the JVM memory option and to the memory required to stock a Parralel collection. For example:

scala> (1 to 1000000).par.map(_+3)

ends up with a OutOfMemoryError the third time I tried to evaluate it, while

scala> (1 to 1000000).par.map(_+3).seq

never failed. The issue is not the computation its the storage of the Parrallel collection.

这篇关于为什么Scala并行集合有时会导致OutOfMemoryError?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆