gpt4 book ai didi

clojure - 为什么 Leiningen 保持自己的 JVM 运行?

转载 作者:行者123 更新时间:2023-12-04 01:09:19 24 4
gpt4 key购买 nike

如果我打电话

lein trampoline repl

Leiningen 启动自己的 JVM 进程,然后为 repl 启动一个单独的 JVM 并退出。但是调用默认值
lein repl

留下两个 JVM 运行。是否有任何理由保持原始 Leiningen JVM 进程运行?为什么不做 lein trampoline行为默认并每次退出?

最佳答案

lein help trampoline指出:

Run a task without nesting the project's JVM inside Leiningen's.

Calculates the Clojure code to run in the project's process for the given task and allows Leiningen's own JVM process to exit before running it rather than launching a subprocess of Leiningen's JVM.

Use this to save memory or to work around stdin issues.

Arguments: ([task-name & args])



所以你可以看到,没有 trampoline第二个 JVM 作为第一个的子进程运行。这就是为什么第一个不能退出——退出会破坏第二个。

另一方面,与 trampoline第一个 JVM 构建了一个 shell 脚本,然后由 lein 执行。生成第二个 JVM 的脚本。所以在这种情况下,第二个 JVM 是 lein 的子级。脚本。 How Clojure Babies are Made: Leiningen's Trampoline相当详细地介绍了这一点。

至于为什么 trampoline不是默认值,我不完全确定。但请记住,并非每个 lein command 运行项目代码,因此不需要每个命令都使用第二个 JVM。

此外,使用 trampoline 也可能存在缺点。 .例如,看看上面文章中的以下代码行:
# Just don't change :target-path in project.clj, mkay?
TRAMPOLINE_FILE="target/trampolines/$INPUT_CHECKSUM"

对我来说,这意味着如果 :target-path 可能会出现问题设置在 project.clj .

关于clojure - 为什么 Leiningen 保持自己的 JVM 运行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27339206/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com