If i don’t use my game for a couple seconds a get this errors. Is that normal?
In the console:
Cannot enlarge memory arrays. Either (1) compile with -s TOTAL_MEMORY=X with X higher than the current value 67108864, (2) compile with -s ALLOW_MEMORY_GROWTH=1 which adjusts the size at runtime but prevents some optimizations, (3) set Module.TOTAL_MEMORY to a higher value before the program runs, or if you want malloc to return NULL (0) instead of this abort, compile with -s ABORTING_MALLOC=0
Looks like you have exhausted the 64MB heap memory allocated to the physics engine (ammo.js). Take care to ensure that you are allocating rigid bodies correctly/efficiently.
So you’re saying you have about 100 of those box colliders? That’s definitely not enough to exceed the engine’s 64MB memory pool for physics. Something else must be going on. Have you changed anything in your project that triggered this?
No not that has to do with the points you mentioned. From the beginning I always got the message [object_event] error if the browser was inactive for too long, but I think that’s normal.
I just published a new version. Maybe you see something that could be the cause.
That creates 37 x 37 box bodies (in a script). So that’s 1369 bodies. Beyond that, ammo.js runs out of memory. So if you are creating more than that, yeah, the error is reasonable.
I wonder if it’s possible to set Module.TOTAL_MEMORY early enough to set a larger heap size as suggested in the error message. @slimbuck might have some thoughts on that.
But having played your game, I fundamentally don’t believe it should be utilizing all the physics memory. Do you create all of the rigid bodies + colliders in code or in the Editor hierarchy panel?
I have made a script that allows me to clone the entities from a prefab, so that I only have to make changes in one entity. The entities in the editor are removed after cloning at the start of the game.