add a configurable constant MAX_TAG_BUFFER_CAPACITY to control the threshold for clearing the buffer