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

  • Home
  • SEARCH
  • 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 3212516
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T14:50:46+00:00 2026-05-17T14:50:46+00:00

A problem happens when I was trying to release one of my instance variables

  • 0

A problem happens when I was trying to release one of my instance variables and reassign it a new value.

I would like to release the address that a instance variable points to, and re-assign a new value to it.

The code look like this:
The .h

@interface MapPageController : UIViewController<MKMapViewDelegate> {
 AddressAnnotationManager *addAnnotation;
}
- (IBAction) showAddress;
@property (nonatomic, retain) AddressAnnotationManager *addAnnotation;

The .m

@synthesize addAnnotation;
- (IBAction) showAddress {
        if(addAnnotation != nil) {
  [mapView removeAnnotation:addAnnotation];
  [addAnnotation release]; // this generates the problem
  addAnnotation = nil;
 }
 addAnnotation = [[AddressAnnotationManager alloc] initWithCoordinate:location];
 addAnnotation.pinType = userAddressInput;
 addAnnotation.mSubTitle = addressField.text;
}

However, with [addAnnotation release], a EXC_BAD_ACCESS always comes along if the process runs through it.

Thus I printed out the memory address in the dealloc of AddressAnnotationManager:

- (void)dealloc {
 NSLog(@"delloc Instance: %p", self);
 [super dealloc];
}

I turned on Zombie, the console gave me something like this:

2010-10-10 17:02:35.648 [1908:207] delloc Instance: 0x46c7360

2010-10-10 17:02:54.396 [1908:207] -[AddressAnnotationManager release]: message sent to deallocated instance 0x46c7360*

It means the code reaches dealloc before the problem occurs.

I have checked all the possible places where I could release addAnnotation. However, I could not find any.

Does anyone happen to find what the problem is?

  • 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-17T14:50:47+00:00Added an answer on May 17, 2026 at 2:50 pm

    I suspect that this is not the whole code involving the addAnnotation variable. Most likely [mapView removeAnnotation:addAnnotation];, which releases addAnnotation, already makes the reference count drop to zero. Do you have something like this in your code somewhere ?

     [mapView addAnnotation:addAnnotation];
     [addAnnotation release];
    

    If so, then you have transfered the complete ownership of addAnnotation to the mapView and you don’t need to release it in showAddress any more, which means that removeAnnotation: is enough.

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

Sidebar

Related Questions

The problem in a nutshell: This is what happens when trying to insert a
I've been trying to find a good architecture for one application for the last
I have a problem calling a batch file from another batch file when trying
hello i'm a beginner java developer and this is one question in a list
I have numerous classes that use the various NSDictionary/NSArray collection classes as ivars but
I have recently been trying to upgrade my app form Rails 2.3.8 to newly-releases
I am creating a view like this: UILabel *qty = [[UILabel alloc] initWithFrame:CGRectMake(0, 0,
Hi I am trying to create a multi-modules project in eclipse with m2eclipse. I
I am new to Asterisk (VoIP) and am rather new to UNIX/Perl. I'm taking
I am looking for hints on how to debugging a crash in an application

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.