Fix Out-of-memory exception, contributed by Ccomp5950