Question: How to properly clear cache?
See original GitHub issueI need your help to understand how to clear cache in some specific cases? here is my scenario
I have mainpage with 3 horizontal listviews with each datetemplate has CacheImage as CacheType Memory implemented. when i profile after main page is loaded, I reach to 100mb memory usage although I am using Downsampling correctly I believe. If I remove lists I experience around 50mb. I can even accept 100mb for mainpage but my problem starts after I navigate to page 1 with a single listview with images it increases to 120 mb. How can I dispose or get rid off images loaded on Mainpage? I tried to set null ItemsSource each listview in OnDisappearing method of the mainpage but it didnt help at ll?
protected override void OnDisappearing()
{
base.OnDisappearing();
// in order keep memory usage lower
listview1.ItemsSource = null;
listview2.ItemsSource = null;
listview3.ItemsSource = null;
}
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
What is a cache? How to clear a cache & more
Click More Tools > Clear Browsing Data. A pop-up menu appears. To delete all data from the cache, select All time. Check the...
Read more >How to Clear Cache for All Major Browsers
One way to have cache clearing happen in the background is by adjusting the field to Remove History Items. You'll pick a certain...
Read more >How to Clear Your Browser Cache
Firefox clear cache · Click the menu button. and select Options. · Select the Privacy & Security panel. · In the Cookies and...
Read more >Clear your web browser's cache, cookies, and history
If you need to clear your cache, cookies, and history for ... Select Safari > Quit Safari or press Command-Q to exit the...
Read more >How Do I Clear My Browser Cache? - SDSU
INSTRUCTIONS ; Select the Google Chrome menu clear-cache-dots , which appears as three dots in the right corner of the browser window. Then ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
FFImageLoading manages memory usage automatically, you shouldn’t worry about anything in most scenarios. If you exceed
MaxMemoryCacheSize
(configurable), it automatically removes bitmaps that are least used from memory, the rest is managed by OS. You shouldn’t worry about memory usage until loading some huge amounts of images or some big size images.If you still want manually remove an entry from cache you can easily do that with:
await ImageService.Instance.InvalidateCacheEntryAsync("image.png or http://something", Cache.CacheType.Memory, removeSimilar: true);
But I advise you to not do that as it isn’t necessary.
In that case this is ignored as no disk cache is involved.
It’s not how it works. Bitmaps are not related to the Xamarin.Forms at all, they’re strictly native objects and OS manages them automatically. Page will be disposed without any issues, but the bitmap would be cached so it could be loaded faster for other image loading tasks. FFImageLoading uses LRU memory cache, so only most used bitmaps are cached, others are freed if memory usage is to high.