Median filter has to sort pixels (3x3, or 5x5) and get the median (this is by memory, haven't looked at wikipedia). As such it might be or might not be better solution.
You could do it in-place with a memory cost of one pixel row (for 3x3, or two for 5x5) plus one (or 2) pixels. That might make be worthwhile depending on where you're actually doing it. It might be more efficient - it's worth implementing both to see.
Also it can't be done in-place (or can it?)