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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T16:06:19+00:00 2026-05-28T16:06:19+00:00

I eliminated all the leaks from my current app. However Instruments constantly tells me

  • 0

I eliminated all the leaks from my current app. However Instruments constantly tells me that I have a leak in the method shown below.

The leak is of type NSMutableArray and has a size of either 16 or 32 bytes. Yes, I know that’s not much but it adds up. Also see it as an academic question that I need to solve to make my code leakless.

+ (id) meterFromDict:(NSDictionary*)dict {
    Meter* resMeter = [[Meter alloc] initWithType:[[dict objectForKey:@"MeterBase"] intValue]];
    //NSLog(@"dict: %@",dict);
    resMeter.volume = nil;
    resMeter.sounds = nil;
    resMeter.repeats = nil;

    resMeter.volume = [[[NSMutableArray alloc] initWithArray:[dict objectForKey:@"volumeArray"]] autorelease];
    resMeter.sounds = [[[NSMutableArray alloc] initWithArray:[dict objectForKey:@"soundsArray"]] autorelease];
    resMeter.repeats = [[[NSMutableArray alloc] initWithArray:[dict objectForKey:@"repeatsArray"]] autorelease];
    //NSLog(@"MeterFromDict called and resmeter.repeats count is : %i",[resMeter.repeats count]);
    resMeter.bpm = [[dict objectForKey:@"BPM"] floatValue];

    return [resMeter autorelease];
}
  • 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-28T16:06:20+00:00Added an answer on May 28, 2026 at 4:06 pm

    Without looking at your Instruments output directly I can’t tell exactly, but you’re writing some redundant code: Try this:

    + (id) meterFromDict:(NSDictionary*)dict {
        Meter* resMeter = [[Meter alloc] initWithType:[[dict objectForKey:@"MeterBase"] intValue]];
        //NSLog(@"dict: %@",dict);
    
        resMeter.volume = [dict objectForKey:@"volumeArray"];
        resMeter.sounds = [dict objectForKey:@"soundsArray"];
        resMeter.repeats = [dict objectForKey:@"repeatsArray"];
        //NSLog(@"MeterFromDict called and resmeter.repeats count is : %i",[resMeter.repeats count]);
        resMeter.bpm = [[dict objectForKey:@"BPM"] floatValue];
    
        return [resMeter autorelease];
    }
    

    There’s no point in nilling your properties before assigning new values to them.

    Also, No point creating new arrays for arrays that you already have. And if you have properly declared your volume, sounds and repeats properties with copy instead of retain.

    Try that and see if it works better.

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

Sidebar

Related Questions

From the following command how can i eliminate all the lines that occur before
Historically, I've always used mysql_real_escape_string() for all input derived from users that ends up
hello guys i am try to eliminate all the duplicate strings from a string
I'm working on a project that I need to eliminate all references to the
I have a do/while loop that goes over database rows. Because it runs many
If we remove one of our apps from the iPhone app store what is
I have 3 memory leaks after the launch of the iPhone application. These remain
I have a C++ class that writes its data out to a binary std::ofstream
I have a subclass of UIViewController that is responsible for a single UIWebView. Since
In our current project, we have one particular page where, when viewed in IE7

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.