How to Fully Remove Geometries and Textures

Hello,

I’m using Debug Mode to monitor performance in my game and noticed that geometries and textures continue to stack up, even after removing entities.

I’ve used world.deleteEntity(eid) to delete entities, which does remove them from the scene, but the geometry count remains unchanged. I also tried explicitly removing geometry-related components like:

ecs.GltfModel.remove(world, eid)
ecs.SphereGeometry.remove(world, eid)
ecs.Collider.remove(world, eid)

But even with those, the geometry count doesn’t decrease.

Additionally, I’m not sure how to remove textures from memory once they’re no longer used. Is there a correct way to fully clean up objects, including both geometries and textures, to avoid memory bloat?

Thanks for the help!

I’m pretty sure the debug mode display values aren’t correct. I’ve done some testing with this as well. I’ve let the engineering team know. :slight_smile:

Thanks! But just to know, is there a way to deactivate a geometry or texture in a game session?

Because I do have 100s of objects and each object has like 5 more objects. :sweat_smile:

I’m a little bit worried since the geometries and textures stack up throughout the levels, so the performance becomes kind of bad. Sometimes my game even crashes with this error:

Uncaught RuntimeError: Aborted(Cannot enlarge memory arrays to size 75161600 bytes (OOM). Either (1) compile with -sINITIAL_MEMORY=X with X higher than the current value 67108864, (2) compile with -sALLOW_MEMORY_GROWTH which allows increasing the size at runtime, or (3) if you want malloc to return NULL (0) instead of this abort, compile with -sABORTING_MALLOC=0)

remove should be catching it. :thinking:

@christoph_nia Any gotcha’s that we should be aware of here?

Also, I don’t know if this is useful, but I forgot to mention that all of the 100s of objects that I want to manage have the same GLB Mesh.