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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:18:06+00:00 2026-05-27T06:18:06+00:00

I ran ‘analyze in xcode on a current iOS project to try to track

  • 0

I ran ‘analyze” in xcode on a current iOS project to try to track down a freeze issue and there are a number of memory alerts that I don’t understand (screenshot of one below).

What is going on there: I have a custom ObjC class extending NSObject; in the init method I alloc/init an NSMutableArray and then in a loop, populate it with NSMutableArrays. This nested array is declared as a property and released in dealloc(). It lives for the life of the app.

Am I doing this wrong? I don’t understand the alert#3: @ object not referenced in this execution path and has a retain count of +1.

Since my class allocs the outer array, it owns it and will clean it up. Do the inner arrays need to be released?

Thanks for any tips – still new at this.

screenshot of xcode memory alert

EDIT/ADDITION
Trying to stamp out the additional memory warnings I am getting so I thought I would add to the question here in the event someone stumbles upon this w/ the same issue.

I am getting the following alert with the code below (the 2nd line “[keyArray addObject: etc”). What is going on: I have a custom class (Key – based on NSObject) that I instance and store in an array. Based on answers to my previous question, I guess my alloc increases the retain count and then when it is added to the array, the retain count isn’t decremented – so the memory warning occurs.

What is the proper way to handle something like this? Use a placeholder like this:

Key * k = [[Key alloc] initKeyWithPath:path isBlackKey:NO]];
[keyArray addObject: k];
[k release];

Is that the proper way to do it? Or is there I way to write the custom class to return an autoreleased obj? (thanks and sorry to be so long winded!).

Potential leak of an object allocated on line 460
Method returns an Objective-C object with a +1 retain count (owning reference)
Object allocated on line 460 is not referenced later in this execution path and has a retain count of +1 (object leaked)

-(void) addOctaveToArraysWithTransform:(CGAffineTransform*)trans andPath: (CGMutablePathRef) path
{
    path = [self createCF_keyUsingTransform: trans];
    [keyArray addObject:[[Key alloc] initKeyWithPath:path isBlackKey:NO]];
}

Key.h

#import <Foundation/Foundation.h>
#import "Key.h"

@interface Key : NSObject {
    @public
    CGMutablePathRef keyPath;
    BOOL isBlackKey;
    NSValue * path;
    int keyState;
    BOOL needsRedraw;
 }

 @property (nonatomic, assign) int keyState;
 @property (nonatomic, assign) BOOL needsRedraw;
 @property (nonatomic) CGMutablePathRef keyPath;

 -(id) initKeyWithPath:(CGMutablePathRef) aPath isBlackKey:(BOOL)flag;
 -(CGMutablePathRef) getKeyPath;

@end

Key.m

#import "Key.h"

@implementation Key

@synthesize keyState, needsRedraw, keyPath;

-(id) initKeyWithPath:(CGMutablePathRef) aPath isBlackKey:(BOOL)flag
{
    if ((self = [super init])){
         isBlackKey = flag;
         keyState = 0;
         needsRedraw = NO;
         keyPath = aPath;
         CGPathRetain(keyPath);
 }
return self;
}

-(CGMutablePathRef) getKeyPath
{
    return  keyPath;
}
@end
  • 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-27T06:18:07+00:00Added an answer on May 27, 2026 at 6:18 am

    You have an allocation of an NSMutableArray on each iteration of the for-loop. Instead use: NSMutableArray array] which is a convenience method that return an autoreleased NSMUtableArray suitable for adding to fieldNotes which will retain the NSMutableArray.

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

Sidebar

Related Questions

I ran into an issue with an IIS web app shutting down an idle
I ran into an interesting (and very frustrating) issue with the equals() method today
I ran across an odd problem while trying to transfer a project to a
Ran into an issue today that I have not been able to resolve. I
Ran across this recently and wondering if someone out there can give me a
Ran into this problem today, posting in case someone else has the same issue.
We ran into an issue where our log table got far larger far faster
I ran across an issue whenever I was trying to sort a vector of
I ran into an issue today and I have been stumped for some time
Ran into a bit of an issue with some jQuery code, but in essence,

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.