Partial Fix for Memory issue - Limiting the number of ImageSources cached (#4433)

* reducing storage of images

* Added task.run

* cleaned up code and added comments

* Renamed variable

* refactored code

* Removed task.run because it was leading to race conditions in the concurrent dictionary and it was taking only upto 10 ms for reordering the dictionary

* Added comments and fixed variable name
This commit is contained in:
Alekhya
2020-06-26 10:20:35 -07:00
committed by GitHub
parent d2f1f67a22
commit 5745a984aa
2 changed files with 31 additions and 4 deletions

View File

@@ -185,9 +185,13 @@ namespace Wox.Infrastructure.Image
string hash = EnableImageHash ? _hashGenerator.GetHashFromImage(img) : null;
if (hash != null)
{
int ImageCacheValue;
if (GuidToKey.TryGetValue(hash, out string key))
{ // image already exists
img = ImageCache[key];
if(ImageCache.Usage.TryGetValue(path, out ImageCacheValue))
{
img = ImageCache[key];
}
}
else
{ // new guid