Thanks! I am very proud about pulling off the garbage collection implementation (but of course it wasn’t my idea!). Otherwise I actually find code optimisation a bit stressful, but I keep making really intense games so I guess I have to learn some things
Just regular factories actually.
Each block has two tables associated with it - permanent data (such as what type it is, location, etc). It also has temporary data when it is spawned (game object reference, AABB id for collisions, etc). The table with temporary data is created/deleted when I perform culling.
I’m not entirely sure what exactly stresses out the garbace collector. What I found, surprisingly, is that deletion is much costlier than creation. I haven’t narrowed down whether that is go deletion or table splicing or something else.
When I have to spawn block “sectors” (sector is what I call a set of blocks that ~cover the player’s window), I batch them so that one sector is spawned each frame. When I have to remove sectors, I batch it so that one row of a sector is deleted each frame (so it takes about 20 frames to remove one sector). If I delete an entire sector in a frame, I get a stutter!