Some digging in the log suggests that it's an out of memory condition that causes the later weirdness. But I suspect that the memory leaking isn't cause by this method in particular. As far as I can tell, it releases its context properly, right?