Avoid allocating a big buffer for samples on the stack.