Skip to content

[Bug] Geometry cache grows unbounded #2508

@timleslie

Description

@timleslie

Describe the Bug

Cache._geometryCache in cache.ts never evicts values, even when the cache is above Cache._maxCacheSize.

Steps to Reproduce

This is purely theoretical. I bumped into this while trying to understand some related (non-buggy) caching behaviour.

The current behavior

Repeated calls to putGeometryLoadObject will insert objects into this._geometryCache without checking the size of this cache.

The internal method _putGeometryCommon calls this.decacheIfNecessaryUntilBytesAvailable, which is clearly intended to cap the cache size. Unfortunately, this method interacts with this._imageCache, not this._geometryCache. As such, we never evict from the geometry cache, and it can grow to unbounded sizes.

There are no other automatic evictions, which can be seen by observing that this._geometryCache.delete is only called on error paths, or if removeGeometryLoadObject is explicitly called externally.

The expected behavior

I would expect _putGeometryCommon to call a version of this.decacheIfNecessaryUntilBytesAvailable that interacts with _geometryCache, not _imageCache.

Note: _putGeometryCommon also calls this.isCacheable, which is also based on _imageCache.

System Information

N/A

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions