fix allocation size calculation bug