apotapov / gdx-artemis

Fork of artemis entity-system (http://gamadu.com/artemis/) refactored to integrate with Libgdx (http://libgdx.badlogicgames.com/)
Other
53 stars 5 forks source link

Component pooling? #23

Closed orlof closed 10 years ago

orlof commented 10 years ago

This is not an issue, but a question.

Do you have any performance data whether component pooling actually increases performance? The consensus in SO seems to be against it. E.g.

http://programmers.stackexchange.com/questions/115163/is-object-pooling-a-deprecated-technique

apotapov commented 10 years ago

You are not required to use component pooling if you don't wish to. You can simply create an Artemis World with a custom component manager that doesn't do any pooling.

With that said, I've read the SE post that you linked. None of the responses mention game development as an application, but talk about Java for the general use case. In high performance environment of gaming, especially that in the mobile world, Garbage Collection can wreak havoc on game performance. I've seen the frame rate drop down quite significantly when Android GC decides to make a round.

In adding pooling to gdx-artemis, I mostly followed recommendations of libgdx and this book: http://www.amazon.com/Beginning-Android-Games-Mario-Zechner/dp/1430246774. It's written by the author of Libgdx. (I really recommend this book if you decide to pursue Android game development. It's a great basic introduction.)

If you are not developing for mobile, perhaps memory allocation and Garbage Collection will not be a big deal. However, personally I prefer to avoid Garbage Collection as much as possible to keep my games running smoothly.

Here's another post that talks about this very issue:

http://stackoverflow.com/questions/2484079/how-can-i-avoid-garbage-collection-delays-in-java-games-best-practices

PS This is also the reason I use libgdx containers rather than java native ones. They are a lot more memory efficient.

orlof commented 10 years ago

Thank you for the very informative response. I am not developing for any mobile platforms, but I will study the links you mentioned.