dealloc memory

Discussion in 'iPhone Tips, Help and Troubleshooting' started by simonhayre, Dec 1, 2010.

  1. simonhayre macrumors newbie

    Joined:
    May 2, 2009
    #1
    I have a memory dealloc issue,
    I can run this app in the simulator fine, but when I try to run it in leaks, my app crashes for some reason.

    I have put an NSLog on every init, and dealloc method to try and debug this.

    I then found a strange output from the debug console.

    this is the steps taken.

    step 1. user logs in, (allocs appear in console)
    step 2. user logs off, (release is called in code, although there is no output from the console) --
    step3. user logs in, (dealloc appears in the console then all my allocs)

    Here's a sample

    THIS IS THE OUTPUT I'M GETTING:
    2010-12-01 13:27:18.701 1.0.1.0[8023:207] --loadLoginView--
    2010-12-01 13:27:23.502 1.0.1.0[8023:207] [UserMethods init];
    2010-12-01 13:27:23.503 1.0.1.0[8023:207] [UserMethods dealloc];
    2010-12-01 13:27:23.506 1.0.1.0[8023:207] --loadMainView--
    2010-12-01 13:27:23.507 1.0.1.0[8023:207] [orders_main_app_view_controller dealloc]
    2010-12-01 13:27:23.508 1.0.1.0[8023:207] [AvailableProductViewController dealloc];
    2010-12-01 13:27:23.508 1.0.1.0[8023:207] [AvailableProductTableViewController dealloc];
    2010-12-01 13:27:23.509 1.0.1.0[8023:207] [AvailableProductsMethods dealloc];
    2010-12-01 13:27:23.510 1.0.1.0[8023:207] [SelectedProductsViewController dealloc];
    2010-12-01 13:27:23.511 1.0.1.0[8023:207] [SelectedProductsTableViewController dealloc];
    2010-12-01 13:27:23.511 1.0.1.0[8023:207] [SelectedProductsMethods dealloc];
    2010-12-01 13:27:23.514 1.0.1.0[8023:207] [main_apps_tools_popover_controller dealloc];
    2010-12-01 13:27:23.514 1.0.1.0[8023:207] [main_apps_tools_popover_view_controller dealloc];
    2010-12-01 13:27:23.515 1.0.1.0[8023:207] [main_apps_tools_popover_table_view_controller dealloc];
    2010-12-01 13:27:23.515 1.0.1.0[8023:207] [tool_data_methods dealloc];
    2010-12-01 13:27:23.516 1.0.1.0[8023:207] [main_apps_tools_popover_controller init];
    2010-12-01 13:27:23.518 1.0.1.0[8023:207] [AvailableProductViewController init];
    2010-12-01 13:27:23.518 1.0.1.0[8023:207] [AvailableProductTableViewController init];
    2010-12-01 13:27:23.519 1.0.1.0[8023:207] [AvailableProductsMethods init];
    2010-12-01 13:27:23.519 1.0.1.0[8023:207] [categoryMethods init];
    2010-12-01 13:27:23.700 1.0.1.0[8023:207] [categoryMethods dealloc];
    2010-12-01 13:27:23.701 1.0.1.0[8023:207] [SelectedProductsViewController init];
    2010-12-01 13:27:23.702 1.0.1.0[8023:207] [SelectedProductsTableViewController init];
    2010-12-01 13:27:23.703 1.0.1.0[8023:207] [SelectedProductsMethods init];
    2010-12-01 13:27:23.704 1.0.1.0[8023:207] [basketMethods init];
    2010-12-01 13:27:23.707 1.0.1.0[8023:207] [basketMethods dealloc];

    IT SHOULD BE LIKE THIS:

    2010-12-01 13:27:23.507 1.0.1.0[8023:207] [orders_main_app_view_controller dealloc]
    2010-12-01 13:27:23.508 1.0.1.0[8023:207] [AvailableProductViewController dealloc];
    2010-12-01 13:27:23.508 1.0.1.0[8023:207] [AvailableProductTableViewController dealloc];
    2010-12-01 13:27:23.509 1.0.1.0[8023:207] [AvailableProductsMethods dealloc];
    2010-12-01 13:27:23.510 1.0.1.0[8023:207] [SelectedProductsViewController dealloc];
    2010-12-01 13:27:23.511 1.0.1.0[8023:207] [SelectedProductsTableViewController dealloc];
    2010-12-01 13:27:23.511 1.0.1.0[8023:207] [SelectedProductsMethods dealloc];
    2010-12-01 13:27:23.514 1.0.1.0[8023:207] [main_apps_tools_popover_controller dealloc];
    2010-12-01 13:27:23.514 1.0.1.0[8023:207] [main_apps_tools_popover_view_controller dealloc];
    2010-12-01 13:27:23.515 1.0.1.0[8023:207] [main_apps_tools_popover_table_view_controller dealloc];
    2010-12-01 13:27:23.515 1.0.1.0[8023:207] [tool_data_methods dealloc];
    2010-12-01 13:27:18.701 1.0.1.0[8023:207] --loadLoginView--
    2010-12-01 13:27:23.502 1.0.1.0[8023:207] [UserMethods init];
    2010-12-01 13:27:23.503 1.0.1.0[8023:207] [UserMethods dealloc];
    2010-12-01 13:27:23.506 1.0.1.0[8023:207] --loadMainView--
    2010-12-01 13:27:23.516 1.0.1.0[8023:207] [main_apps_tools_popover_controller init];
    2010-12-01 13:27:23.518 1.0.1.0[8023:207] [AvailableProductViewController init];
    2010-12-01 13:27:23.518 1.0.1.0[8023:207] [AvailableProductTableViewController init];
    2010-12-01 13:27:23.519 1.0.1.0[8023:207] [AvailableProductsMethods init];
    2010-12-01 13:27:23.519 1.0.1.0[8023:207] [categoryMethods init];
    2010-12-01 13:27:23.700 1.0.1.0[8023:207] [categoryMethods dealloc];
    2010-12-01 13:27:23.701 1.0.1.0[8023:207] [SelectedProductsViewController init];
    2010-12-01 13:27:23.702 1.0.1.0[8023:207] [SelectedProductsTableViewController init];
    2010-12-01 13:27:23.703 1.0.1.0[8023:207] [SelectedProductsMethods init];
    2010-12-01 13:27:23.704 1.0.1.0[8023:207] [basketMethods init];
    2010-12-01 13:27:23.707 1.0.1.0[8023:207] [basketMethods dealloc];



    HERE IS SOME SAMPLE CODE:

    -(void)loadMainView:(id)sender{
    [self.login_page_app.view removeFromSuperview];

    //[self.login_page_app dealloc];
    //[self.login_page_app release];

    NSLog(@"--loadMainView--");
    self.orders_main_app_view = [[orders_main_app_view_controller alloc] init];

    //load the view
    [self.view addSubview:self.orders_main_app_view.view];
    }

    -(void)logOutUser{
    [self.orders_main_app_view.main_apps_tools_popover_controller_Class.popoverControllerObject dismissPopoverAnimated:NO];
    //[self.orders_main_app_view.main_apps_tools_popover_controller_Class dealloc];

    [self.orders_main_app_view.view removeFromSuperview];

    //[orders_main_app_view dealloc];

    [orders_main_app_view release];

    //self.orders_main_app_view = nil;

    NSLog(@"--loadLoginView--");

    //self.login_page_app = [[login_page_app_controller alloc] init];
    //login_page_app.halo_main_login_delegate = self;

    self.login_page_app.userPW_TField.text = @"";

    //load the view
    [self.view addSubview:self.login_page_app.view];
    }
     
  2. simonhayre thread starter macrumors newbie

    Joined:
    May 2, 2009
    #2
    I almost had it..

    after:

    [orders_main_app_view release];

    I have to set the object to nil, to reuse the synthesized object like this:

    [orders_main_app_view release];

    self.orders_main_app_view = nil;

    NSLog(@"--loadLoginView--");
     

Share This Page