Reallocate memory for bitmaps only when necessary.