Xna Xbox framedrops when GC kicks in

I'm developing an app (XNA Game) for the XBOX, wich is a pretty simple app. The startpage contains tiles with moving gif images.

Those gif images are actually all png images, wich gets loaded once by every tile, and put in an array. Then, using a defined delay, these images are played (using a counter wich increases everytime a delay passes).

This all works well, however, I noticed some small lag every x seconds in the movement of the GIF images. I then started to add some benchmarking stuff: http://gyazo.com/f5fe0da3ff81bd45c0c52d963feb91d8

As you can see, the FPS is pretty low for such a simple program (This is in debug, when running the app from the Xbox itsself, I get an avg of 62fps). 2 important settings:

Graphics.SynchronizeWithVerticalRetrace = false;
IsFixedTimeStep = false;


Changing isFixedTimeStep to true increases the lag. The settings tile has wheels wich rotate, and you can see the wheels go back a little every x seconds. The same counts for SynchronizeWVR, also increases lag.

I noticed a connection between the lag and the moment the garbage collector kicks in, everytime it kicks in, there is a lag ...

Don't mind the MAX HMU(Heap memory usage), as this is takes the amount of the start, the avg is more realistic.

Here is another screen from the performance monitor, however I don't understand much from this tool, first time I'm using it...

Hope it helps: http://gyazo.com/f70a3d400657ac61e6e9f2caaaf17587

• How long was that profiling session for? – Jonathan Dickinson Feb 21 '12 at 12:09
• About a minute or 2 – Mortana Feb 21 '12 at 13:30
• The trick is to have no garbage collection. Create a memory pool that you use anytime you allocate memory for a new object. – Nic Foster Feb 21 '12 at 15:31
• Ok - you have allocated 100MB worth of objects in 2 minutes. The XBox is very sensitive to excessive garbage. Remember anything in Update() or Draw() is getting called probably 60 times per second. – Jonathan Dickinson Feb 21 '12 at 16:13
• @JonathanDickinson That's what I noticed, my Draw() method checks the current page state, and it won't do anything unless it has the right state to act. BUT the Update() method isn't keeping the pagestate in mind, which makes it so that EVERY custom component (and there are loads of them, I made a little GUI framework) that is created, get's his Update() called. I'm pretty sure I'm doing the State stuff wrong, so I'm now into reading this: create.msdn.com/en-US/education/catalog/sample/… I'll rebuild the project tomorrow with the new screenmanager. Keep you posted! – Mortana Feb 21 '12 at 19:47