开发者

push and pop increase live bytes

开发者 https://www.devze.com 2023-03-30 21:38 出处:网络
as a test I push and pop the same view again and again...I am going to the next screen and clicking on back over and over... and I can see the live bytes continuously increasing...

as a test I push and pop the same view again and again... I am going to the next screen and clicking on back over and over... and I can see the live bytes continuously increasing...

Although somewhere else in the application I come forth and back between 2 screens displaying table views, the live bytes increase 开发者_Go百科and decrease of the same amount (execpt the first time).

So what do I need to check to understand what is going on... after 20 minutes playing, usually the application crashes - please note that at any time there are no memory leaks.

On these first views that I push and pop, the second screen has a picture and a textfield. Do I need to so something particular with these? Also do I noted that I did not have the default functions viewWillDisappear and viewDidDisappear... do I need these? are they mandatory? added them did not change anything... so do I need to put something particular in them...

any help is much appreciated

Cheers, geebee


Try Heapshot, see: Using Heapshot Analysis to Find Undesirable Memory Growth


You can find out exactly what changes over a period using Instruments' Heapshot Analysis.

1) Profile using the allocations template

2) run the app (navigate around)

3) Click 'Mark Heap" button

4) run the app (navigate around)

5) Click 'Mark Heap" button

then look at the results of the Heapshot Analysis.

when your view is unloaded you should zero your IBOutlets, free what you can easily reconstruct, and free what may be considered a large allocation.


Put a breakpoint in the -dealloc method of the controller you're pushing and popping to see if it ever fires. If not, you're retaining a reference to it somewhere. This can happen for a number of reasons. Here are a few possibilities:

  1. The preceding view controller might be retaining a reference to the successor. This is unnecessary and should be avoided (the UINavigationController retains the view controllers in its stack).

  2. You might have introduced a retain cycle in your code by retaining a reference to an object that retains your view controller. This can easily happen if you use blocks and you're not careful about following memory management rules.

If you're doing things right, your view controller should deallocate after it gets popped from the navigation controller.

0

精彩评论

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