High FPS but getting lagspikes

Started by Epicbo, April 25, 2012, 12:09:41

Previous topic - Next topic

Epicbo

This issue has been bothering me for quite some time now. Since I switched to rendering using VBOs, I've been getting lagspikes. It's not because my computer cant handle it, I get thousands of FPS ingame but still the game randomly decides to freeze for some ms. The spikes usualy last 30-100 ms but some may last up to 500 ms. It seems like the lower my framerate is, the worse the spikes are (though, having 1000-2000 fps shouldn't give me 100 ms spikes). Using Display.sync(60); makes the spikes less common/less bad but they're still there. Also, using sync(60) makes the game randomly choppy for a few seconds, and then return to normal, and then choppy again etc. Kind of how it would be like if the fps suddenly droped to 20-30, but the FPS is actually 60 during that time.

I understand it's hard for you to help me without seeing my code. But if you have any idea what could be causing this, please tell me. Or if you had the same problem yourself but managed to solve it, then tell me how you did it.

Thanks.

CodeBunny

Are you using LWJGL 2.8.3 or the nightly build? There is an updated Display.sync which may fix your problem.

kappa

The spike could also be caused by Java's garbage collector. Are you creating any garbage?

Epicbo

Quote from: CodeBunny on April 25, 2012, 16:23:48
Are you using LWJGL 2.8.3 or the nightly build? There is an updated Display.sync which may fix your problem.
Im using the nightly build.

Quote from: kappa on April 25, 2012, 16:26:42
The spike could also be caused by Java's garbage collector. Are you creating any garbage?
I don't know. I don't i'm creating enough for it to have a noticable effect. Im actually starting to believe that theres something wrong with my drivers or something. I let a few of my friends test the game and none of them could notice the lag.

Edit: Nope! Updating my drivers did not change anything.

RiverC

Epicbo, The lagging sometimes is caused by system memory load... if you're in a Windows environment, especially if you use Netbeans, Firefox, or other memory hogs over time Windows will get a little freaky on high-performance stuff like games. Sometimes just shutting down and restarting removes the problem. Also, given that Netbeans can be a beast, one thing I do is run my DIST package outside of Netbeans, with no java apps running. That gives a better feel for what it might really be like for the player, and controls some more variables in the GC/GL lagspike equation.

I'm told however that there's never been a perfect fix for lagspikes in Windowed mode.