Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4015622
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T09:38:29+00:00 2026-05-20T09:38:29+00:00

This is a very very… very odd bug. It’s hard to describe the exact

  • 0

This is a very very… very odd bug. It’s hard to describe the exact project I have, but I will try and create a simpler representation of the classes I have. It goes like this:

Assume I have a navigation controller as my top view controller. Inside it, at one moment in time I have a UIViewController, let’s say a ContactsScreenController. The view for this contains multiple UITableView that each is controlled by a separate object of type MyTableController (delegate&datasource). I do this by keeping an array of controllers


// This is the interface for my screen controller. An object of this type goes in a top-
// level navigation controller
// MainScreenController.h
@interface ContactsScreenController : UIViewController

    NSMutableArray* tableControllers;

@end



// MainScreenController.m

- (UITableViewCell*)cellForRowAtIndexPath..something..
{
    // Here what I do is create a new controller if needed, and add it to tableControllers
    // Memory allocations & releases are good because I checked with instruments
}

#define SAFE_DEL(x)   { if (x != nil) { [x release]; x = nil; } }

- (void)dealloc
{
    SAFE_DEL(tableControllers);
    [super dealloc];
}

Now, MyTableController is a more complicated object as it handles fetching data from a web service, but basically what I do is I want to make sure that when the object is deleted, I cancel any pending data requests, like this:


// MyTableController.m
- (void)dealloc
{
    [globalDataProvider cancelRequestsForController:self];

    // release other objects i might have
    [super dealloc];
}

OK, so this is my objects setup. The crash occurs when I am deleting the object tableControllers. It decrements the retainCount for my MyTableController objects and it reaches 0 (checked using Instruments). But for some UNKNOWN reason, I get calls for cancelRequestsForController, AFTER the retain count has been zero.
Obviously, I get a EXC_BAD_ACCESS.

Before you start thinking it’s a problem with my retain/release pairs, the application runs perfectly if I am releasing the main screen controller while the inner tables are static. As soon as the are scrolling and I hit the Back button in the navigation controller I experience the bug.

I’ve checked using instruments the entire history of retain count changes for my inner controllers and it is good (no unusual stuff). When the bug occurs, my last entry in the history is from QuartzCore run_animation_callbacks with a retain count of -1.

Any ideas? 🙂

PS: As a quick solution to get the project going, I’ve moved the cancelRequestsForController in a separate method and I’m manually calling it for each object in tableControllers before the release. This way I am sure that there will be no calls after the release, no matter the state of the tableview.


- (void)dealloc
{
    for (TableController* c in tableControllers)
        [c cancelRequests];
    SAFE_DEL(tableControllers);
    [super dealloc];
}

But I don’t like this solution for several reasons.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T09:38:30+00:00Added an answer on May 20, 2026 at 9:38 am

    Thanks to everybody for the answers/comments.
    The problem was generated by a call to [super dealloc] in an object, before I got the chance to release my objects. This caused a lot of crazy stuff to happen. I moved the [super dealloc] at the end of my dealloc method (after my releases) and it works fine now.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this very strange problem while compiling the project. MOC seems to be
I have this very simple example that I am using to learn structs in
I was making this very simple lex program (just an introductory program). But on
I posted this very same item on SERVERFAULT, but got no reply. So here
I have this very straight forward question regarding Thread and Timer classes in Java
I have this very simple sql statement: SELECT max_dose FROM psychotropes WHERE (patient_meds.psychotrope =
This one is probably very simple, but I can't seem to get it working.
I am using this very nice LinkedIn ruby gem (https://github.com/pengwynn/linkedin) for a project of
I have this very simple button that I would like to hide <input type=button
I have this very simple XAML window: <Grid> <Grid.RowDefinitions> <RowDefinition/> <RowDefinition/> </Grid.RowDefinitions> <ContentControl Content={Binding

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.