0

I have implemented a custom version of bitmap loader. I have an auto scroll list of images of movies. When the user presses and holds the d-pad i start scrolling the list at Speed 1. We have speed 2 and 3 which scroll the list very fast so I have to load the images very fast. So I created a circular list to load 50 images first then based on the current position I load the 25 images and discard the older 25 images.

I also tried the Glide preload https://muyangmin.github.io/glide/int/recyclerview.html but this does not work well in speed 3 and shows empty tiles instead of images

When I am doing the profiling i am seeing that 395MB memory is used by FinalizerRefrenace Memory profiler

FinalizerReference is held by the bitmaps I am using.

How can I fix the memory leak? I tried calling the recycle when the user closed the seek, still no luck.

Images i have are very small in size, mostly 10kb. Why do they take 100 Mb in memory? Is there any other library I can use to show these images on a fast scrolling list for android TV?

Pavan Tiwari
  • 3,077
  • 3
  • 31
  • 71
  • "Images i have are very small in size, mostly 10kb. Why do they take 100 Mb in memory?" -- [JPEG is a compressed file format](https://en.wikipedia.org/wiki/JPEG). Software needs to decompress it to render it on the screen. "How can I fix the memory leak?" -- [there may not be a leak](https://stackoverflow.com/q/57027001/115145). – CommonsWare Jun 12 '22 at 20:31
  • The two big things I'd be looking at: 1- make sure you're using RecyclerView or similar, and not just adding new views for each row. 2- make sure you do not store the bitmap anywhere in your model. At most, store a WeakReference to the bitmap and reload if needed. 3- if you have any caching layer, make sure that its working properly, that it does not keep references around longer than needed, and that its limited to not just a number of images but a max memory size of image. – Gabe Sechan Jun 13 '22 at 05:35

0 Answers0