- Home /
Why when i increase memory allocation for Webgl , my game gone crazy and take more away RAM on Browsers?
hi all Unity developpers , something weird ihave been seeing, for example when i allocate 512mo , my real RAM on browser Ram is about 1024mo !!! but when i put 128 mo , my real ram comsuption is about 600/700 mo, why this is hapening ? even tho the game works ? is this a bug or am i the only one seeing this wierd stuff ? thank you all
Exactly my issue. We have a game which consumes about 300-500$$anonymous$$B of memory on movile devices. While in Chrome it is larger than 1GB!!! I tried all of the combinations proposed here and they are really useless.
Answer by vladrybak · Sep 26, 2015 at 10:53 AM
Before build
Set Optimization Level to “Fastest”
Set “Enable Exceptions” in Player Settings to “None”
Enable code Stripping” in Player Settings.
Take care when using third-party managed dlls, as those may drag in a lot of dependencies and increase the emitted code size significantly.
Don't use LoadFromCacheOrDownload function for asset bundles
WebGL Memory size should be set to value that you expect from your game and should be as small as possible. You can check your current memory allocation in Editor Profiler and make WebGL size a little larger.
After Deploy
Make sure that your server use Compressed files instead of the much larger “Release” folder, as the http protocol natively supports gzip compression (which is faster then Unity could handle decompression by itself in JavaScript code). You can check that by loading your content and inspecting network transfers in your browsers development tools. You should find “Content-Encoding: gzip” in the response headers for the js and data downloads. If you are hosting your files on an Apache web server, Unity will write an invisible .htaccess file into the build results folder, which tells Apache to compress the transfers, so this should just work. If you are using other web servers, check your server’s manual.
Answer by vladrybak · Sep 25, 2015 at 07:57 AM
It's expected behavior for webgl. Here is a docs about it http://docs.unity3d.com/Manual/webgl-memory.html
Answer by Jessespike · Sep 24, 2015 at 07:22 PM
Increasing the WebGL Memory size will directly increase the amount of memory used by the browser. Browsers handle memory for webgl in a less than ideal way, creating duplicates, etc. So it bloats. Looking at the memory consumed by the browser via task manager probably isn't the best way to gauge apps.