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 7622149
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T04:22:47+00:00 2026-05-31T04:22:47+00:00

NB: To clarify what I’m trying to do here: I have an instance of

  • 0

NB: To clarify what I’m trying to do here:

I have an instance of a subclass of UIView. When this instance gets released from a View Controller I would like that the dealloc method of that instance be called.

The point being to release other objects within that instance of the subclass of UIView.

In the View Controller:

- (void)viewDidLoad
{
    [super viewDidLoad];

    self.mav = [[MapAreaView alloc]init];
    [self.view addSubview:self.mav];
    [self.mav release];

    t_ = [NSTimer scheduledTimerWithTimeInterval: 20.0f target: self selector:@selector(onTick) userInfo: nil repeats:NO];
}

and:

- (void)onTick
{
    NSLog(@"Releasing...");
    [t_ invalidate];
    t_ = nil;
    [self.mav release];
    [self.mav release];
    [self.mav release];
    NSLog(@"Done releasing.");
}

In MapAreaView:

- (void)dealloc
{
    NSLog(@"map view area dealloc called.");
    [super dealloc];
}

I am trying to release the MapAreaView and have it’s dealloc method called.

Also, when I run this app, Releasing... and Done releasing. get printed, but not map view area dealloc called. And despite all of my excessive release messages sent to self.mav the app doesn’t crash. Weird.

Ideas?

EDIT 1

@interface MemoryManagmentViewController : UIViewController {

    MapAreaView *mav_;
    NSTimer *t_;
}

@property (nonatomic, retain) MapAreaView *mav;

which is then synthesized: @synthesize mav = mav_;

EDIT 2

Please not that the timer is not for use in my real application. I’m just using it to learn about memory management.

  • 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-31T04:22:48+00:00Added an answer on May 31, 2026 at 4:22 am

    First off, don’t use [self.mav release]. This is incorrect use of properties, and is not guaranteed to release your object. Use self.mav = nil instead.

    Secondly, I presume your crazy timer is there just to try and force the release of your view and isn’t really code you are using? Because it really shouldn’t be there!

    To manage the memory of a view that you want to both keep a pointer to and add as a subview to your main view, remove the release and timer messages from your viewDidLoad. You now have one retained pointer to mav, via your property, and the view will be retaining it as well since it is a subview.

    In viewDidUnload, your view no longer exists so it will no longer have a pointer to mav. Therefore, if you put self.mav = nil there, mav will be released.

    You shouldnt try to release it while it is still a subview of another view.

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

Sidebar

Related Questions

Let me clarify this a bit... I have a class that handles XML files.
I would like to clarify details of the scheduler.getCurrentlyExecutingJobs() method in Quartz1.6. I have
Let me clarify my question. I'm trying to get an integer value from @student.rooms.last,
to clarify: there's only one rails command, which gets installed from the latest Rails
I just want to clarify one thing. This is not a question on which
I am writing to clarify some comments on this website. 1) I know that
UPDATE: To clarify a generic error catcher that catches 404's doesn't have enough granularity
Please clarify, how to deal with returned objects from methods? Below, I get employee
To clarify: no I can't make this pure PHP5 yes this code works in
Can someone please clarify the following; if a have the following model; presentation-->slide-->video where

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.