In case it's unclear, I agree with you that we should be optimizing this function.
I merely tried to point out that in the realm of all possibilities, updating the string every frame isn't the case with the highest usage percentage.
my use case is not as naive as it sounds.
That's not what I wanted to say, sorry if it came across like that.
Even with your use case the ratio between "animated" text and "static" text will weigh in favor of static texts (i.e. you render more frames with text that hasn't changed between frames, than text that has changed between frames).
As such it's best to optimize for the "static" text rendering and accept some performance penalty when "animating" text.
Hope that was a bit clearer to what I meant.
So the collection is delayed until the collector thinks it needs to, it will look like a memory leak in between collections.
GC actions are unpredictable, which is one of the major downsides of GC