I think we should first lock the histogram and then clear the sample.