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 #198

Closed
blurtime opened this issue Feb 22, 2019 · 9 comments
Closed

Memory leak #198

blurtime opened this issue Feb 22, 2019 · 9 comments

Comments

@blurtime
Copy link

blurtime commented Feb 22, 2019

I've recently started coding again after quite some time off due to studying a lot. But somehow my app's been crashing pretty often due to memory issues and naturally, I tried to find the cause, e.g. a retain cycle - in my own code. However, even after hours of searching and trying to strip my code down to the very basics I just couldn't get rid of the leak. And when debugging the memory graph I noticed something odd: The number of pages, i.e. SubViewControllers of my PageboyViewController, was way too high. Although I had in total 6 pages it displayed a bunch more (e.g. 21) when I debugged it. I noticed I could induce the problem by going back and forth a lot (e.g. from page 1 to 6 and back) and indeed I could watch my memory go up in the memory leak-typical manner with virtually every new page. The problem wouldn't occur, though if I didn't go back and forth.

To make sure it wasn't because of my code I first replaced the old pages with other, simpler ViewControllers but it still wasn't going away. The app still crashed although it did seem to take a little longer. The videos in my usual pages seemed to add to the problem.

Anyways, now I created a simple project with a normal UIPageViewController and a PageBoyViewController to compare them. I'm using Pageboy (3.0.5) (from Podefile.lock) and also installed a simple video player pod (Player) so that the pages in the controller would resemble my project to some extent.

In my example project, I used exactly 10 pages which always showed the same video. As you can see on the left of the picture (debugged memory graphs), 21 instances of VideoPlayer (my SubViewController of the respective PageViewController) were created when I used PageBoy. On the contrary, only 10 (the total number of SubViewControllers) were created when I used a "normal" (therefore NormalViewController) UIPageViewController.
To be able to compare them I tried to induce the crash as described above in both controllers. When I noticed the former (PageBoyController) became slower, I debugged. If I don't stop, however, it will invariably crash with Message from debugger: Terminated due to memory issue.
Trying to induce the crash the same way in the "normal" UIPageViewController didn't work (even after one entire minute of rapidly going back and forth).

If you would like me to share my example project, please let me know.

Now the bad news: Unfortunately, I couldn't find the cause. I've analyzed the debugged memory graph a lot but couldn't find e.g. a retain cycle. I have to admit, though, that I am not very experienced at this, too. Therefore, I would really appreciate if someone could help me with this problem. I really like the pod and wouldn't wanna work without it but this is a little too hard of a problem for me (as no CS student) to solve. Thank you!

PS: Please let me know if there are any questions or if anything remains unclear. I'll try to provide answers as precisely as possible.

@batuhangobekli-deprecated

+1

@msaps
Copy link
Member

msaps commented Feb 26, 2019

Okay will check it out ASAP - thanks for all the detail 💯

@msaps
Copy link
Member

msaps commented Feb 28, 2019

@blurtime would you be able to provide the example project? Finding this hard to reproduce, at least with vanilla PageboyViewController and basic child view controllers.

@blurtime
Copy link
Author

@msaps Sure, I've never uploaded anything so please bear with me if I do something wrong. I just added you to a private project. Please let me know if you can work with the zip I uploaded. Thank you!

@msaps
Copy link
Member

msaps commented Feb 28, 2019

@blurtime thanks that's great, I'll try and take a look at it over the weekend! 💯

@SeanFromTheMatrix
Copy link

Please post when a solution is found. Thank you!!

@msaps
Copy link
Member

msaps commented Mar 3, 2019

Fixed in 3.0.6 🎉

cc @blurtime @SeanFromTheMatrix

@msaps
Copy link
Member

msaps commented Mar 3, 2019

@blurtime @SeanFromTheMatrix use 3.0.7 - fixed a critical issue that was in 3.0.6 😅

@blurtime
Copy link
Author

blurtime commented Mar 3, 2019

@msaps New version seems to work fine, thank you very much - especially for fixing it so quickly!

@blurtime blurtime closed this as completed Mar 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

4 participants