How to calculate the perfect "WebGL memory size"?

Hi,

I am using unity 5.2.4f1 - my game when exported in webPlayer is 15.8meg - that is very low.

I can’t find what memory size i should use, when i am at 1024 meg I am too high, and when i am at 768meg i am too low.

So the question is:

Is there a way to calculate mathematicaly the perfect/optimal memory size ?

thx.

Edit:

I am running the game with 800meg - it crashes time to time, but the strange thing that when i attach the profiler with the webGL game it gives me:
Used total: 81.3meg
reserved total: 89.4meg

Nobody on that ?
Can you guys at least tell me how much you put in ?
for comparison purpose.

I had to debug a memory leak on a WebGL build, and ended up logging memory allocations by editing the Emscripten-generated “dynamicAlloc” function in the resulting JavaScript file. Remember that it is far easier to edit a development build as the resulting code is somewhat legible.

Simply add a few console logs in the correct function, so it looks like:

 dynamicAlloc: (function(size) {
  var ret = DYNAMICTOP;
  DYNAMICTOP = DYNAMICTOP + (assert(DYNAMICTOP > 0), size) | 0;
  DYNAMICTOP = DYNAMICTOP + 15 & -16;
  console.log("Alloc " + size + ", Used: " + ret + ", Free: " + (TOTAL_MEMORY-ret) + "/" + TOTAL_MEMORY);
  if (DYNAMICTOP >= TOTAL_MEMORY) {
   alert("Failed to alloc " + size + ", Free: " + (TOTAL_MEMORY-ret) + "/" + TOTAL_MEMORY);
   var success = enlargeMemory();
   if (!success) {
    DYNAMICTOP = ret;
    return 0;
   }
  }
  return ret;
}),

This way, you’ll have a notice everytime memory grows (a lot at first, but it will quickly slow when you’re near the maximum used memory). It is then a simple matter of putting a reasonable value (the value of the “ret” variable plus some padding) and you should be set.

1 Like

It looks like a good idea, but i am at the step before: i cant even launch the game under 800megs.

What numbers do you get if you take a “Detailed” Memory Profiler capture on your webgl build ?

is this what you ask for ?

What does these numbers means ?

Is someone having the same trouble or is it just me ? Marco, what about those numbers ?

I am not able to see the image you uploaded.

Here is the re uploded file, what do you think ?

Given these numbers, I would expect your content to run with much less memory. do you see any spike in the memory profiler graph ?

Ok, here are some news.

I did remove a few assets, so the project is even lighter, then i updated my ram from 4gigs to 8gigs.
I can now launch the players on firefox with a memory size at 450!

Now i dont know what exactly did the trick, memory update or asset cleaning…

for now it works at least. if i get more information i will keep you informed.