使用clojure lein ring服务器,如何在启动Web应用程序时设置max heapsize?

问题描述 投票:1回答:3

因此,当我使用命令lein ring server启动clojure Web应用程序时,有2个进程可以启动.qazxsw poi

第一个进程是clojur.main,然后运行主Web应用程序。 jvm选项

enter image description here

用于控制Web应用程序内存的响铃工作。问题是clojure.main -m leingen.core.main分配了300多MB的堆空间。 (见截图32)

:jvm-opts ["-Xmx128m" "-server"]

clojure leiningen ring
3个回答
1
投票

另一种方法是创建一个uberjar:

enter image description here

您通常总是希望使用> 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 版本。

然后你开始使用普通的java w / o任何lein:

xxx-standalone.jar

你可以添加任何标志,如java -jar /home/alan/expr/demo-horizon/target/demo-horizon-0.1.0-SNAPSHOT-standalone.jar 或任何你喜欢的。


更新

在创建一个uberjar之前我总是运行-Xmx4g。这是默认行为,但可以通过在lein clean中设置:auto-clean false来禁用。根据Sample project.clj:

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 (以防lein clean被禁用)。


2
投票

好吧没关系

显然我应该运行lein trampoline ring server

这样莱林就可以避开记忆


0
投票

你需要在你的:auto-clean中设置:jvm-opts。例如

project.clj

另见:jvm-opts ["-Xmx1g" "-server"]

© www.soinside.com 2019 - 2024. All rights reserved.