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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:13:26+00:00 2026-05-26T00:13:26+00:00

I’ve the following problem: I’m accessing foursquares Venue API and get a JSON string

  • 0

I’ve the following problem:

I’m accessing foursquares Venue API and get a JSON string back. I parse this string with this json-framework. After that I’m saving the dictionaries and arrays for accessing further information about the venues (in special I’m using the explore API). So the venue information is saved deeply (for my experience) in the json-structure tree. And after getting the needed information (venue name & coordinates) I put a corresponding pin on a map with the same coordinates and with the venue’s name as the pin’s name.

And exactly at the point where I want to set the pin’s name, I get a memory leak. So something get’s wrong here. If I don’t set any title, all works fine. So the memory leak occurs only when I’m setting the name of the venue to the pin.

Here is the corresponding code fragment:

- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
    //Parse JSON string
    // Store incoming data into a string
    NSString *jsonString = [[NSString alloc] initWithData:self.fetchedJSONData encoding:NSUTF8StringEncoding];
    [self.fetchedJSONData setLength:0];

    // Create a dictionary from the JSON string     
    NSDictionary *results = [NSDictionary dictionaryWithDictionary:[jsonString JSONValue]];
    [jsonString release];

    NSDictionary *response = [NSDictionary dictionaryWithDictionary:[results objectForKey:@"response"]];

    NSArray *groups = [NSArray arrayWithArray:[response objectForKey:@"groups"]];
    NSDictionary *groupsDic = [groups lastObject];
    NSArray *items = [NSArray arrayWithArray:[groupsDic objectForKey:@"items"]];

   for (int i=0; i<[items count]; i++)
   {
        CLLocationCoordinate2D annotationCoord;
        MKPointAnnotation *annotationPoint = [[MKPointAnnotation alloc] init];
        NSDictionary* oneItemDoc = [NSDictionary dictionaryWithDictionary:[items objectAtIndex:i]]; 
        NSDictionary *singleVenue = [NSDictionary dictionaryWithDictionary:[oneItemDoc objectForKey:@"venue"]];             

        /*
         *          Leak here in the next two lines!
         *
         */

        NSString *titleName = [[[singleVenue objectForKey:@"name"] copy] autorelease]; 
        annotationPoint.title = titleName;

        NSDictionary *locationOfVenue = [NSDictionary dictionaryWithDictionary:[singleVenue objectForKey:@"location"]];

        annotationCoord.latitude = [[locationOfVenue objectForKey:@"lat"] doubleValue];
        annotationCoord.longitude = [[locationOfVenue objectForKey:@"lng"] doubleValue];               
        annotationPoint.coordinate = annotationCoord;

        [self.mapView addAnnotation:annotationPoint];
        [self.annotationsArray addObject:annotationPoint];
        [annotationPoint release];
   }
}

So the leak occurs when I want to set the title for the annotationPoint.

For each venue fetched with JSON I get the following leak trace (blurred libraries are my own libraries):

All blurred responsible libraries are my own app

Has anybody a suggestion how to solve this problem? I tried many, many things. So the key issue seems to be how to “hand over” the [singleVenue objectForKey:@"name"] correctly. I first tried to set it without a copy and an autorelease, but then I get a zombie object. So I don’t know how to do this. I think the problem are not these two lines, but some lines above them. Am I right? I also have the suggestion, that my 3rd party json parser is forcing this problem (cf. leak trace).

So I hope someone can help me to fix this problem. Would be really great!

Update: The problem seems to be independent of the corresponding JSON parser. I’ve testet my code with another parser, same problem there. So it has to do something with my code itself.

I think I know what’s the problem. So the leak occurs after closing the map. So after dealloc. So it might be, that I’ve missed something there. I have a mapview and I also release it in dealloc and set it to nil in viewDidUnload. I also release all the other Arrays etc. in dealloc. Is there something else (specific about the map and view) which I need to release? I think this might be the problem!

Update: Solved the problem: I had to set all Foursquare pins’ title and subtitle to nil in the dealloc method, because a value (accessed via a JSON parser) was retained by the map view somehow. Now all works fine!

  • 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-26T00:13:26+00:00Added an answer on May 26, 2026 at 12:13 am

    Solved the problem: I had to set all Foursquare pins’ title and subtitle to nil in the dealloc method, because a value (accessed via a JSON parser) was retained by the map view somehow. Now all works fine!

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

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am currently running into a problem where an element is coming back from
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Does anyone know how can I replace this 2 symbol below from the string
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string
this is what i have right now Drawing an RSS feed into the php,

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.