optimize memory cost while iterating data segments in bitmap