How to increase scala stack size?

倖福魔咒の 提交于 2019-12-07 02:19:49

问题


I am getting a java.lang.StackOverflowError, when I execute a Scala program.

I believe that the stack size can be set with -DXss=n, but it does not work on my system:

  Scala compiler version 2.7.7final and
  Linux 2.6.38-8-generic #42-Ubuntu 

The attached program witnesses the problem on my system.

// scalac StackOverflow.scala
// scala StackOverflow 6000
// scala -DXms=200M -DXmx=200M -DXss=200M StackOverflow 6000

object StackOverflow {
  def recur(k: Double): Double = {
    // check effects of various commands
    println(k)
    // try to prevent tail recursion
    if (k>0) return recur(k-1)+k/(k+1)
    else return 0.0
  }
  def main(args: Array[String]) {
    if (args.length == 0) println("Missing argument");
    val k = args(0).toInt+0.1
    recur(k)
  }
}

Sergio


回答1:


I think what you want is scala -J-Xss200m



来源:https://stackoverflow.com/questions/6591452/how-to-increase-scala-stack-size

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!