Skip to content

Memory isn't freed after entity removal #245

@redain

Description

@redain

I noticed that memory consumption slowly growing over time in one of my prototypes. Seems like after entity removing memory consumption is not decreasing.
I was able to reproduce it in a fresh new crate as well with a following code:

use legion::*;

#[derive(Default, Clone, Copy)]
pub struct Dummy {
    pub field_1: u128,
    pub field_2: u128,
    pub field_3: u128,
    pub field_4: u128,
}

fn main() {
    let mut ecs = World::default();
    loop {
        let ids = ecs.extend([(Dummy::default(),); 100].to_vec()).to_vec();
        for id in ids.iter() {
            ecs.remove(*id);
        }
    }
}

clear() for the entire World doesn't help as well.
Note that call to len() method of the World returns correct number of entities (in the example above at the end of each loop iteration it will show 0), which means that removals were successful.
Was tested both on debug and release.
Legion version: 0.4.0
OS: Windows 10

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions