Typically you allocate a buffer that's generously sized for the maximum number of items you think you might need.
Then when your temporary objects change, you fill that buffer from one end, with all the items you currently need, leaving space at the far end when you're drawing fewer items than the max. This way you're just paying the cost of a data upload to an existing buffer, not incurring all the cost of re-allocating a fresh one.
If you ever need more items than you have room for in the buffer, then you can...
(In a development build): crash with an error message saying the predicted max count was too low, so the developer knows to increase it. Simple, but a bit harsh...
Re-allocate a larger buffer automatically, and start using that one instead (and, in a development build, log a warning that the initial max might be too low)
Recycle the oldest / most distant / least apparent objects to make room for new/more important ones
Stop drawing items beyond the cap (usually a last resort, if you have no more memory to spend or no way to prune less-important items from the buffer)