duplicate the buffer to avoid concurrent access issue.