Releasing memory of views

Discussion in 'iPhone/iPad Programming' started by anuragsolanki, Dec 24, 2008.

  1. macrumors newbie

    Joined:
    Dec 24, 2008
    #1
    I am having problem in releasing memories of views.

    Just understand my problem in detail:
    Consider I have view controllers-> view1controllers, view2controllers, view3controllers...and so on.
    view2controllers is a part of view1controllers and view3controllers is part of view2controllers...
    For example-
    view1controllers.h
    Code:
    #import <UIKit/UIKit.h>
    
    @class view2controller;
    
    @interface view1controller : UIViewController {
         view2controller *v2Controller;
    }
    
    Now I switch from view1 to view2 using
    Now I want to release the memory of view1controller (or its view). How should I do it?
    Similarly, I am switching between other views. As a result object allocation tends to increase and never decrease. Is there any method so that I can release the memory of last view or didReceiveMemoryWarning could help me any ways?

    Just tell me if I am not clear, but please reply soon.
     
  2. macrumors newbie

    bnut

    Joined:
    Nov 16, 2008
    #2
    That entirely depends on how you allocated the view, but after you have removed it from usage you can probably tell it to autorelease. I'm not entirely sure of all the internal intricacies of the view hierarchy when doing this, but if you use the appropriate methods when removing it as a subview then call this, it should be fine. I haven't had a problem with this method.
     
  3. macrumors newbie

    Joined:
    Oct 17, 2008
    #3
    Dont Use interface Builder

    Why are you going with interface builder and nibs stuff, create the views and everything from the coding itself then it doesn't make any memory problems.
    here is my sample code .

    HotelDetailsVIewController *elementController= [[HotelDetailsVIewController alloc] initWithIndexPath:indexPath];
    [[self navigationController] pushViewController:elementController animated:YES];
    [elementController release];
    it never given me any problems :)
     

Share This Page