Skip to content

Commit 2aef204

Browse files
authored
fix: A task may only be disposed if it is in a completion state (RanToCompletion, Faulted or Canceled). (#318)
1 parent 3d9a4e3 commit 2aef204

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

GameRealisticMap/Satellite/SatelliteImageProvider.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,10 @@ public async Task<Rgba32> GetPixel(GeoAPI.Geometries.Coordinate coordinate)
135135

136136
private void ClearCache()
137137
{
138-
foreach (var img in cache.Values)
139-
{
140-
img.Dispose();
141-
}
142-
cache.Clear();
138+
// Just clear the reference to the images, and let the GC do the work to release memory,
139+
// as we don't know if a thread has still a reference to one of the images
140+
// The synchronization overhead is not worth it.
141+
cache.Clear();
143142
estimatedCachePressure = 0;
144143
}
145144

0 commit comments

Comments
 (0)