Memory Management – Part 3

So I finally have a little bit of time after the Christmas rush to finish off our 3 part post on memory management (see Part 1 and Part 2), by looking at garbage collection. So let’s dive in…

Garbage collection is a feature available to a number of programming languages, most notably .NET languages (e.g. C#), Java and Objective-C (though not currently available on iOS). Basically, garbage collection is kind of like, well, real life garbage collection. When you’re finished with something, you discard it, and at some point in the future everything you’ve discarded will get cleaned up by someone else (i.e. The garbage collector). Sounds like a perfect system, right? Just create what you want, discard it when you’re done and not worry about memory management. Unfortunately, a lot of people (myself included) soon come across the pitfalls of this approach, but with a little knowledge you can play nice with the garbage collector. Firstly, we’ll take a look at how garbage collectors generally work, then at some of the problems we can find ourselves in, and finally the solutions…

Continue reading

XNA Skinned Model Animations

The Skinned Model sample from the App Hub education catalogue is great for getting animated characters into your game, but there’s a bit of a flaw with the export process. The problem is, when you export your character from 3DS Max (and possibly other modelling programs), all you get is one animation, named ‘Take 001’. Wouldn’t it be nice if we could define different animations for different parts of the animation timeline? Well, we’re going to do just that :). As an added bonus, we’ll also be adding in events, so you can be notified when certain parts of your animation are hit.

Continue reading