You use special libraries designed for this purpose, that use a static buffer under the hood themselves. Or you just make sure that memory usage increase is low enough that it isn’t a problem. You sometimes have places where they do for example one GC call a day.