diff options
author | Sven Gothel <sgothel@jausoft.com> | 2010-10-14 18:39:42 +0200 |
---|---|---|
committer | Sven Gothel <sgothel@jausoft.com> | 2010-10-14 18:39:42 +0200 |
commit | 6ced17f0325d5719e992b246ffd156e5b39694b4 (patch) | |
tree | c8618ebe347466e26c5ac8feb818b6844761121e /src/jogl/classes/com/jogamp/opengl/util/AnimatorImpl.java | |
parent | 29999cf3b7616c8ab58f4483c672e30076fbb3e4 (diff) |
Fix: Memory consumption
Observing memory consumption showed:
1 - 'traceLock' debug stack traces (GLContextLock)
2 - massive Iterator usage
(1) is fixed, ie only enabled in DEBUG mode, like we have done in RecursiveLock before
(2) Using an Iterator on ArrayLists with a low element count < 100,
as it is usual in our use cases, is observed not to be faster
than accessing the elements via an index (-> TestIteratorIndexCORE.java ).
On the contrary, the index implementation was a bit faster.
Further more, these Iterators were massively used on the fly during animation,
hence their memory managment even impacts fluent processing/animation.
Recoded all animation related (display, surfaceUpdated, ..) loops using an index.
Diffstat (limited to 'src/jogl/classes/com/jogamp/opengl/util/AnimatorImpl.java')
-rw-r--r-- | src/jogl/classes/com/jogamp/opengl/util/AnimatorImpl.java | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/util/AnimatorImpl.java b/src/jogl/classes/com/jogamp/opengl/util/AnimatorImpl.java index e4bf8d711..8f2715e0a 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/AnimatorImpl.java +++ b/src/jogl/classes/com/jogamp/opengl/util/AnimatorImpl.java @@ -44,20 +44,26 @@ class AnimatorImpl { public void display(AnimatorBase animator, boolean ignoreExceptions, boolean printExceptions) { - Iterator iter = animator.drawableIterator(); - while (animator.isAnimating() && !animator.getShouldStop() && !animator.getShouldPause() && iter.hasNext()) { - GLAutoDrawable drawable = (GLAutoDrawable) iter.next(); - try { - drawable.display(); - } catch (RuntimeException e) { - if (ignoreExceptions) { - if (printExceptions) { - e.printStackTrace(); + List drawables = animator.acquireDrawables(); + try { + for (int i=0; + animator.isAnimating() && !animator.getShouldStop() && !animator.getShouldPause() && i<drawables.size(); + i++) { + GLAutoDrawable drawable = (GLAutoDrawable) drawables.get(i); + try { + drawable.display(); + } catch (RuntimeException e) { + if (ignoreExceptions) { + if (printExceptions) { + e.printStackTrace(); + } + } else { + throw(e); } - } else { - throw(e); } } + } finally { + animator.releaseDrawables(); } } |