Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

How to define TOTAL_MEMORY in Production.framework.js

Discussion in 'Web' started by thomasneuro, Jan 24, 2022.

  1. thomasneuro

    thomasneuro

    Joined:
    Mar 22, 2019
    Posts:
    8
    Hi,
    I recently updated Unity from 2018 to 2021 version and so far in the Editor everything works fine now. Only when I compile for WebGl build I always run into this error:

    An error occurred running the Unity content on this page. See your browser JavaScript console for more info. The error was:
    ReferenceError: TOTAL_MEMORY is not defined
    _GetTotalMemorySize@http://localhost:8000/Builds/WebGL/Current/Production/Build/Production.framework.js:280:21312

    In my created production.framework.js file the only usage of this is "function _GetTotalMemorySize(){return TOTAL_MEMORY}"

    I tried setting this var somehow in the index.html template file but without success, so I'm really running out of ideas and I find it very strange that I dont find anything about this topic. So it look like there is some uncommon mistake on my side.

    If i manually go through the production.framework.js file and change it to "_GetTotalMemorySize(){return 0}" together with some other Memory getters then the build is running.

    I really hope someone can point me in the correct direction as I already spent a lot of time on that issue and I think this manual fix is not the correct way to go. Thanks for help
     
    Last edited: Jan 24, 2022
  2. thomasneuro

    thomasneuro

    Joined:
    Mar 22, 2019
    Posts:
    8
    I still did not find a solution to fix it properly, really no one there that could give a hint? The exact Unity version im using is 2021.2.7f1
     
  3. dimitroff

    dimitroff

    Joined:
    Apr 3, 2013
    Posts:
    131
    Bump for that problem, we are in the same boat after moving to 2021, from 2020?
     
  4. thomasneuro

    thomasneuro

    Joined:
    Mar 22, 2019
    Posts:
    8
    Hi, sorry forgot to post my solution. Found out in the project the Kongregate WebGl utilities were used for logging the memory usage. These libs were merged and they are using the TOTAL_MEMORY var. Im on another laptop so I cannot look for the exact code parts, if you need more information let me know.
     
    michailBreachGG likes this.
  5. thomasneuro

    thomasneuro

    Joined:
    Mar 22, 2019
    Posts:
    8
  6. xavicarosilvente

    xavicarosilvente

    Joined:
    Nov 8, 2018
    Posts:
    8
    Hello, I don't quite understand how you solved it, could you give a more specific example because the TOTAL_MEMORY is not defined keeps appearing and I would like to be able to solve it, thanks!
     
  7. JamesA24

    JamesA24

    Joined:
    Sep 6, 2018
    Posts:
    28
    Hello! I just today had this come up for my WebGL builds, and discovered what was causing it for me. I'm sharing the info here in-case it can help anyone else.

    In the ProjectSettings.asset file, there is a setting called "enableCrashReportAPI". I had set this to 1 a couple days ago, but I don't remember where in the editor I had enabled it. I opened the project settings file in a text editor and set it's value to 0. My WebGL builds were working again as intended.

    Hope this helps.