question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Memory size is greater than image sizes? how to free memory on navigating back?

See original GitHub issue

I am displaying 300+ items in a listview and each having image defined as below. Images are retrieved from aws s3 bucket. I profiled memory usage with xamarin profiler and I can see that the more I scroll in the list, memory usage increases which makes sense as each images are cached. But I am going above 300 mb cache. total size of all images physically are not more than 15 mb.

  1. How can it be cached 20 times more than actual size? If I use loading.png for loadingplaceholder, is it also cached for 300 times for each item in the list?

  2. When i navigate back from the list, my memory size is not reduced. this is probably expected as some people may want to keep them in memory. Is there an option free the memory in build? a parameter or something?

<ffimageloading:CachedImage  RetryCount="1"	
DownsampleToViewSize="true" 
 TransparencyEnabled = "false"  CacheDuration = "30" 
LoadingPlaceholder="loading_dark.png"    ErrorPlaceholder="error.png"   
Source="{Binding Image, Converter={StaticResource thumbnailConvertor}}"
  Aspect="AspectFit"    />

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
daniel-luberdacommented, May 8, 2017

As @molinch said:

downloaded file size != bitmap size in memory

1px = 4 Bytes (Android ARGB_8888) 
1024px x 1024px = 4 Megabytes
 2048px x 2048px = 16 Megabytes

Every PNG / JPG is decoded into a bitmap, there’s no other way. That’s why downscaling is so important.

0reactions
daniel-luberdacommented, May 8, 2017

@EmilAlipiev

You can control memory cache size by yourself 😃 Just use custom FFImageLoading config:

var config = new FFImageLoading.Config.Configuration()
{
    MaxMemoryCacheSize = 9999999,
};
ImageService.Instance.Initialize(config);
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to prevent excessive memory usage when resizing ...
I'm using a image resizing library for resizing images on a website. To better secure the image resizing process I used a fuzzer(afl...
Read more >
How To Optimize Images for Web and Performance
The primary goal of formatting your images is to find the balance between the lowest file size and an acceptable quality. There is...
Read more >
PVS Internals #2 – How to properly size your memory
In first part, I've prepared the theoretical ground for the discussion about proper sizing of the memory. You should already understand the ...
Read more >
Memory management and patterns in ASP.NET Core
Learn how memory is managed in ASP.NET Core and how the garbage collector (GC) works.
Read more >
Strategies for Efficient Use of Memory - MATLAB & Simulink
One simple way to increase the amount of memory you have available is to clear large arrays that you no longer use. Save...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found