Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Join us on Dec 8, 2022, between 7 am & 7 pm EST, in the DOTS Dev Blitz Day 2022 - Q&A forum, Discord, and Unity3D Subreddit to learn more about DOTS directly from the Unity Developers.
    Dismiss Notice
  3. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

Weg GL out of memory alert

Discussion in 'WebGL' started by Saravana_Vins, Apr 24, 2020.

  1. Saravana_Vins

    Saravana_Vins

    Joined:
    May 5, 2017
    Posts:
    35
    Hi All,
    I am developing cross platform application, It is running without any problem in all other platform except WebGL. When I open my application in browser it throws alert with following message.

    "Out of memory. If you are the developer of this content, try allocating more memory to your WebGL build in the WebGL player settings."

    As I analyzed, We can set memory size property in player setting.But It does not showing in my Unity editor(2019.2.3f1) player settings.

    Please Guide me to solve this.
    Thanks.
     
    JZ_CGL likes this.
  2. JZ_CGL

    JZ_CGL

    Joined:
    Jun 12, 2017
    Posts:
    9
    I'm experiencing the same issue. I've checked the console and got this additional error message:


    Invoking error handler due to
    Uncaught abort("Cannot enlarge memory arrays. Either (1) compile with -s TOTAL_MEMORY=X with X higher than the current value 2144141312, (2) compile with -s ALLOW_MEMORY_GROWTH=1 which allows increasing the size at runtime, or (3) if you want malloc to return NULL (0) instead of this abort, compile with -s ABORTING_MALLOC=0 ") at Error
     
  3. adriankml

    adriankml

    Joined:
    Apr 11, 2020
    Posts:
    8
    I am having the same problem, I got around the memory error by going into the Unity.json file in the build folder and increasing TOTAL_MEMORY to about 1gb. Probably not very sustainable though so if anyone has tips they would like to share to help reduce memory usage that would be greatly appreciated.
     
  4. JZ_CGL

    JZ_CGL

    Joined:
    Jun 12, 2017
    Posts:
    9
    I went through all my PNG spritesheets and changed their Compress method to RGBA Crunched DXT5. In order for this to work properly, the Sheets Need to be multiple of 4 in size. I've just added blank Alpha channel Pixel rows and columns in order to achieve this. That reduced the Memory usage of my spritesheets by 98.5%, from 45 MB to 0.6 MB!
     
  5. benhall98

    benhall98

    Joined:
    May 26, 2020
    Posts:
    4
    How did you do this exactly? Having huge issues :(
     
  6. AgnosiaGames

    AgnosiaGames

    Joined:
    May 26, 2020
    Posts:
    57
  7. UnityDev291

    UnityDev291

    Joined:
    Jul 21, 2014
    Posts:
    9
    I initially tried change the Build/<WebGL project>.json TOTAL_MEMORY value but that had no effect whatsoever. What eventually worked for me in Unity 2019.4.15f1 was adding the TOTAL_MEMORY value in the WebGL index.html where the Unity instance is created i.e.:

    <script>
    var unityInstance = UnityLoader.instantiate("unityContainer", "Build/PreSizeOnlineDebug.json", {TOTAL_MEMORY: 1610612736, onProgress: UnityProgress});
    </script>
     
    Kasaie likes this.