Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unbounded memory issues #13

Open
shalins opened this issue Apr 13, 2019 · 6 comments
Open

Unbounded memory issues #13

shalins opened this issue Apr 13, 2019 · 6 comments

Comments

@shalins
Copy link

shalins commented Apr 13, 2019

First of all, thanks for developing such an awesome repo–I've been using the pod like crazy and appreciate all the work you guys have done with this.

Unfortunately, I've been having a lot of memory issues with using this. 1) as I scroll down further and further, my memory increase is unbounded. 2) that wouldn't be a problem except this memory is never freed when I pop/dismiss the SwiftyGiphyViewController. All the mallocs and CGImageData are saved in memory and none of the objects are ever released.

image

I've spent 50-60 hours tracing through the code line by line and trying to figure out how to fix the issue but I haven't been able to find it. At first, I thought it was something simple with the collection view objects not being correctly dereferenced, then I tried looking deeper into each of the components that make up each cell (all the subviews, etc). I tried deinit-ing latestTrendingResponse and latestSearchResponse and even every individual element inside (as well as pretty much any other place I could find saved gifs). I've tried keeping track of other things such as how many CornerRoundingViews were kept in memory at different points in time. I've spent many frustrating hours in Instruments to no avail.

It would be beyond awesome to be able to use this repo in production. If you guys have some time, would you be able to look into fixing the memory issues? Perhaps you guys might be able to fix it more quickly than I'd be able to since you guys are the ones who actually wrote the code.

Thanks so much!

@shalins
Copy link
Author

shalins commented May 6, 2019

Bump (it'd be so helpful if you could take a look at this for even like 15-20min, I'd be more than happy to fix it myself but it's difficult to debug since I didn't write the code)

@shalins
Copy link
Author

shalins commented May 28, 2019

Bumping this again

@shalins
Copy link
Author

shalins commented Jul 14, 2019

Guys cmon would really appreciate the response and help

@shalins
Copy link
Author

shalins commented Jul 14, 2019

It has literally been months

@ulmentflam
Copy link
Contributor

@shalins I am so sorry for such a late response but have been looking into this issue since the first bump. If you are able to find a fix to the leak I will be happy to merge a PR, however, I am also having trouble pinning down the best approach to the issue that I see. I initially thought it may be related to the SDWebImage library and the image cache it maintains not being cleared. However, when looking at the memory graph hierarchy I see a few issues that seem to point directly to the SDWebImage decoder. That is where I see most of the retain cycles that are causing the memory leaks. I have tried a few approaches to clear these retain cycles, however, those attempts did not bound the memory. Many of the mallocs are coming from the call here and I have yet to figure out a solution that does not require a rework. Again I am so sorry for the late response and will keep you updated as I search for the solution.

@shalins
Copy link
Author

shalins commented Sep 17, 2019

@ulmentflam Thanks for the response! Yeah, I was also able to point to the same line causing all the mallocs but I didn't really know how to fix it from there. I tried a bunch of different things that didn't end up working.

My temporary solution was just to not allow pagination so the memory usage wouldn't keep increasing as I scrolled. But obviously this solution doesn't actually fix the problem and using the search bar to search for new gifs still mallocs space.

I will still keep an eye out for some way to fix it when I'm running through the code but I appreciate you looking into it and let me know if you do come up with a fix!

I would love to use the repo in a production app :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants