-
-
Notifications
You must be signed in to change notification settings - Fork 455
Limiting the number of ImageSources cached to address memory issue #133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…junbalgovind:user/arbalgov/apperrorFix
|
@bao-qian has introduced a way to lazy load image for resultlistview, which is a quite simple change, should I add that to this pr? |
| public ConcurrentDictionary<string, int> Usage = new ConcurrentDictionary<string, int>(); | ||
| private readonly ConcurrentDictionary<string, ImageSource> _data = new ConcurrentDictionary<string, ImageSource>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should merge this two dictionary to one by creating another utility class, which will allow us to remove element easier?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, let me have a look
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have finished that, if you want, I can add that to the pr.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
haha ok cool, yes please
Are you referring to the change in the other PR ? |
I think we can keep them separate and then just resolve any conflict depending which goes in first |
|
Sure |
|
@taooceros new changes look good. Do you want to approve and merge it in? |
|
Sure! |
Problem:
Memory usage can run up quite high for Flow, and can hit 300 mbs for myself if constantly performing searches. It does reduce back down to around 130 when querying is stopped.
Note:
This is a partial fix to the memory issue, it does not address it complete, and other factors that contribute to it are still been investigated.
This PR does not mean memory will reduce significantly, it is more focused on addressing the unnecessary high memory caused by improperly handling of image caching. So reduce image cache (ImageSources)'s memory's footprint is the main focus here.
How to reproduce:
Open query, type 'a' (especially if Explorer hotkey is set as global '*') and you should get numerous results. Keep pressing down arrow on the keyboard and should see Flow.Launcher.exe in task manager grow to as high as 300mbs for myself. It may vary depending on the user and the application images that need to be displayed on the machine.
If unable to repro, change the power mode on Windows to 'Recommended' then try.
Partial solution:
Limiting the number of ImageSources cached to reduced the memory usage going over too high.
Set maximum number of images cached to 50 from 5000.
Once cached images go over permissible factor (2) X number of images (50), perform clean up by removing infrequently used ones from dictionary.
Testing
Result
Before this PR change:

With this PR:

Related: #128