I'm new to C Sharp, and writing a game w/ the XNA Framework. I've created a project that's a heavily modified version of the "Platformer" XNA starter kit.
I'm seeing (seemingly) random fluctuations with the framerate. Sometimes it'll run at 60 FPS the whole time, sometimes it'll start at 60 FPS then drop to 49-52, and othertimes it'll drop to 49-52 immediately. Using Fraps to display framerate (not recording video to disk).
The unique nature of this game requires that it run at 60 FPS consistently.
So it seems some race condition or random factor is causing a difference between individual runs of the exe. Numerous rebuilds make no difference.
This fluctuation occurs on both my desktop and laptop with exactly the same frequency, so it's not an issue w/ hardware, anti-virus, etc.
I've searched about how to lock framerates in XNA, and my code seems to be doing much of what it needs to do, including an attempt to clamp at 60 FPS (using IsFixedTimeStep, SynchronizeWithVerticalRetrace).
The game is absolutely capable of 60 FPS from beginning to end, I see it all the time. When it's running at 60 FPS it does not tax CPU, RAM or any other resource as far as I can tell.
Anyone else experienced this?
Thanks, - S
I would check whether these periodic slowdowns coincide with GC events, specifically of generations 1 or 2. From what you're describing, that seems quite plausible. If so, look at whether you can reduce object churn in your code via reuse, stack allocations, etc.