2

I followed the play deployment instruction and used "play clean stage" to package the application. After uploading the package to an aws EC2 instance, I tried to start it with the command:

target/universal/stage/bin/myapp -Dconfig.file=target/universal/stage/conf/application.conf

But it failed with the message:

OpenJDK 64-Bit Server VM warning: INFO: os::commit_memory(0x00000000c5550000, 715849728, 0) failed; error='Cannot allocate memory' (errno=12)
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (malloc) failed to allocate 715849728 bytes for committing reserved memory.
# An error report file with more information is saved as:
# /tmp/jvm-14940/hs_error.log

I tried to add arguments like: -mem=512 or -Xms256m -Xmx512m. But nothing works so far. Can someone help me on how to run the play app?

Nakilon
  • 34,866
  • 14
  • 107
  • 142
yang
  • 498
  • 5
  • 22
  • 1
    The error message indicates the system is trying to allocate 715MB of memory. Does the instance you are running this on have that much free memory? – Eric J. May 19 '14 at 22:30
  • There is not. That's why I was trying to set -Xmx512m, but it still threw the same error message. – yang May 19 '14 at 22:54
  • you can also turn on swap I guess, but that's going to impact performance. Let me know if you'd like to go down this path and I'll post an answer with the necessary steps. – andreimarinescu May 20 '14 at 09:00
  • I think that's may be informative that it is SBT which tries to allocate that precise amount of memory. Still cannot find the solution but when have one will update. – Alexander Arendar Jun 07 '16 at 12:13
  • The stack-trace you provided is caused by SBT default memory config. To fix it please look my answer here: http://stackoverflow.com/questions/25877206/cant-set-memory-settings-for-sbt-start – Alexander Arendar Jun 07 '16 at 12:39

2 Answers2

3

I faced the same issue while running play app on AWS. But, I packaged the app and was trying to run it form the bin via a shell script that is auto generated.

So, basically I did

  1. play dist
  2. copy the zip file to EC2
  3. Unzip
  4. go to the bin directory and run the below command
  5. ./my-app-name

This gave me the exact same error what you are facing. I just ran it using the below command line argument and it worked.

./my-app-name -mem 512

Hope this will help.

Manohar Negi
  • 445
  • 5
  • 12
0

Ya, too much memory being used for a Micro Instance, I believed they're capped at 615mb.

What is bundled with your application? Play! on its own should't use that much memory.

Alternatively you could just go to your AWS Dashboard where it lists your instances, right click the one you want and change it to a 'small' or 'medium', but you'd end up paying for it.

brdu
  • 284
  • 1
  • 3
  • 17
  • Thanks for the reply. But I was asking how to limit the app to use less than say 512MB memory? – yang May 19 '14 at 22:53
  • You can't really just 'limit' what the app can use.. if your app is starting fresh, thats the amount of memory it needs to run. You'd need to look over what's all being launched within your app. Play itself doesn't use near that much memory, so something else is going on. – brdu May 20 '14 at 06:36