It looks like it could be a problem with the browser… I added some debug code and could check that each time we dispose a texture, we do execute context.deleteTexture
for that texture, which should free the GPU memory, or at least mark the memory as being “reclamable”: it’s not required that the browser immediately releases the memory.
Also, I saw with nvidia-smi that once I reach my max GPU memory, refreshes still work for 5 or 6s, meaning the browser is able to reuse GPU memory under-the-hood: the used memory stays at max during all that time, proving (I think) that GPU memory is not really freed by the browser, but that it is able to recycle the released textures. But at some point it is not able to do it anymore for some reasons…
Note that it works in WebGPU, memory does not raise with each refresh.
It looks quite like Memory Leak in Screenshots - #19 by Evgeni_Popov, but I don’t know what the final outcome of this case was.