2
\$\begingroup\$

I'm developing a 2D game using MonoGame. I've got a square on the screen I can move around. The problem is that about once a second, the square jumps a bit. Using a frame counter I found here I've concluded that my FPS drops from 59.9988 to either 59.3988 or 59.6988. It's skipping frames.

I've tried googling and searching forums for hours but can't find a solution. I've commented out everything in the Draw method of the Game class except for the frame counter and it still happens. I even tried creating an entirely new MonoGame project with nothing in it except the frame counter and still I would get the frame skips.

Setting IsFixedTimeStep = true does not fix the issue. I do get higher frame rate, but also not as high as I would expect (not higher than ~100). I've looked at the diagnostic tools and there is no garbage collection going on (no yellow triangles).

I am completely at a loss. If anyone has any insights to offer, it would be much appreciated.

\$\endgroup\$
  • 1
    \$\begingroup\$ I could be the garbage collector. Without code it is near impossible to tell you what is wrong. Can you post your movement code? \$\endgroup\$ – Felsir Jul 15 '16 at 11:18
1
\$\begingroup\$

I guess your monitors refresh rate is about 100Hz. If you disable IsFixedTimeStep and SynchronizeWithVerticalRetrace you will probably see the FPS shoot up.

It's almost impossible that there is no garbage collection happening. I'd say run a profiling tool and check what if anything is being allocated every frame. You might find an issue in Monogame that can be fixed even.

The frame counter will allocate memory every frame as well since it is using String.Format to generate the message to print. It's certainly not a lot of memory though, probably around 1kb per second or something depending on your framerate.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.