As Mike correctly pointed out, image surfaces are kept in the cache, which only keeps on growing.
This cache needs to become an LRUCache. Care has to be taken that the ImageSurfaces are correctly disposed (otherwise we leak memory).
Disposing the ImageSurface can only happen if no other thread is using it. All rendering happens on the mainloop. So when implementing this, override the ExpireItem method of LRUCache and proxy the dispose to the main loop, so it gets serialized with the rendering (and is thus safe).
We need to make sure that if an item is expired from the cache, that it will always get re-added.
As Mike correctly pointed out, image surfaces are kept in the cache, which only keeps on growing.
This cache needs to become an LRUCache. Care has to be taken that the ImageSurfaces are correctly disposed (otherwise we leak memory).
Disposing the ImageSurface can only happen if no other thread is using it. All rendering happens on the mainloop. So when implementing this, override the ExpireItem method of LRUCache and proxy the dispose to the main loop, so it gets serialized with the rendering (and is thus safe).
We need to make sure that if an item is expired from the cache, that it will always get re-added.