WebGL Build Memory Browser Error

[Using Unity 2022.3.33f1]

Hi

When attempting to run my WebGL build in any browser, I receive the following errors in console (inspect) :

1.0.0.framework.js:2797 Could not allocate memory: System out of memory!
Trying to allocate: 1060203640B with 16 alignment. MemoryLabel: Serialization
Allocation happened at: Line:72 in ./Runtime/Core/Containers/Vector.h
Memory overview

[ ALLOC_TEMP_TLS ] used: 32032B | peak: 0B | reserved: 4194304B
[ ALLOC_MEMORYPROFILER ] used: 91248B | peak: 91248B | reserved: 1048576B
[ ALLOC_DEFAULT ] used: 1091756731B | peak: 1091756731B | reserved: 1093014364B
[ ALLOC_TEMP_JOB_1_FRAME ] used: 0B | peak: 0B | reserved: 0B
[ ALLOC_TEMP_JOB_2_FRAMES ] used: 0B | peak: 0B | reserved: 0B
[ ALLOC_TEMP_JOB_4_FRAMES (JobTemp) ] used: 0B | peak: 0B | reserved: 262144B
[ ALLOC_TEMP_JOB_ASYNC (Background) ] used: 0B | peak: 0B | reserved: 4194304B
[ ALLOC_GFX ] used: 50624062B | peak: 50624062B | reserved: 50630785B
[ ALLOC_PROFILER ] used: 296703B | peak: 4394652B | reserved: 303588B

[ ALLOC_TEMP_TLS ] used: 34404B | peak: 0B | reserved: 4194304B
[ ALLOC_DEFAULT ] used: 1089449241B | peak: 1089449241B | reserved: 1090337662B
[ ALLOC_TEMP_JOB_1_FRAME ] used: 0B | peak: 0B | reserved: 0B
[ ALLOC_TEMP_JOB_2_FRAMES ] used: 0B | peak: 0B | reserved: 0B
[ ALLOC_TEMP_JOB_4_FRAMES (JobTemp) ] used: 0B | peak: 0B | reserved: 262144B
[ ALLOC_TEMP_JOB_ASYNC (Background) ] used: 0B | peak: 0B | reserved: 4194304B
[ ALLOC_GFX ] used: 50623194B | peak: 50623194B | reserved: 50627887B

_JS_Log_Dump @ 1.0.0.framework.js:10
31.0.0.wasm:0x19160fc Uncaught RuntimeError: null function or function signature mismatch
at 1.0.0.wasm:0x19160fc
at 1.0.0.wasm:0x18e5cdb
at 1.0.0.wasm:0x19169e3
at 1.0.0.framework.js:10:224101
at Object.mouseEventHandlerFunc [as handlerFunc] (1.0.0.framework.js:10:224137)
at jsEventHandler (1.0.0.framework.js:10:194468)

1.0.0.wasm:0x18e6c17 Uncaught RuntimeError: table index is out of bounds
at 1.0.0.wasm:0x18e6c17
at 1.0.0.wasm:0x1916a17
at JS_ScreenOrientation_eventHandler (1.0.0.framework.js:10:45509)

1.0.0.wasm:0x16f5a31 Uncaught RuntimeError: memory access out of bounds
at 1.0.0.wasm:0x16f5a31
at 1.0.0.wasm:0x18e9ffb
at 1.0.0.wasm:0x19169e3
at 1.0.0.framework.js:10:218064
at Object.focusEventHandlerFunc [as handlerFunc] (1.0.0.framework.js:10:218100)
at jsEventHandler (1.0.0.framework.js:10:194468)

1.0.0.wasm:0x18e6c17 Uncaught RuntimeError: table index is out of bounds
at 1.0.0.wasm:0x18e6c17
at 1.0.0.wasm:0x1916a17
at JS_ScreenOrientation_eventHandler (1.0.0.framework.js:10:45509)
$func73703 @ 1.0.0.wasm:0x18e6c17
$dynCall_viii @ 1.0.0.wasm:0x1916a17
JS_ScreenOrientation_eventHandler @ 1.0.0.framework.js:10

1.0.0.wasm:0x18f3e8c Uncaught (in promise) RuntimeError: table index is out of bounds
at 1.0.0.wasm:0x18f3e8c
at 1.0.0.wasm:0x18f43ba
at 1.0.0.wasm:0x7b099
at 1.0.0.wasm:0xf0da09
at 1.0.0.wasm:0x17e628d
at 1.0.0.wasm:0x17f3f06
at 1.0.0.wasm:0x15b324a
at 1.0.0.wasm:0x181d5dc
at 1.0.0.wasm:0x181e406
at 1.0.0.wasm:0x167d77f
at 1.0.0.wasm:0x167f10e
at 1.0.0.wasm:0x167f306
at 1.0.0.wasm:0x16f62f3
at 1.0.0.wasm:0x19154fa
at 1.0.0.wasm:0x1915b4a
at Module._main (1.0.0.framework.js:10:330113)
at callMain (1.0.0.framework.js:10:427024)
at doRun (1.0.0.framework.js:10:427471)
at run (1.0.0.framework.js:10:427643)
at runCaller (1.0.0.framework.js:10:426683)
at Object.removeRunDependency (1.0.0.framework.js:10:17133)
at 1.0.0.loader.js:1:9461

I have tried many workarounds, including different configurations in the Player settings, to no avail.
I’ve also done a lot of optimizing, including static batching of objects, with the help of the live Profiler.

I noticed most of the memory usage comes from the main camera in the scene. It is using like 94% of GPU and 50% of CPU - there are about 70 calls on it? I tried messing with the draw distance but that had no impact. I’m not entirely sure if the camera is the culprit for why these errors are occurring, but it appears as such. My ram usage is almost capped at 2.4 GB in the Profiler.

Please let me know of any tips and if there is anything else I can try to troubleshoot this! Thanks.

The memory limit for WebGL apps is at 2 GB currently. Try to free up a lot of memory by removing assets for a test. If it launches then, the app exceeded that limit and you’ll have to implement some memory saving techniques or remove assets.

1 Like

Thank you for the response!

My project is currently at about 900 MB when built - including all assets.
So then why would it be inflating to over 2 GB when I try to run it?

Edit : In fact, my Assets Folder is only 223 MB before build - What’s up with that?
I’m guessing the size increase has something to do with the Unity Libraries / engine?

File size on disk is NOT the same as memory usage, and there is no generalizable correlation between the two.

Add Graphy to your build to see memory usage.

2 Likes

Thank you!