-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Return removed components to the component pool #58
Comments
Once we add a component using a generated method like What do you think? |
Also, I think it's time to also add tests for the actual logic of the generated output, not only tests for the expected output of the generator. I'd like to add tests for the four component types (standard, flag, single std, single flag) |
Creating new components would be cheaper... |
I see... The issue I stumbled upon, and thus discovering this intricacy, was that my object count was increasing a lot, I had a lot of entities which were being destroyed and created, and the GC was turning on once in ~10 secs and that was stuttering my game :/ I am tinkering with the code right now, trying to figure out another way... |
Here's my test, if you're interested: |
|
added |
I found this article summarizing some garbage tests with events and delegates: http://jacksondunstan.com/articles/3264#comments and they confirm your findings. 104 bytes for creating a delegate and then another 208 bytes when adding that delegate to an event if it is the second+. |
I could try writing a custom event system for Entitas. Might be (or not be) more efficient |
I have an idea which works completely without events. An entity could have an array of stacks (similar to the array which holds the components). When removing a component it will get the stack at index and push the component. Done. If no stack exists, it doesn't (which means we're using entitas without the code generator) |
fyi, I started writing tests for the existing generated component extensions. After that I will implement my idea test driven. |
Ok, I found a way which works without events. |
See #60 |
A bit late but I checked through your solution, smart moving up the pools and creating a function to retrieve the correct one. Nicely done! |
Thanks :) |
As a performance optimization the Code Generator creates component pool for each generated component type (https://github.com/sschmid/Entitas-CSharp/blob/develop/Tests/Tests/Entitas.CodeGenerator/Fixtures/PersonComponent.cs#L15)
When you replace or remove components, the old component gets pushed to the component pool.
However, neither e.RemoveAllComponents() nor pool.DestroyEntity() will make use of the component pool and won't push them back.
That should be fixed...
The text was updated successfully, but these errors were encountered: