-
-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Garbage collection for Archetypes #277
Comments
Hi, and thanks for submitting this! First of all, which version of Miniplex are you using exactly? Your code looks like you're using one of the 2.0 betas — which one? To be entirely fair, I'm not sure if there really is a memory leak, or if there is one, that it's because of the archetype creation. A call to If for some reason multiple instances of the same archetype are being created, that would be a bug. May I ask what steps you took to identify this memory leak? Thanks! |
Addendum: I'm honestly surprised that the code example you've posted here works at all, considering you're creating an iterator using I'm assuming you're using 2.0b3 — please let me know if this is wrong. The implementation of Heads-up: because the nature of how |
Sorry, I should have mentioned. I am using What I really want is to have a component that only rerenders when the entities selected by the predicate change. My actual code presently caches the If you're moving towards the API you describe in #275, it would be awesome to have something like this (again, this is just pseudocode): function MyList({ section }) {
const entities = useQuery(world, React.useCallback(
q => q.with("location").where(e => e.location.section === section),
[section]
));
return (<div>...</div>);
} If it's possible to create such a |
Hello! I stumbled upon this library looking for a good array-of-structs ECS system and I've been working with the for the past month or so in my game. I'm building a renderer using React, but I am not using
miniplex-react
(frankly, it doesn't seem to provide anything I would use that isn't very easy to implement myself).I want to be able to render a list of entities matching a criteria, and I would like to be able to use an Archetype for this, however this causes a memory leak. I have a
Location
component which has asection
field, and my React component should render all entities which have a givensection
. That's easy:This has a memory leak, since it creates a new Archetype every time the section prop changes, but Archetypes are never removed. The feature request is simple: once the last listener for a Bucket is removed, the Bucket should remove its own listeners. If future listeners for the bucket are added, the Bucket should reattach its own listeners and recalculate its entities.
I know I can create a global cache of every section and look up in that cache when rendering my component... but a cache without expiration is still just a memory leak.
Obviously this isn't critical, but since you're changing the API for 2.0 I figured now was an appropriate time to raise this. Thanks for continuing work on this library!
The text was updated successfully, but these errors were encountered: