开发者

Presenting multiple view controller modally -- A memory issue?

开发者 https://www.devze.com 2023-02-14 06:39 出处:网络
How much memory a view controller eats when it is loaded into the memory? I have an application where I am planning to keep 4 view controllers in the memory as they are modal on each other and out of

How much memory a view controller eats when it is loaded into the memory?

I have an application where I am planning to keep 4 view controllers in the memory as they are modal on each other and out of them, one view controller is a navigation controller (with 4-5 view controller 开发者_如何学Gopushed in stack) presented as modal.

Any suggestions?


A view controller object itself usually needs very little memory unless you use it store large objects like images or caches. What takes a lot of memory is the view that is attached to the view controller. That's why view controllers unload their views when they receive a memory warning and the view is not currently on screen.

So you shouldn't worry. Follow the memory management rules, implement viewDidUnload correctly (release your outlets) and respond to memory warnings appropriately. The view controllers will take care of unloading and reloading their views if needed.

0

精彩评论

暂无评论...
验证码 换一张
取 消