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 Leak #2

Closed
pjebs opened this issue Mar 29, 2016 · 10 comments
Closed

Memory Leak #2

pjebs opened this issue Mar 29, 2016 · 10 comments

Comments

@pjebs
Copy link

pjebs commented Mar 29, 2016

if I have removeOnCompletion=true,

when the animation finishes it does remove itself from the superview but something else is holding a strong reference to JRMFloatingAnimationView hence it never deallocates.

Perhaps (not tested) the FloatingImageView deallocs but not the AnimationView.

@pjebs
Copy link
Author

pjebs commented Mar 29, 2016

Forget what I wrote. I misunderstood the difference between JRMFloatingAnimationView and JRMFloatingImageView.

@pjebs pjebs closed this as completed Mar 29, 2016
@pjebs pjebs reopened this Mar 29, 2016
@pjebs
Copy link
Author

pjebs commented Mar 29, 2016

Actually to solve the issue this change should be made:

There are numerous blocks inside JRMFloatingImageView that keep a strong reference to self.
I am using your control for a 'non-standard' use case and self is dangling at times.

You should use:
__weak typeof(self) weakSelf = self;
and use weakSelf inside the blocks instead of self.

There is no harm in doing that anyway.

@pjebs
Copy link
Author

pjebs commented Mar 30, 2016

since I didn't want to interfere with your code (cocoapods), I had to subclass. Here is my modifications that may be helpful for eccentric use cases:

It would be good if you could implement these changes so I can get rid of my subclass. I also couldn't access some stuff so I had to use a work around:

Header:

@pjebs
Copy link
Author

pjebs commented Mar 30, 2016

@pjebs
Copy link
Author

pjebs commented Apr 2, 2016

@carleihar
Copy link
Owner

@pjebs Were you experiencing an EXC_BAD_ACCESS crash? Setting the delegate to (nonatomic, weak) instead of (nonatomic, assign) will fix this if using ARC. Without this fix, the delegate will not be set to nil when it is deallocated and then will crash on animationDidStop. I will fix this and push it this week.

@carleihar
Copy link
Owner

@pjebs This is fixed in version 0.1.1.

@Xedart
Copy link

Xedart commented Mar 21, 2018

I don't know if this project is still alive but I still have this issue :) FloatingImageView does not remove itself from JRMFloatingAnimationView upon animation completion. They just still there, and if I add new ones, they are collected until app runs out of memory.

@Xedart
Copy link

Xedart commented Mar 22, 2018

Was able to solve my problem by changing
pathAnimation.removedOnCompletion = NO;
to
pathAnimation.removedOnCompletion = YES;
in JRMFloatingImageView' start method. I am not sure what kind of problem it was, and if it was unique to my use case, but maybe it will be helpful to somebody :)

@bishalg
Copy link

bishalg commented Aug 20, 2018

the issue is if the view controller disappears,
there is the sudden memory leak and CPU usage start to climb up then again if we are back to VC the issue is resolved.

If only there was the option to stop() animation it would have been the way to stop the leak.
Even if we manually remove the animation it will again trigger the leak!

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

4 participants