I’ve been playing with some basic animation code lately, and put together a small demo program for running in windowed mode. I’m using Canvas/BufferStrategy, and am having horrible results. About once every second I get a ~300ms lag.
It certainly has nothing to do with gc (I can see that with the -verbose:gc option), and using the -Xrunhprof:cpu=samples option, I get:
1 66.47% 66.47% 666 81 sun.awt.motif.MComponentPeer.swapBuffers
2 16.47% 82.93% 165 31 sun.awt.motif.MToolkit.run
Any clues as to what’s going on? My animation loop is very standard. Also, I’m working on Linux and have a new nVidia card.
These problems are causing me to think about manually doing double-buffering using the standard techniques. For windowed-only apps, is this a better solution?