Tags: , ,

Unity’s garbage collector is old and slow. As garbage from your scripts piles up, the garbage collector will eventually run. When it does, it runs all at once instead of spreading the work out over multiple frames. This means you get a big spike on one frame causing your game to momentarily freeze. One of the best ways to get around this is to use an “object pool” to reduce the number of objects eligible for garbage collection. After all, if there’s no garbage then there’s nothing to collect! For more on this strategy as well as a class you can use to implement it, read on!

Read the rest of this article »