You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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)]pubstructDummy{pubfield_1:u128,pubfield_2:u128,pubfield_3:u128,pubfield_4:u128,}fnmain(){letmut 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
The text was updated successfully, but these errors were encountered:
This is typical for Rust's built-in types too. Vec will keep its allocation after you remove or clear. It only reduces the allocation if you call shrink_to or shrink_to_fit. Something like that could be added to World as well, which the user could then call periodically.
This is typical for Rust's built-in types too. Vec will keep its allocation after you remove or clear. It only reduces the allocation if you call shrink_to or shrink_to_fit. Something like that could be added to World as well, which the user could then call periodically.
If I remove items from Vec and add the same amount of items later, previously allocated memory will be reused and memory consumption will not grow - it will be constant for the same amount of items, but in case with removing and adding entities seems like memory is not reused and it's consumption is only growing with each add/remove iteration.
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:
clear()
for the entireWorld
doesn't help as well.Note that call to
len()
method of theWorld
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
The text was updated successfully, but these errors were encountered: