Use compressBound() and fix memory bug.