This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-11-21
Channels
- # announcements (1)
- # babashka (66)
- # beginners (37)
- # calva (3)
- # cljdoc (2)
- # clojure (14)
- # clojure-australia (6)
- # clojure-doc (4)
- # clojure-europe (22)
- # clojurescript (9)
- # datalevin (5)
- # datomic (4)
- # emacs (5)
- # events (1)
- # figwheel-main (6)
- # graalvm (41)
- # lsp (16)
- # luminus (1)
- # off-topic (2)
- # overtone (2)
- # re-frame (2)
- # reagent (8)
- # remote-jobs (1)
- # reveal (49)
- # shadow-cljs (9)
- # spacemacs (14)
- # tools-build (4)
- # tools-deps (16)
Hi! Can anyone give me some tips on how to reduce the size of the binary file? I'm compiling a simple CLI Clojure project that only depends on cheshire and clj-http-lite. The size of the file is 45-46Mb.
If you don't mind slowing down your program a bit, you can compress it using upx: https://upx.github.io/
I've tried to replace clj-http-lite with a primitive Clojure wrapper on top of http://java.net.http.HttpClient, but the size didn't change
@igrishaev you can get this down to probably 15 mb. usually this inflation occurs when you're dynamically requiring vars somewhere
having said this, babashka also contains cheshire and is compatible with clj-http-lite (but also has other http clients on board) so you can maybe also run it with that already, depending on your use case
@igrishaev as the author of etaoin, you might also be interested in seeing what I did to make it run with babashka: https://github.com/babashka/pod-babashka-etaoin
@igrishaev thanks for inviting me to the repo. I see your'e using clojure.pprint and that uses vars dynamically.
this is likely the culprit of the image size bloat. try without pprint for now. I know a workaround for this
I hope the patch will make it into Clojure, that will make clojure.pprint better to use with graalvm
@igrishaev I found that when using httpkit as the client, this is only takes 1.5mb or so
I have a huge JSON file. There is an option to generate a static namespace file before compilation
but if you have the compiled namespace in the image then you don't need to include the JSON anymore right
What I mean: you can make (slurp`(io/resource "my-json.json")` )work at runtime in the image