Im building my first app in Swift, I used to work with Android. So Im in my loginViewController and when I login, the MenuViewController, the memory increase, and that's ok. But when I dismiss, the Memory no decrease, so if the user login and logout (dismiss) many times, the memory still increase and increase. ¿How do I have more controll of my ViewController dismiss or how can I clean the memory when I dismiss a viewController?
Asked
Active
Viewed 286 times
0
-
This sounds like “strong reference cycle”. See https://stackoverflow.com/a/30993476/1271826 for demonstration of how to identify precisely where the strong reference cycle is. Or see the [WWDC video](https://developer.apple.com/videos/play/wwdc2016/410/?time=1467) linked in that answer for Apple’s own demonstration about how to use this “Debug Memory Graph” feature right in Xcode. – Rob Apr 29 '19 at 19:37
-
Another possibility is unbounded memory usage. If for example, you cache images in memory that were fetched from a server - but never clear the cache - your memory usage will keep going up and up. See the *Allocations, Allocations, Allocations* section of [Instruments Tutorial with Swift: Getting Started](https://www.raywenderlich.com/397-instruments-tutorial-with-swift-getting-started) for a good tutorial about this. – paulvs Apr 29 '19 at 19:47
-
Thanks so much for the help, I gonna see the WWDC, the demonstration and follow the tutorial. How can i clean the cache? turning all to nil after dismiss? did I have to declare Weak the UIViewController to present? thanks again – Jesus Barragan Apr 30 '19 at 22:50