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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T16:31:51+00:00 2026-05-24T16:31:51+00:00

I’m currently using a singleton as a data store for my app. I essentially

  • 0

I’m currently using a singleton as a data store for my app. I essentially store a number of events that are pulled and parsed from a web service and then added as needed. Each time I make a request from the web service, I parse the results and see if the items already exist. If they do, I delete them and add the updated version provided by the web service.

Everything appeared to be working properly until I fired up the Instruments panel to find out that my system is leaking the objects every time it loads them from the web service (from the second time on). The core method where things appear to be messing up is this one, which is located in my HollerStore singleton class:

- (void)addHoller: (Holler *)h
{
    //Take a holler, check to see if one like it already exists
    int i = 0;

    NSArray *theHollers = [NSArray arrayWithArray:allHollers];
    for( Holler *th in theHollers )
    {
        if( [[th hollerId]isEqualToString:[h hollerId]] )
        {
            NSLog(@"Removing holler at index %i", i);
            [allHollers removeObjectAtIndex:i];
        }
        i++;
    }
    [allHollers addObject:h];
}

Quick explanation: I decided to copy the allHollers NSMutableArray into theHollers because it’s being updated asynchronously by NSURLConnection. If I update it directly, it results in a crash. As such, I switched to this model hoping to solve the problem, however the Instruments panel is telling me that my objects are leaking. All the counts are exactly the # of items I have in my data set.

From what I can tell removeObjectAtIndex isn’t effectively removing the items. Would love to get the thoughts of anybody else out there on three things:

  1. Is my analysis correct that something else must be retaining the individual hollers being added?
  2. Should I be using CoreData or SQLite for storing information pulled from the web service?
  3. Do you know how long data stored in a Singleton should be available for? Until the app is killed?

Update
I think I’ve found the source, however perhaps someone can provide some clarity on the proper way to do this. I’ve created a method called parseHoller which takes a dictionary object created through SBJSON and returns my own model (Holler). Here are the last couple lines:

Holler *h = [[[Holler alloc] initFromApiResponse:hollerId 
                                       creatorId:creatorId 
                                     creatorName:creatorName 
                                 creatorImageUrl:creatorImage 
                                        comments:comments 
                                       attendees:attendees 
                                          wishes:wishes 
                                        invitees:invites 
                                       createdAt:createdAt 
                                            text:text 
                                           title:title 
                                            when:when]autorelease];
//(some other autorelease stuff is here to clean up the internal method)
return h;

I figured that since I’m returning an autoreleased object, this should be fine. Do you see anything wrong with this?

  • 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-24T16:31:52+00:00Added an answer on May 24, 2026 at 4:31 pm

    Have you tried to do a retain count on the objects that is leaking? Maybe that could clear up when or where it is being retained.
    The code should be

    [putObjectHere retainCount];

    and then write to an NSLog

    Hope it gives you something

    Peter

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

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am currently running into a problem where an element is coming back from
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I want use html5's new tag to play a wav file (currently only supported
I have a JSP page retrieving data and when single or double quotes are
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

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.