Haneke / HanekeSwift

A lightweight generic cache for iOS written in Swift with extra love for images.
Apache License 2.0
5.2k stars 591 forks source link

Is it a memory leak in image loading caused by Haneke? #362

Closed peihsendoyle closed 7 years ago

peihsendoyle commented 8 years ago

I'm dealing with images in TableView and CollectionView and using Haneke for caching. But I'm realize that everytime a cell is visible (with imageView inside), the memory grow dramatically. The Allocations Instrument indicate that there is "cg raster data" leak the memory.

screen shot 2016-10-18 at 12 59 41 am

and inside it are many CoreGraphics algorithms:

screen shot 2016-10-18 at 1 00 58 am

Here is my tableViewCell and tableView codes:

screen shot 2016-10-18 at 1 02 51 am screen shot 2016-10-18 at 1 02 59 am

Anyone can help me in this case, thanks very much.

yoller commented 8 years ago

Did u find any solution for this?

peihsendoyle commented 8 years ago

Dear yoller,

I found out that the things lead to problems is the size of image. If the size is too big, the device has to use their resources to process the image. That lead to an increasing in memory. I resize the image and the problem solved.

Thanks for your concern :)

rlam3 commented 7 years ago

@peihsendoyle What was the size of the image files you are using? I believe I may be running into a similar issue.

peihsendoyle commented 7 years ago

@rlam3 sorry for the late reply.

Actually, I'm using IMGIX service to resize the image and detect face. It allows you to pass params like width, height, crop,... and return a new proper url instead of your directly url.

The problem is that you have to use their url, it means you must store images resource in their repository. I don't realized it 3 months ago, and just used directly url, it leads to the image was not resize.

In my opinion, when you download an image and attach it to your imageView, it should have the size equivalent to the bounds of imageView (like 50x50, 70x70).