I'm working on a game for android that requires some processing of the data model, before it can be rendered correctly.
It's not much, but it requires me to assemble a new List every frame, with some list elements in it (between 4 and 500).
The element objects are very small convinience-things like the Vector3f, employing only 2 integers, and 2 floats.
The list assembly is essentially copying a similar list' (the raw model) important values, and doing some minor tweaking with some of the values. The minor tweaking is virtually nothing, in terms of CPU usage.
I'm afraid of the list assembly though. I have not been able to test my game on android yet, as I'm waiting for a new workstation to arrive, but the game runs smoothly on PC.
I have the following questions about performance in this situation.
Is it better to not reinitialize my list every frame, and just clear it?
Would I be far
better off using an object pool for these small short-life objects?
Is there a chance the garbage collector in android is actually capable of cleaning this up, without showing lag?
Should I not worry about it, and get on with my game?
I'm quite new to the platform, so I don't know how well I have to manage object creation and garbage collection. I know that I can slack off quite a lot in this respect on the PC.
In the past, I have drawn the model directly so I never really had this problem. It could very well be that this exercise of making a few new objects to use for rendering is common practice, and I'm just stressing over something that hasn't been a problem in Java for a long time. Reading about memory fragmentation, and garbage collector lag makes me nervous, but it could be that those issues only are with huge
datamodels, and not applicable in this case. Anyway, please clue me in!
Thanks for reading, and perhaps responding. Cheers!