hello! i’m trying to build our project to webgl. although it works ok with unity 4.6-webplayer, when i try to compile with unity-5.0-beta14-webgl it doesn’t work.
with the non-optimised option it compiles but it crashes the chrome/firefox browser and with the optimised option i get this error:
I’m getting the same error and I also have 16 GB memory with 200+ GB free disk space, running OSX Mavericks on a 1st generation Macbook Pro Retina and Unity 5 beta 17.
I watched the Unity process tree as it was building, and it never seems to go above 5 GB of memory used. I would assume it could grab more memory if it needed it.
OSX makes it difficult to really figure out how much true “free” memory you have left though. I’m happy to run another build running some kind of memory debug commands as the build process is running, if you can provide the command you like to get the amount of free memory.
I poked around on the emscripten site for ideas on how to decrease the memory usage, or increase the amount of memory available to emcc, and I did find 1 thing that might help: EMCC_CORES (FAQ — Emscripten 3.1.65-git (dev) documentation). Apparently, if you have a lot of cores and not so much memory, you can set that to a lower number than your real cores and it should consume less memory. Is there a way to add that to the emcc command it runs?
@d12frosted_1 , @tayl0r : It seems odd that you would be running out of memory on a 16GB mac. I have the same setup and I never saw that happening. Are you sure that you are seeing the same error as the thread starter? The first lines of the error are not relevant, the relevant part is “FATAL ERROR: CALL_AND_RETRY_2 Allocation failed - process out of memory”. If you are seeing that on a 16 MB mac, then either your project is somehow stretching the limits of emscripten very far, or points to a bug in emscripten. In either case, a bug report with a repro project would probably be helpful.
FATAL ERROR: CALL_AND_RETRY_2 Allocation failed - process out of memory Traceback (most recent call last): File “/Applications/Unity5/Unity.app/Contents/PlaybackEngines/WebGLSupport/BuildTools/Emscripten/emcc”, line 1452, in flush_js_optimizer_queue() File
I submitted a bug report (# 657693) with our huge project attached. I’m pretty confident you’ll be able to reproduce it with our project. Thanks!
So, I looked at a bug report on this now, and discussed the behavior with Alon from mozilla (developer of emscripten). It turns out that the code had a single, very long function (several thousand lines of code), which caused the JavaScript optimizer to run out of memory when building with the “Fastest” build option (-O3 in emscripten). “Fast” (-O2 in emscripten) would work fine. Alon is working on a new version of the emscripten optimizer (which is written in C++ and not in JavaScript), which uses less memory and should fix this issue. But that is not stable yet, so until then, you can either use “Fast” to get around this, or check your project for excessively long functions and try splitting those up.