Occasionally my game has hicups/dropped frames because of garbage collection. So I am trying to reduce this by removing unnessasary allocations.
Using the allocation tracker in Eclipse I see that my code below:
for (IGameObject obj : mObjects) {
//stuff
}
Is allocating an iterator:
java.util.ArrayList$ArrayListIterator 24 bytes java.util.ArrayList iterator
I can easily change all places where this is happening as mObjects is an ArrayList.
Just out of interest though, will proguard or jit somehow optimise this to a basic for loop? As it seems a shame I have to make my code more verbose to avoid this allocation.