Is variable assignment expensive compared to a null check? For example, is it worth checking that foo is not null before assigning it null?
if (foo != null)
This will have little or no effect. I don't think you could even create a benchmark to demonstrate the difference.
In fact, some would argue that assigning to null at all is a code smell (see the PMD detector for NullAssignment):
Assigning a "null" to a variable (outside of its declaration) is usually bad form. Some times, the assignment is an indication that the programmer doesn't completely understand what is going on in the code. NOTE: This sort of assignment may in rare cases be useful to encourage garbage collection. If that's what you're using it for, by all means, disregard this rule :-)
In general, I'm personally leery of anything that attempts to encourage garbage collection (you almost always get effects that you didn't expect).