Good morning/afternoon/evening. I'm hitting a weird bug that I don't know where to go on. I have a service that gets packed into an uberjar with lein uberjar in a Dockerfile. When I run lein uberjar from my laptop's terminal all is well. When I run the command inside of docker build I get an OutOfMemory exception Java heap space. The stack trace always looks something like:
102.4 Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
102.4 at clojure.lang.PersistentVector.chunkedSeq(PersistentVector.java:279)
102.4 at clojure.lang.PersistentVector.seq(PersistentVector.java:283)
102.4 at clojure.lang.RT.seqFrom(RT.java:528)
102.4 at clojure.lang.RT.seq(RT.java:523)
102.4 at clojure.lang.RT.first(RT.java:668)
102.4 at clojure.core$first__4339.invokeStatic(core.clj:55)
102.4 at clojure.core$some.invokeStatic(core.clj:2592)
102.4 at clojure.core$some.invoke(core.clj:2583)
102.4 at leiningen.core.pedantic$all_paths$iter__4322__4328$fn__4329.invoke(pedantic.clj:109)
102.4 at clojure.lang.LazySeq.sval(LazySeq.java:40)
102.4 at clojure.lang.LazySeq.seq(LazySeq.java:56)
102.4 at clojure.lang.ChunkedCons.chunkedNext(ChunkedCons.java:59)
102.4 at clojure.lang.ChunkedCons.next(ChunkedCons.java:43)
102.4 at clojure.lang.RT.next(RT.java:688)
102.4 at clojure.core$next__4341.invokeStatic(core.clj:64)
102.4 at clojure.core$dorun.invokeStatic(core.clj:3033)
102.4 at clojure.core$doall.invokeStatic(core.clj:3039)
102.4 at clojure.core$doall.invoke(core.clj:3039)
102.4 at leiningen.core.pedantic$all_paths.invokeStatic(pedantic.clj:113)
102.4 at leiningen.core.pedantic$all_paths.invoke(pedantic.clj:100)
102.4 at leiningen.core.pedantic$transform_graph.invokeStatic(pedantic.clj:123)
102.4 at leiningen.core.pedantic$transform_graph.invoke(pedantic.clj:115)
102.4 at leiningen.core.pedantic$use_transformer$reify__4356.transformGraph(pedantic.clj:161)
102.4 at org.eclipse.aether.internal.impl.DefaultDependencyCollector.collectDependencies(DefaultDependencyCollector.java:282)
102.4 at org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveDependencies(DefaultRepositorySystem.java:350)
102.4 at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
102.4 at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
102.4 at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
102.4 at java.base/java.lang.reflect.Method.invoke(Method.java:568)
102.4 at clojure.lang.Reflector.invokeMatchingMethod(Reflector.java:93)
102.4 at clojure.lang.Reflector.invokeInstanceMethod(Reflector.java:28)
102.4 at cemerick.pomegranate.aether$resolve_dependencies_STAR_.invokeStatic(aether.clj:806)
Any ideas on how to debug this? I tried moving the heap up by adding :jvm-opts ["-Xmx8g"] to my project.clj . Will that change the java args on the lein process or is there a different way to set that for leiningen? Thanks for the great tool.@brandon268 interesting, let me see.
I bet that's it. The base docker image that I'm using has lein 2.8.1. I'll get it upgraded. Thanks!!
That was totally it. Thanks for the help everyone!!
What version of lein are you using? Lein 2.9.9 fixed a bug that could cause infinite loops and OOM in the leiningen.core.pedantic code path https://github.com/technomancy/leiningen/releases/tag/2.9.9
Updating lein to the latest, or setting :pedantic? false in project.clj would probably help
docker configuration allows you to specify the max number of cores/memory for containers. could you have that configured with less memory than you need?
Good thought. I’ll try tomorrow. Thanks
there's this var as well https://github.com/technomancy/leiningen/blob/24fb93936133bd7fc30c393c127e9e69bb5f2392/sample.project.clj#L546 - often you have to hit that one instead for Lein itself