oakes/play-cljc

Windows build issues

Closed this issue · 6 comments

Hi! Looking forward of getting to do some gamedev with Clojure :)

I'm trying to run both web versions and develop native one but in all of these cases something funky happens. And not the good kind of funky - the bad kind!

Output on native case:

D:\Projects\Lisps\Clojure\hello-world>powershell -command clj -A:dev:windows native
2019-08-12 00:12:01.003:INFO::main: Logging initialized @3523ms to org.eclipse.jetty.util.log.StdErrLog
Started Nightlight on http://localhost:4001
Syntax error (OutOfMemoryError) compiling at (D:\Projects\Lisps\Clojure\hello-world\dev.clj:33:1).
Java heap space

Output on web case:

D:\Projects\Lisps\Clojure\hello-world>powershell -command clj -A:dev
2019-08-12 00:13:38.261:INFO::main: Logging initialized @3504ms to org.eclipse.jetty.util.log.StdErrLog
Started Nightlight on http://localhost:4000
[Figwheel] Validating figwheel-main.edn
[Figwheel] �[32mfigwheel-main.edn is valid \(?)/�[0m
[Figwheel] Compiling build dev to "resources/public/main.js"
[Figwheel] �[31mFailed to compile build dev in 14.192 seconds.�[0m
[Figwheel:WARNING] �[36mCould not Compile: �[0m�[33mJava heap space  �[0m�[36mD:\Projects\Lisps\Clojure\hello-world\src\hello_world\start.cljs   �[0m
[Figwheel:SEVERE] java.lang.OutOfMemoryError: Java heap space
[Figwheel] Starting Server at http://localhost:9500
Opening URL http://localhost:9500

As it can be seen, on windows clj must be evoked with powershell (major bummer - I know). Don't know if that additional step contributes to the problem and I'm quite a n00b with Clojure-CLI (need to read up on it more).

whatdonow

Edit: Ensured that there's no issue because of using cmd.exe with preceding powershell -command. Initialized directly with powershell instead and used the commands stated in the docs. The results seem to be the same.

oakes commented

I actually develop on windows 10, I've never experienced this. How much ram do you have? Maybe try something like clj -J-Xmx1g -A:dev:windows native to make sure it has enough heap space, though it definitely should not need that much.

Ah, as a person who does anything game related on a windows I'm very happy to hear that. I have 32GB. Seems the heap space limit did the trick but it's definitely strange that it's needed..

Here's the full report that is generated when OutOfMemoryError happens. Has this something to do with Edna?

{:clojure.main/message
 "Syntax error (OutOfMemoryError) compiling at (D:\\Projects\\Lisps\\Clojure\\hello-world\\dev.clj:33:1).\r\nJava heap space\r\n",
 :clojure.main/triage
 {:clojure.error/phase :compile-syntax-check,
  :clojure.error/line 33,
  :clojure.error/column 1,
  :clojure.error/source "dev.clj",
  :clojure.error/path
  "D:\\Projects\\Lisps\\Clojure\\hello-world\\dev.clj",
  :clojure.error/class java.lang.OutOfMemoryError,
  :clojure.error/cause "Java heap space"},
 :clojure.main/trace
 {:via
  [{:type clojure.lang.Compiler$CompilerException,
    :message
    "Syntax error compiling at (D:\\Projects\\Lisps\\Clojure\\hello-world\\dev.clj:33:1).",
    :data
    {:clojure.error/phase :compile-syntax-check,
     :clojure.error/line 33,
     :clojure.error/column 1,
     :clojure.error/source
     "D:\\Projects\\Lisps\\Clojure\\hello-world\\dev.clj"},
    :at [clojure.lang.Compiler load "Compiler.java" 7648]}
   {:type java.lang.OutOfMemoryError,
    :message "Java heap space",
    :at [com.sun.media.sound.SF2Soundbank readSdtaChunk nil -1]}],
  :trace
  [[com.sun.media.sound.SF2Soundbank readSdtaChunk nil -1]
   [com.sun.media.sound.SF2Soundbank readSoundbank nil -1]
   [com.sun.media.sound.SF2Soundbank <init> nil -1]
   [com.sun.media.sound.SF2SoundbankReader getSoundbank nil -1]
   [javax.sound.midi.MidiSystem getSoundbank nil -1]
   [edna.core$fn__27172 invokeStatic "core.clj" 223]
   [edna.core$fn__27172 invoke "core.clj" 222]
   [clojure.lang.Delay deref "Delay.java" 42]
   [clojure.core$deref invokeStatic "core.clj" 2320]
   [clojure.core$deref invoke "core.clj" 2306]
   [edna.core$export_BANG_$fn__27182 invoke "core.clj" 250]
   [clojure.core$update invokeStatic "core.clj" 6196]
   [clojure.core$update invoke "core.clj" 6188]
   [edna.core$export_BANG_ invokeStatic "core.clj" 250]
   [edna.core$export_BANG_ invoke "core.clj" 229]
   [hello_world.music$build_for_clj invokeStatic "music.clj" 13]
   [hello_world.music$build_for_clj invoke "music.clj" 12]
   [hello_world.start$play_music invokeStatic "start.clj" 56]
   [hello_world.start$play_music invoke "start.clj" 54]
   [hello_world.start$_main invokeStatic "start.clj" 77]
   [hello_world.start$_main doInvoke "start.clj" 60]
   [clojure.lang.RestFn invoke "RestFn.java" 397]
   [hello_world.start_dev$start invokeStatic "start_dev.clj" 10]
   [hello_world.start_dev$start invoke "start_dev.clj" 7]
   [user$eval27307$fn__27308 invoke "dev.clj" 31]
   [clojure.lang.MultiFn invoke "MultiFn.java" 229]
   [user$eval27311 invokeStatic "dev.clj" 33]
   [user$eval27311 invoke "dev.clj" 33]
   [clojure.lang.Compiler eval "Compiler.java" 7177]
   [clojure.lang.Compiler load "Compiler.java" 7636]
   [clojure.lang.Compiler loadFile "Compiler.java" 7574]
   [clojure.main$load_script invokeStatic "main.clj" 475]],
  :cause "Java heap space",
  :phase :compile-syntax-check}}
oakes commented

Ah that actually makes sense, maybe it's loading the entire sound bank into memory. I think you can find the max heap size for your java installation with this:

java -XX:+PrintFlagsFinal -version | findstr MaxHeapSize

Mine says 4253024256 so about 4 gigs I guess. At any rate, I'm sure other people will run into it so I added it to the template here. You might want to do the same so you don't have to keep typing it. If you're not planning on making music you can also remove the edna stuff from the project.

oakes commented

Actually it'd be better to add it here instead so it is used when doing dev and prod commands.

oakes commented

Nevermind, I don't think you can add :jvm-opts to the top level so my first link is better.

Ah, thanks for the help! :)