I'm trying to run sbt start
in a Play Framework application written in Scala, on a machine that is an ec2 t2.micro instance on AWS. But i can't because There is insufficient memory for the Java Runtime Environment to continue.
我正在尝试运行sbt从一个在Scala中编写的游戏框架应用程序开始,在一个ec2 t2的机器上。在AWS上微实例。但是我不能,因为Java运行时环境没有足够的内存继续。
The machine has 1GB of memory, but in practice 930MB of free memory to use while running the remaining of OS processes. It is Ubuntu Server 14.04 LTS. The app is small, cute.
这台机器有1GB的内存,但是在实践中,运行OS进程的其余部分时要使用930MB的空闲内存。它是Ubuntu服务器14.04 LTS。这款应用程序小巧可爱。
Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x00000000d5550000, 715849728, 0) failed; error='Cannot allocate memory' (errno=12)
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (mmap) failed to map 715849728 bytes for committing reserved memory.
# An error report file with more information is saved as:
# /app/incoming/hs_err_pid9709.log
Here is the link to the log file for more info.
这里是指向日志文件的链接,了解更多信息。
Inside i see jvm_args: -Xms1024m -Xmx1024m -XX:ReservedCodeCacheSize=128m ...
despite i set my JVM args in so many different ways to something else but no effect.
我在里面看到jvm_args: -Xms1024m -Xmx1024m -XX:ReservedCodeCacheSize=128m…尽管我用很多不同的方式设置JVM args,但是没有效果。
With these arguments -Xss1m -Xms256m -Xmx512m -XX:+CMSClassUnloadingEnabled
I tried everything:
有了这些参数-Xss1m -Xms256m -Xmx512m -XX:+CMSClassUnloadingEnabled,我尝试了一切:
- setting JVM args in /usr/share/sbt-launcher-packaging/conf/sbtopts
- 在/usr/share/sbt-launcher-packaging/conf/sbtopts中设置JVM args
- same in /usr/share/sbt-launcher-packaging/conf/sbtconfig.txt
- 在/usr/share/sbt-launcher-packaging / conf / sbtconfig.txt相同
- supplying the args directly when running:
sbt -J-Xss1m -J-Xms256m -J-Xmx512m -J-XX:+CMSClassUnloadingEnabled start
- 运行时直接提供args: sbt -J-Xss1m -J-Xms256m -J-Xmx512m -J-XX:+CMSClassUnloadingEnabled start
- already set
fork in run := true
in build.sbt - 已经设置了fork in run:= true in build.sbt。
-
javaOptions in run += "-Xmx512m -XX:+CMSClassUnloadingEnabled"
in build.sbt - 在build.sbt中,运行+= "-Xmx512m -XX:+CMSClassUnloadingEnabled"中的javaOptions
Neither of them helps. The same lame 1024 things appear in the logs every time i run the app. Please help.
他们两人有帮助。每次我运行这个应用时,日志里都会出现同样的1024个没用的东西。
2 个解决方案
#1
8
Also struggled with setting jvm memory args for sbt
on Linux in the past (on Windows you can tweak sbtconfig.txt
but this and all other places where you can specify SBT_OPTS
I could find doesn't work on Linux for some reason).
以前在Linux上为sbt设置jvm内存args也遇到过困难(在Windows上,可以调整sbtconfig。但是这个和其他可以指定SBT_OPTS的地方在Linux上并不适用)。
Last time I've solved this by using -mem <amount>
option of sbt
itself.
上次我用sbt本身的-mem
So, in your case you should try something like this:
所以,在你的情况下,你应该尝试以下方法:
$ sbt -mem 512 start
#2
1
I had the same problem today with EC2 nano-instance. Solved it this way:
我今天在EC2纳米实例上遇到了同样的问题。这样解决:
cd /etc/sbt-launcher-packaging/
sudo nano sbtopts
Then uncomment -mem option. I've set it to 256 and after that I can normally run sbt on nano-instance. A sample piece of this config file after edited:
然后取消mem选项。我将它设置为256,然后我可以在nano-instance上运行sbt。经过编辑的配置文件示例:
# Path to local Ivy repository (default: ~/.ivy2)
#
#-ivy ~/.ivy2
# set memory options
#
-mem 256
# Use local caches for projects, no sharing.
#
#-no-share
#1
8
Also struggled with setting jvm memory args for sbt
on Linux in the past (on Windows you can tweak sbtconfig.txt
but this and all other places where you can specify SBT_OPTS
I could find doesn't work on Linux for some reason).
以前在Linux上为sbt设置jvm内存args也遇到过困难(在Windows上,可以调整sbtconfig。但是这个和其他可以指定SBT_OPTS的地方在Linux上并不适用)。
Last time I've solved this by using -mem <amount>
option of sbt
itself.
上次我用sbt本身的-mem
So, in your case you should try something like this:
所以,在你的情况下,你应该尝试以下方法:
$ sbt -mem 512 start
#2
1
I had the same problem today with EC2 nano-instance. Solved it this way:
我今天在EC2纳米实例上遇到了同样的问题。这样解决:
cd /etc/sbt-launcher-packaging/
sudo nano sbtopts
Then uncomment -mem option. I've set it to 256 and after that I can normally run sbt on nano-instance. A sample piece of this config file after edited:
然后取消mem选项。我将它设置为256,然后我可以在nano-instance上运行sbt。经过编辑的配置文件示例:
# Path to local Ivy repository (default: ~/.ivy2)
#
#-ivy ~/.ivy2
# set memory options
#
-mem 256
# Use local caches for projects, no sharing.
#
#-no-share