"Spike" profiler?
I'm writing a game, and while it's performance is good most of the time, it sometimes slows to a crawl. Normal profiler开发者_JS百科s haven't been a help in this, as they record the whole time my game is running, and the important info in the laggy portions get diluted over all of the smooth sections. Are there any tools or libraries that can help me isolate the problem?
You're almost certainly being hit by garbage collection.
And yes there is a tool for fixing that. You want the CLR Profiler. This will show you exactly where you're allocating memory.
On Xbox the garbage collector will run after every 1MB allocated and it is slow. The Windows GC is much more forgiving, but can still cause frame-rate jitter.
The best way to avoid garbage collection stutters is to not allocate anything while your game is running. Do your allocations during loading screens where the user won't notice.
I recommend reading this post and this post on Shawn Hargreaves' blog.
You say you're going from a frame taking 16ms to 3000ms. So in a long frame, it is spending (3000 - 16)/3000 = 99.5% of its time doing something you didn't expect.
During those 3 seconds, how can you find out what it's doing?
Just pause it a few times, and check the call stack.
The chance you won't see what it's doing on each pause is 0.5%
If it's in the garbage collector, this should confirm it. If it's doing something else, it will also tell you.
精彩评论