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. Dismiss Notice

Webgl out of memory error.

Discussion in 'WebGL' started by TroyFabcomLive, Nov 2, 2020.

  1. TroyFabcomLive

    TroyFabcomLive

    Joined:
    Oct 2, 2020
    Posts:
    12
    I am running into this error.
    Screen Shot 2020-11-02 at 10.46.31 AM.png
    This is the debug statement I've been shown.
    Screen Shot 2020-11-02 at 10.46.45 AM.png
    From looking up allowing memory growth, I've found that I can just supposedly put this in an editor script.
    Is this any different from throwing this into a c# script? Or does this go into the define symbols portion in the publishing/other settings.
     
  2. jukka_j

    jukka_j

    Unity Technologies

    Joined:
    May 4, 2018
    Posts:
    944
    Memory growth should be enabled by default. Only if you are targeting asm.js (output file is .asm.js instead of .wasm), or if you are using multithreading, memory growth will be disabled. Is one of those the case for you? If so, you'll need to increase WebGL Player Settings memorySize instead. (use C# editor script to do that)
     
  3. TroyFabcomLive

    TroyFabcomLive

    Joined:
    Oct 2, 2020
    Posts:
    12
    I'm not 100% sure which one I am targeting. Where can I check that target? also, where can I check that I am multithreading? Lastly, in the c# script, where should I throw the memorySize line at? outside the namespace? Or possibly within the start method?
     
    Last edited: Nov 2, 2020
  4. jukka_j

    jukka_j

    Unity Technologies

    Joined:
    May 4, 2018
    Posts:
    944
    You can check it e.g. by looking at the files that are output to the build directory. If there is a file with ".asm" in it, it is old asm.js. If there is a file with ".wasm" in it, it is never WebAssembly.

    You can use the attached script to force a WebAssembly build, in case that was set to old asm.js setting in your project (that can happen when migrating old projects to new builds, if you once had built asm.js before). See the instructions inside the attached file.

    If you haven't manually enabled multithreading, then that definitely shouldn't be the case. You can double check by setting threadsSupport to false in an Editor script (see https://docs.unity3d.com/2019.1/Doc...ence/PlayerSettings.WebGL-threadsSupport.html). E.g. you can add that directive to the buildWebGL.cs.
     

    Attached Files:

    TroyFabcomLive likes this.
  5. TroyFabcomLive

    TroyFabcomLive

    Joined:
    Oct 2, 2020
    Posts:
    12
    We found out we had some inefficient code running that was causing a memory leak.