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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T20:14:21+00:00 2026-05-29T20:14:21+00:00

I have many of this annotations(about 2400), but here is my problem. I get

  • 0

I have many of this annotations(about 2400), but here is my problem.

I get the following errors

potential leak of an object allocated on line 81 and stored into
‘annot1’
potential leak of an object allocated on line 81 and stored into ‘annot2’

potential leak of an object allocated on line 81 and stored into
‘annot3’

And so on. Here is my code:

MKPointAnnotation *annot1 = [[MKPointAnnotation alloc] init]; 
annot1.title = @"A"; 
annot1.subtitle=@"A1"; 
annot1.coordinate = CLLocationCoordinate2DMake(21.978954, 120.752663); 
[mapView addAnnotation:annot1]; 
MKPointAnnotation *annot2 = [[MKPointAnnotation alloc] init]; 
annot2.title = @"B"; 
annot2.subtitle=@"B2"; 
annot2.coordinate = CLLocationCoordinate2DMake(21.988607, 120.748703); 
[mapView addAnnotation:annot2]; 

MKPointAnnotation *annot4 = [[MKPointAnnotation alloc] init]; 
annot4.title = @"C"; 
annot4.subtitle=@"C1"; 
annot4.coordinate = CLLocationCoordinate2DMake(22.008867, 120.743637); 
[mapView addAnnotation:annot4]; 
MKPointAnnotation ***strong text**annot5 = [[MKPointAnnotation alloc] init]; 
annot5.title = @"D"; 
annot5.subtitle=@"D1"; 
annot5.coordinate = CLLocationCoordinate2DMake(22.016190, 120.837601); 
[mapView addAnnotation:annot5]; 
MKPointAnnotation *annot6 = [[MKPointAnnotation alloc] init]; 
annot6.title = @"E"; 
annot6.subtitle=@"E1"; 
annot6.coordinate = CLLocationCoordinate2DMake(22.024183, 120.743401); 
[mapView addAnnotation:annot6]; 
MKPointAnnotation *annot7 = [[MKPointAnnotation alloc] init]; 
annot7.title = @"F"; 
annot7.subtitle=@"F1"; 
annot7.coordinate = CLLocationCoordinate2DMake(22.055653, 121.509689); 
[mapView addAnnotation:annot7]; 
MKPointAnnotation *annot8 = [[MKPointAnnotation alloc] init]; 
annot8.title = @"G"; 
annot8.subtitle=@"G2"; 
annot8.coordinate = CLLocationCoordinate2DMake(22.070082, 120.713684); 
[mapView addAnnotation:annot8]; 

etc

{

  • 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-29T20:14:23+00:00Added an answer on May 29, 2026 at 8:14 pm

    If you’re not using ARC then you should release the object after you add it to your mapview.

    For example:

    MKPointAnnotation *annot1 = [[MKPointAnnotation alloc] init]; 
    annot1.title = @"A"; 
    annot1.subtitle=@"A1"; 
    annot1.coordinate = CLLocationCoordinate2DMake(21.978954, 120.752663); 
    [mapView addAnnotation:annot1]; 
    

    Should be updated to:

    MKPointAnnotation *annot1 = [[MKPointAnnotation alloc] init]; 
    annot1.title = @"A"; 
    annot1.subtitle=@"A1"; 
    annot1.coordinate = CLLocationCoordinate2DMake(21.978954, 120.752663); 
    [mapView addAnnotation:annot1];
    [annot1 release]
    

    The reason is that your object reference count never hit zero and the object is never released.

    MKPointAnnotation *annot1 = [[MKPointAnnotation alloc] init];
    

    When you allocate an object it has a reference count of 1. If you add an object to an array or dictionary the reference count is incremented. So after the following block of code you have a reference count of two.

    MKPointAnnotation *annot1 = [[MKPointAnnotation alloc] init]; 
    annot1.title = @"A"; 
    annot1.subtitle=@"A1"; 
    annot1.coordinate = CLLocationCoordinate2DMake(21.978954, 120.752663); 
    [mapView addAnnotation:annot1]
    

    Now, if you call release on annot1 after you add it to your mapview the object isn’t really released yet. This is because the data structure in your mapview is holding reference to it.

    [mapView addAnnotation:annot1]
    

    Once you’re done with your mapview and it is released then annot1 is finally destroyed.

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

Sidebar

Related Questions

There have been many debates about this topic already here, but none of them
I have seen many answers for this type of question but its not related
I have seen many posts on this subject, but none have been answered, and
I have many errors in my apache error log like this: [Mon Mar 26
I've got the following (simplified) problem: I have a entity in a Many-To-One relationship:
I have been stressed out with many responses about this issue and many people
Hello I have got this php order by annotations on my one to many
I have been struggling with this for long. I read many resources but still
I get the famous out of memory error. But i have tried many of
I have seen many posting this issue in SO. I have gone through those

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.