Starting from Unity 6, Unity has officially begun focusing on WebGL builds, introducing many new features. So, I wanted to check its current state, as memory allocation was previously a major issue, often causing browser crashes.
To test this, I created an empty project and built it using Unity 6000.0.41f1. I selected Stripping Mode as “High” and did not add any additional resources. I also reviewed the build report, removed all unnecessary packages, and disabled all SRP shadow toggles and camera depth. Almost all settings were tweaked based on suggestions from Unity manuals and various posts.
Despite all these optimizations in an empty project, the release build still consumes around 200 MB of memory, as reported by both Unity and Microsoft Edge’s Browser Task Manager.
My Questions:
Can this be optimized further?
Does Unity have any plans to drastically improve Web build memory usage?
According to the Memory Profiler, render textures are using around 38.5 MB in an empty build. Is there any scope for reducing this?
I disabled Camera > Depth Texture, but it didn’t make any improvement. Based on the profiler image, a ~14 MB runtime texture is still being created for that.
Try disabling the depth texture support in the renderer asset as well.
Hmmm my guess is because one might want to change that at runtime.
This has often been discussed. Just FYI from what I recall those 1.2 MB is the uncompressed size but in the build the image is compressed and likely around one tenth of that size.
You aren’t using terrain but you still have it installed. Try disabling the Terrain built-in package in Package Manager. This is generally best practice to disable / uninstall unused packages.
I did some minimizing tests as described here. This is buried in the longest webgl build size thread and perhaps you missed it, or perhaps you found another thread where I linked to that post but the link was incorrectly linking to the OP’s post until right now.
I think the shader issue has also been discussed somewhere but I can’t recall what the status quo is.
Also worth pointing out: measure release builds because debug builds generally consume more disk space and memory.
Overall in recent years WebGL builds have been continuously optimized bit by bit. If you were to make the same tests with 2021.3 you’ll find noticably higher memory and disk usage. Likewise you may be interested in trying to repeat this test with 6.1 beta and 6.2 alpha to see how the metrics change in these versions but bearing in mind that being beta/alpha versions they are not representative of the official releases.
Okay, if I don’t want or use the skybox, shouldn’t there be an option to include or exclude it?
The memory snapshots I have attached are from the build itself, not from the editor.
Yes yes, for example, below is the memory allocated in the release build, where the Development Build checkbox and other debug options are disabled, but still the memory consumption is around ~200 MB
I have gone through the thread you attached and made those tweaks, but the runtime allocation hasn’t reduced much. In the meantime, as you have suggested, I will check the latest beta to see if there are any changes around this.
I’m not sure what memory the “Browser Task Manager” actually shows. You can’t do much about any memory used by HTML and Javascript for instance, but this value may include that.
I am following this post with interest because we are facing the same issue.
We have observed a similar result: an entirely empty Web build alone consumes 200MB of RAM. Given that the recommended limit on mobile (iOS) is 500MB, this accounts for 40% of the total budget.