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

Memory problem on AnimatedImages #12

Closed
LouisBorlee opened this issue Feb 6, 2015 · 5 comments
Closed

Memory problem on AnimatedImages #12

LouisBorlee opened this issue Feb 6, 2015 · 5 comments

Comments

@LouisBorlee
Copy link

Hello,

I am currently using the pre-carthage Gifu and have been encountering some memory problem.

I have a few AnimatedImages in a dictionary and, whilst I try to clear them with dictionary.removeAll(), I can see that their deinit (which I have implemented) is never called.

I had a similar problem with an AVPlayer overload of mine and I know objects won't free themselves until they have no longer a single "dependency" (lack of a better term). So, I tried to remove delegate, pause them and remove displayLink from the mainRunLoop but still, it won't call deinit.

Since I'm a bit new in swift, I haven't manage to understand all of your syntax / code, and thus, I hope you can enlighten me on that.

Thank you for your time and for Gifu, it really helped me a lot on my current project.
Cordially, Louis.

@thunderousNinja
Copy link

Bump... Are you guys aware of any memory leak issues?

I am also facing memory issues when placing AnimatedImage in a UITableView, the memory just keeps going up :[ When profiling I noticed that cg raster data was not getting deallocated. I also verified that the deinit is getting called in AnimatedImage. So I wasn't sure exactly what was up.

@itaydressler
Copy link

Bump.

@kaishin
Copy link
Owner

kaishin commented Jan 21, 2016

Interesting. I am personally not aware of any memory leaks but I wouldn't rule them out.

To be able to debug this, we will need more information such as:

  • Gifu version used
  • Xcode/Swift version
  • Code snippet where the images are created
  • Optionally screenshot of Instruments showing where the memory leaks are happening.

@flyinghyrax
Copy link
Contributor

I have created a sample project which I believe demonstrates a memory leak: https://github.com/mr-seiler/gifu-bug-demo/tree/master

Instructions are in the Readme file. The essential structure of application is simply a navigation controller with a button that pushes a second view controller onto the navigation stack; the second view controller contains a Gifu AnimatableImageView. When the pushed view controller is popped back off the stack and deallocated, it appears (based on analysis in Instruments) that the AnimatableImageView is not being released, and more memory is allocated each time the view controller is pushed/popped.

  • Gifu version 1.0.1 on CocoaPods, which appears to be the same as 1.1.0 here on Github
  • Xcode 7.3 / Swift 2.2
  • Snippet (lines 23-29 can be removed and the issue still occurs; those were in place for testing a different bug)
  • Screenshot and saved Instruments report:

gifu-leak-demo.trace.zip
screen shot 2016-03-31 at 10 41 52 am

@flyinghyrax
Copy link
Contributor

We have found a solution to prevent a reference cycle between CADisplayLink and the AnimatableImageView; I will have a PR open with the implementation shortly. I will also attach the Instruments trace to the PR.

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

5 participants