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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

(Out of memory) Does anyone have this error when running on webgl?

Discussion in 'WebGL' started by stanleykwan, Sep 13, 2022.

  1. stanleykwan

    stanleykwan

    Joined:
    Nov 18, 2021
    Posts:
    6
    I am using Unity 2020.3.38f1, have this error when running the webgl build.

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


    What I am doing is load one image (around 500kb size) at runtime, I use the following code, it works when I run on Unity Editor, but fail with the above error when running on Webgl build.

    Code (CSharp):
    1. private IEnumerator GetTexture(string imageUrl)
    2.         {
    3.             using UnityWebRequest uwr = UnityWebRequestTexture.GetTexture(imageUrl);
    4.             _currentWebRequest = uwr;
    5.             yield return uwr.SendWebRequest();
    6.             if (uwr.result != UnityWebRequest.Result.Success)
    7.             {
    8.                 Debug.Log(uwr.error);
    9.                 uwr.Dispose();
    10.             }
    11.             else
    12.             {
    13.                 var tex = DownloadHandlerTexture.GetContent(uwr);
    14.                 myIcon.sprite = Sprite.Create(tex, new Rect(0.0f, 0.0f, tex.width, tex.height), new Vector2(0.5f, 0.5f), 100.0f);
    15.  
    16.                 //Now we are able to click the button and we will pass the loaded sprite :)
    17.                 myIcon.gameObject.SetActive(true);
    18.                 myButton.interactable = true;
    19.  
    20.                 uwr.Dispose();
    21.             }
    22.         }
    Does anyone have idea how much memory limit is for the webgl? And how to configure it?

    Thanks a lot
     
  2. stanleykwan

    stanleykwan

    Joined:
    Nov 18, 2021
    Posts:
    6
    Problem solved after change from unity 2020 to 2021, thanks
     
  3. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    4,191