Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to fix strange retain count (1 init - 3 retaincount)? + edit: dealloc problem
    primarykey
    data
    text
    <p>So my code goes like this:</p> <pre><code>ArticleControllerController *ac = [[ArticleControllerController alloc] init]; ac.categoryIndex = idx; NSLog(@"acc retain: %d", [ac retainCount]); [app.nav pushViewController:ac animated:NO]; NSLog(@"acc retain: %d", [ac retainCount]); [ac release]; NSLog(@"acc retain: %d", [ac retainCount]); </code></pre> <p>And I get:</p> <pre><code>[2649:207] acc retain: 1 [2649:207] acc retain: 3 [2649:207] acc retain: 2 </code></pre> <p>How to resolve this mess? I don't understand what I'm doing wrong and this part sometimes causes application crash due low memory.</p> <p>Edit: related problem.</p> <p>So the situation is the same as defined above, but the problem is that ArticleControllerController dealloc method never gets called.</p> <p>More code:</p> <pre><code>- (void) navigateToNewsCategoryByIndex:(int)idx { [app.nav popViewControllerAnimated:NO]; currentMode = MODE_ARTICLE; ArticleControllerController *ac = [[ArticleControllerController alloc] init]; ac.categoryIndex = idx; [app.nav pushViewController:ac animated:NO]; [ac release]; return ; </code></pre> <p>}</p> <p>If this method gets repeated several times ArticleControllerController creates massive amounts of various interface elements, but its dealloc method never releases them (retain count never goes down to zero), so I think here lies the memory-crash problem I am trying to resolve for a couple of days now.</p> <p>What's up with that? Can I do something more to resolve this?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload