Added OutOfMemoryError checks. If it catches it, clears the GC then tries again.
Merge pull request #1 from Gregadeaux/master

Oh Java...