If I have a `jvm.heapSize=2048` value in server.js...
# box-products
s
If I have a
jvm.heapSize=2048
value in server.json, that value is obviously used for the server when it starts. Is that value also used by Commandbox for other commands? For example, if I run
box install
will the Commandbox process also grab another 2GB of memory? I ask because I am running a server on an EC2 instance with 4GB memory and 2048 heapsize. Sometimes when I do a deploy the entire instance crashes when it gets to the
box install
part of the deploy (like can't even ssh to it). Trying to figure out why...
b
@seandaniels Server settings have no affect on what the CLI does
The CLI actually doesn't set a max heap so it's just going to grab whatever Java think it wants to ask the OS for.
Normally, just running a one-off command will only take a few hundred megs, but I've also ran heavy duty task runners from the CLI and had it gobble up a couple Gigs of RAM
If you want to prevent the CLI from taking over a certain amount, there are a couple ways to provide JVM args to the underlying Java process, but it depends on your OS
You can set this on your server to keep the CLI from going over your set amount.
Java can be a little greedy when you don't give it a max, so setting a max should still work just fine, it will just force Java to perform garbage collection a little more often 🙂
s
Will give that a try, thanks!
Like I said, it's just a
box install
so it didn't seem to me to be too heavy a task (probably a dozen or so packages?) but hey who knows. It was definitely happening repeatedly at that exact step in the deploy.
b
Honestly, it may depend on how big the zip are you're downloading.
If you're downloading hundreds of megs of stuff, that can create a good deal of memory churn
And Java seems that it will always just ask the OS for more rather than bother running GC, lol
s
Ah. Interesting. Yeah some of my packages might be pretty big. In particular, a "commons" library my apps use.
Just verifying, if I'm using
commandbox-dotenv
and I'm on *nix and I add
BOX_JAVA_ARGS="-Xms512m -Xmx512m"
to my .env, that should do it, eh?
b
No
s
heh
glad I asked
b
the dot env module has nothing at all to do with the bootstrapping of CommandBox itself!
s
Right, ok
b
It only loads env vars into CommandBox's shell. looooong after Java has already started
👍 1
You need to set that env var in your actual shell before ever running box
s
I see. Thanks
b
You can set them in a profile if you want so they always exist, or create a shell script called
box
that sets that and then runs the
real_box
, etc
Or if this is a CI server, just run that set prior to running your build
👍 1
s
all good. I'll just add that to my deploy shell script before it calls
box install