Skip to content

Garbage collection and list iteration improvements#515

Merged
pspeed42 merged 3 commits into
jMonkeyEngine:masterfrom
tiatin:iterator-garbage-collection-improvement
Jun 27, 2016
Merged

Garbage collection and list iteration improvements#515
pspeed42 merged 3 commits into
jMonkeyEngine:masterfrom
tiatin:iterator-garbage-collection-improvement

Conversation

@tiatin
Copy link
Copy Markdown
Contributor

@tiatin tiatin commented Jun 25, 2016

For-Each loop creates Iterator object and uses hasNext and next methods, which are slower, than manual iteration. Also allocating Iterator object increases work for GC.

Forum post: https://hub.jmonkeyengine.org/t/iteration-over-list-performance-improvement/36250

See test 9 for more details: http://www.devahead.com/blog/2011/12/coding-for-performance-and-avoiding-garbage-collection-in-android/

tiatin added 3 commits June 25, 2016 15:45
For-Each loop creates Iterator object and uses hasNext and next methods, which are slower, than manual iteration. Also allocating Iterator object increases work for GC.

Forum post: https://hub.jmonkeyengine.org/t/iteration-over-list-performance-improvement/36250

See test 9 for more details: http://www.devahead.com/blog/2011/12/coding-for-performance-and-avoiding-garbage-collection-in-android/
Reason for this is that if List is LinkedList, complexity for get(int i) is O(n/4).
…n performance reasons. Fixed bug in SafeArrayList.equals().
@tiatin tiatin changed the title Changed iteration over List from for-each to manual iteration. Garbage collection and list iteration improvements Jun 26, 2016
@pspeed42 pspeed42 merged commit 3f7f9b1 into jMonkeyEngine:master Jun 27, 2016
@tiatin tiatin deleted the iterator-garbage-collection-improvement branch June 27, 2016 07:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants