So when I start the cloure web application with the command lein ring server, there are 2 processed that get started.
The first process is clojur.main that then runs the main web application. The jvm options
:jvm-opts ["-Xmx128m" "-server"]
for ring work to control the memory for the web application. The issue is that the clojure.main -m leingen.core.main allocates 300+ MB of heap space. (see screenshot 32)
The other way is to create a uberjar:
> lein clean
> lein uberjar
Compiling demo.hello
Compiling demo.numbers
Created /home/alan/expr/demo-horizon/target/demo-horizon-0.1.0-SNAPSHOT.jar
Created /home/alan/expr/demo-horizon/target/demo-horizon-0.1.0-SNAPSHOT-standalone.jar
You normally always want to use the xxx-standalone.jar
version.
Then you start the process using plain java w/o any lein at all:
java -jar /home/alan/expr/demo-horizon/target/demo-horizon-0.1.0-SNAPSHOT-standalone.jar
and you can add any flags like -Xmx4g
or whatever else you like.
I always run lein clean
before creating a uberjar. This is the default behavior, but can be disabled by setting :auto-clean false
in project.clj
. According the the Sample project.clj:
; By default Leiningen will run a clean before creating jars to prevent
; undeclared AOT from leaking to downstream consumers; this disables
; that behaviour.
:auto-clean false
I cannot see why starting with a dirty build would ever be a good idea, which is why I always manually run lein clean
first (just in case :auto-clean
has been disabled).