QuadtreeRasterOverlay sub-tile cache size accounting is wrong #958
Labels
bug
Something isn't working
performance
Improvements to performance, including reductions in memory usage
QuadtreeRasterOverlay
has a small cache that is intended to briefly store decoded raster overlay tile images that span multiple geometry tiles, so we don't need to decode them multiple times (or download them multiple times in the hopefully-unlikely event that the requests aren't cached).But it doesn't appear to be working correctly.
QuadtreeRasterOverlayTileProvider
has a_cachedBytes
field. When a new overlay image is loaded, this field is immediately incremented accordingly. The code that later decrements this field looks like this:This snippet is executed when we're removing this tile from the cache because the cache is full and this tile is the one that is least-recently-used. It is not necessarily true that this image is unused when this happens. And because of that
use_count() == 1
check, if this tile happens to be in use elsewhere when it's evicted from the cache, we'll never subtract its bytes.As a result, over time (and it doesn't take very long), we'll think the cache is completely full at all times and each new image will be evicted immediately, making the cache pretty close to useless.
I think the solution is simply to remove that
use_count() == 1
check. When we evict an image from the cache, we should always reduce the number of bytes in the cache accordingly. Based on the comment, when I wrote this, I seemed to be hung up on the question of whether the image would actually be freed. But the freeing doesn't matter; all that matters is whether this image is kept in the set of tiles temporarily kept around even though they're potentially unused.The text was updated successfully, but these errors were encountered: