Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialNick Sint
4,208 PointsMemory Management of View Controllers
I have two question regarding memory management with View Controllers. Suppose there exist 2 view controllers (call them FirstViewController and SecondViewController).
- FirstViewController
- Imbedded in a navigation controller
- Has a button to segue to SecondViewController
Otherwise completely blank
SecondViewController
Has a back button which "pops" to root view controller
Has a very large image in a image view (lets call it a 1000pixel by 1000pixel image)
My first question is how come when I "pop" from SecondViewController to FirstViewController, the memory allocated for the image view in SecondViewController has not been released?
My second question is regarding memory for views in a navigation controller. If I also had a large image in FirstViewController AND SecondViewController AND in a ThirdViewController (all stacked in a navigation controller). Will memory be allocated for FIrstViewController and SecondViewController when viewing ThirdViewController?
1 Answer
kerdeseverin
9,688 Points1.) Could be a number of reasons. Does your view controller have a delegate of strong reference in another class? Or are you storing your view controllers in an array somewhere?
2.) From what I know it would allocate memory for those.