There is a RecyclerView, each item in the list has a picture. The picture is loaded asynchronously using AsyncTask inside the holder. The problem is that when the list is very large and the user scrolls quickly, then a lot of AsyncTask starts at the same time, which can result in an OutOfMemoryError. How can I get around this? I know that there are Picasso and UIL, but in this case they are not suitable.

  • AsinkTask is outdated. UIL is also outdated and not supported for several years. Picasso, too, can be said outdated and there is his improved analogue of Glide . Use it. Cutting bicycles for an ordinary task using outdated tools - why? - Yuriy SPb
  • @ ЮрийСПб Need to avoid adding another library. Therefore, you need your decision. Can you suggest the implementation? - BArtWell
  • Nevertheless, I insist that in this case it is necessary to use the library. But, since you really want to do wrong and have problems out of the blue, you can try to add Async's instances to the Sheet and, in case its size is larger than a certain value, when you add a new task, call сancel () on those at the top of the list . It will be bad and slow to work, but it can work (probably). Maybe you have a problem not in this at all, but in exceeding the limit of 65 thousand methods in the project, and that’s why you don’t want to add? Explain in more detail why you do not want, plz - YuriySPb
  • one
    Check the scrolling speed, if the speed is high, then do not load pictures. Create a limit on downloading images no more than 2 per second. In general, I fully agree with Yurimspb, better use the library, otherwise something tells you that there will still be problems. - ivansoft
  • 2
    @BArtWell, you can connect a third-party lib as a jar file in your lib - it will never change so that the developer of GLIDE will not do it - nothing can break. Not at all. The same will happen if you connect it as a dependency by specifying a specific version - as long as you do not change your version, your problem will not be any. You fear nothing of this. The only reasonable solution in your situation is to use third-party libs. No need to cut the bike. \ - Yuriyi SPb

0