- Home /
Memory settings for WebGL content: Array Buffer Allocation Failed vs. Out of Memory Exception
I am struggling with choosing the right memory size for my WebGL game Silly World Series. I've read all unity answers threads I could find on the topic of WebGL Build memory size, but I have some questions.
For the record, my WebGL Memory Size is currently set to 400Mb.
Error Messages
My game is live in the AirConsole store and has been played about 300 times since I uploaded it yesterday. We have a tool (developers console) that saves javaScript errors that users experience, to help us track issues. The tool reports the following errors:
Uncaught RangeError: Array buffer allocation failed
Occurred in 23 cases / ~5%
To make sure I get this right: This error occurs when the content is loading, and the browser tries to allocate 400mb of memory, but the browser says "Nope, can't give you that much." Is that correct?
Uncaught Exception: Out of Memory
Occurred in 7 cases / ~1%
Again, to make sure I understand correctly: this is what shows up when the game is running, but the 400mb aren't enough to run it anymore. Correct?
Uncaught RangeError: Invalid Array Buffer Length
Occurred in 8 cases / ~1%
I have no idea what this one is about. Any ideas?
Weird issues / Inconsistencies
Someone tried to play the game using Firefox on Windows 8.1 and a powerful gaming PC. They got a message saying "The browser could not allocate enough memory for the WebGL Content", which I assume is what shows up as "Array Buffer allocation failed" in my dev tool. (Using Chrome on the same PC worked)
Which factors determine how much memory Firefox can allocate? Because we've tested it using Firefox on a Macbook Pro and had no memory issues. Is there a setting for how much memory the browser can allocate?When testing on our Macbook Pros, we've never run into any "out of memory" issues (regardless of browser), even with a smaller memory size than 400mb. On my coworker's Macbook Air however, the game runs out of memory halfway through. I realize that the game might not always use the exact same amount of memory, but since it happens consistently on one computer and never on the other, I wonder: Why would the 400mb be enough on one computer but not the other?
.
Solutions?
Since it's very frustrating for players to start playing the game and then running out of memory, I am more inclined to increase the memory size: I'd rather people know if they can run the game at the beginning, instead of getting interrupted halfway through.
However: The more content I add, the bigger the memory will have to be, the fewer people will be able to play my game - is that something I just have to accept or can I do anything about it?What can I do to reduce memory usage? I'm pooling objects and caching variables as best I can. What other things have an impact on how much memory my game will need? (For the record: code stripping is enabled, I'm making 'fastest' builds, import settings of textures etc. are set to 'compressed' and appropriate sizes...)
I have discovered (in the UnityLoader.js file) that I've misinterpreted the meaning of the "out of memory" message. Getting "out of memory" (lowercase o) as an error message is the exact opposite of a user getting "Out of memory" (uppercase O) as an alert.
The three error messages "out of memory", "invalid array buffer length" and "array buffer allocation failed" seem to all mean the exact same thing, different browsers/user agents merely send it in a different way. For any of these three messages, the alert shown to the user is: "The browser could not allocate enough memory for the WebGL content. If you are the developer of this content, try allocating less memory to your WebGL build in the WebGL player settings."
On the other hand, if there was really an issue of there being too little memory allocated, it would show up in my console with the message "Cannot enlarge memory arrays", and show the user an alert saying "Out of memory. If you are the developer of this content, try allocating more memory to your WebGL build in the WebGL player settings."
This has never happened with my project, meaning I can probably use less memory than the 400mb I've been allocating.
Your answer
![](https://koobas.hobune.stream/wayback/20220612083040im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
WebGL memory size in Player Settings? 2 Answers
WebGL Build Out of Memory Github Pages Not on Local Host 0 Answers
I have this out of memory issue when running my webgl game in iOS. 0 Answers
Not able to load large obj Files in Unity Webgl 0 Answers
Unity WebGL build memory discrepancy in local hosted and web hosted 0 Answers