Tracing a stutter.

This is going to be a bit vague, because I can’t give a whole load of detail. I have a really odd stutter in a game I’m working on. The game is perfectly silky smooth, apart from the one specific time when a key is released.

The key itself is a brake mechanism, it basically multiples a vector and some other stuff. The thing is, while the key is being held down and all this funky stuff is going on everything is fine. When you release the key the game stutters for 1/4 to 1/2 a second, but the code is doing less. A lot less.

I’ve been over and over the routines and can’t find any reason for it. And because the stutter happens when the extra load has ended I don’t have anything to isolate.

How do you folks track down odd little hiccups of this kind? Is there any profiling software that might help?

Any advise welcome.


You say the code is doing a lot less. Are you, by any chance, releasing objects when releasing your braking key? If so, your game is maybe trying to do some garbage collection…

It’s either garbage collection or the logic that fires off when the key is released causes one of two things:

  1. movement updates stop for a set amount of frames
  2. movement updates MORE than it should for a set amount of frames

Either one of the above will cause a noticeable stutter. Trace through the logic that fires off on key release. Set some debug points and double check values. Double check logic flow and make sure you are updating things at the proper time and in the proper order.

Garbage collector is fairly east to figure out. I don’t make any new calls outside of constructors/inits in my engine specifically to avoid GC stutters.

If you are using Visual Studio 2015/2017 Community Edition, it comes with a source code profiler as part of the package, which you can avail yourself of.

A profiler such as that included with VS2017 will pinpoint the source of this stall quicker than it takes to type up this response.