Skip to content

Commit

Permalink
Reduce Java Heap for Mill Client (#4163)
Browse files Browse the repository at this point in the history
The Mill Client only forwards requests and therefore does not need much
memory.
However, Java doesn't know that an allocates a large heap based on the
machines memory size.

Therefore, give a way lower heap limit,
creating a leaner client memory wise.

Example on my machine:
- Before: A Mill client reserved ~500MByte
- After: A Mill client reserves the specified 24Mbyte

This is mostly relevant for a long running mill client (examples
`--watch` clients, `-i --no-build-lock` and --bsp`).

Co-authored-by: Li Haoyi <haoyi.sg@gmail.com>
  • Loading branch information
gamlerhart and lihaoyi authored Jan 21, 2025
1 parent 0bcbe00 commit 5c48b68
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion dist/package.mill
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,11 @@ object `package` extends RootModule with InstallModule {
.mkString("\r\n")

os.write(vmOptionsFile, millOptionsContent)
val jvmArgs = otherArgs ++ List(s"-DMILL_OPTIONS_PATH=$vmOptionsFile")
val jvmArgs = otherArgs ++ List(
// Avoid reserving a lot of memory for the client, as the client only forward information
"-Xmx32m",
s"-DMILL_OPTIONS_PATH=$vmOptionsFile"
)
val classpath = runClasspath().map(_.path.toString)
val classpathJar = Task.dest / "classpath.jar"
Jvm.createClasspathPassingJar(classpathJar, runClasspath().map(_.path))
Expand Down

0 comments on commit 5c48b68

Please sign in to comment.