Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specify default memory parameters of java_application BASH script in the build #82

Closed
abrutus opened this issue Nov 20, 2013 · 13 comments
Closed

Comments

@abrutus
Copy link

abrutus commented Nov 20, 2013

I downloaded a sample app for the latest version of play
packaged it using debian:packageBin and then installed it in my VM with 512 megs of ram
but when I try to run it I get this

Error occurred during initialization of VM
Could not reserve enough space for object heap

While you can specify -mem to the script to fix this, it'd be nice if the default configuration for memory requirements was configurable.

@jsuereth
Copy link
Member

Yeah, sort of. THe default is 1024M I believe. You can use the -mem option, or the -h option to see available options.

Here's the spot in code:

https://github.com/sbt/sbt-native-packager/blob/master/src/main/resources/com/typesafe/sbt/packager/archetypes/bash-template#L149

@abrutus
Copy link
Author

abrutus commented Nov 20, 2013

👍 It works! app-name -m 128

Is there any way to set that number up through my build.sbt or something like that so I don't have to specify it every time I run the packaged version?

Thanks for your super fast response!

@jsuereth
Copy link
Member

Not yet. I'll alter this to a feature request :)

@abrutus
Copy link
Author

abrutus commented Nov 20, 2013

Okay thanks! If you outline the changes necessary I might be able to figure it out and send you a pull request

@muuki88
Copy link
Contributor

muuki88 commented Mar 3, 2014

Is it a good idea that the javaOptions in run will be appended to the etc-default template? The logic would be rather simple (append -J to every value which doesn't start with -D, right?)

Would this be to much magic? @jsuereth , @aparkinson

@jsuereth
Copy link
Member

jsuereth commented Mar 3, 2014

I'm pretty nervous about javaOptions in run making it into the packaging. Particularly because there's a divorce between the platform you develop on and the platform you deploy on (usually).

that's just me though. The idea of doing magic (as long as it's configurable) is great. As you've seen, most of the work in this 0.7 has been taking the initial magic of "auto java app" and adding in configuration that was missing. So, I'd be ok adding javaOptions in run.

@muuki88
Copy link
Contributor

muuki88 commented Mar 4, 2014

I never used this option so I have no idea how people use it and if they expect that their production system will look the same.

We may scope this to avoid confusion, like

javaOptions in (run, Linux)

@aparkinson
Copy link
Contributor

I know in my use case our production javaOptions are very different from development and I wouldn't want them to get through

@muuki88
Copy link
Contributor

muuki88 commented Mar 4, 2014

Okay. Do you think scoping makes sense then?

@aparkinson
Copy link
Contributor

Scoping seems reasonable and I have no objection to it

@huntc
Copy link
Contributor

huntc commented Feb 28, 2015

I'd like to re-visit this issue. As more microservice style applications are developed then having a default of -Xms1024m -Xmx1024m seems excessive. I recently observed a medium sized EC2 machine running out of space within only 3 services running.

Why not just lean on the default mx of Java which is 64m respectively. ms could still equal mx.

Developers need to think about the memory required for their apps. Unfortunately the current settings do little to provoke that thought in practice.

@muuki88
Copy link
Contributor

muuki88 commented Mar 2, 2015

@huntc the easiest way of doing the shell part would be to remove the -mem option. It adds a lot of possible errors in the bash script and doesn't add any convenience as the jvm figures out most of the stuff itself.

@jsuereth I really would like to remove this part as it only gets more tricky with each additional request.

@kardapoltsev
Copy link
Member

+1 for removing -mem.

muuki88 added a commit that referenced this issue Mar 28, 2015
FIX #82 adding the ability to specify jvm options via sbt
rtyley added a commit to guardian/subscriptions-frontend that referenced this issue Jun 18, 2015
Apparently `sbt-native-packager` removed the `-mem` parameter with
sbt/sbt-native-packager@62362c2377 - so if you
look in a subscriptions-box, you see this in `/subscriptions/stdout.log`:

```
!! WARNING !! -mem option is ignored. Please use -J-Xmx and -J-Xms
```

sbt/sbt-native-packager#82 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants