Currently, every sample is allocated. Maybe it is better to do this only once at the start of the run, and overwrite the values only.