correct a bug when shrinking memory