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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T18:32:57+00:00 2026-06-08T18:32:57+00:00

I have an nsmutablearray which i need through out the application so i declared

  • 0

I have an nsmutablearray which i need through out the application so i declared it in application delegate and release it in dealloc method of application delegate. Here is the code for that.

@interface AppDelegate : UIResponder <UIApplicationDelegate>{
    NSMutableArray *arr1;
    IBOutlet UINavigationController *navConroller;
}
@property (strong, nonatomic) IBOutlet UIWindow *window;
@property (nonatomic, retain) UINavigationController *navConroller;
@property (nonatomic, retain) NSMutableArray *arr1;


@implementation AppDelegate
@synthesize navConroller;
@synthesize window = _window;
@synthesize arr1;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.arr1 = [[NSMutableArray alloc] init];
    [self.window addSubview:navConroller.view];
    [self.window makeKeyAndVisible];
    return YES;
}

- (void)dealloc
{
    [self.arr1 release];
    [_window release];

    [super dealloc];
}

when i check memory performance tool it shows me memory leak at

self.arr1 = [[NSMutableArray alloc] init];

I am using this array in different classes. Any suggestion will be appreciated.

I used Pieter Gunst answer and leak stop at that place. but it is showing at another place. where i pares json and storing records in arr1. Here is the code for that.

-(void) apiCall:(NSString *)para1 {
    SBJSON *parser = [[SBJSON alloc] init];

    para1 = [para1 stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
    para1 = [para1 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

    NSString *url = [[[NSString alloc] initWithFormat:@"my api url",para1] autorelease];

    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:url]];
    NSData *response = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
    NSString *json_string = [[NSString alloc] initWithData:response encoding:NSUTF8StringEncoding]; 

    arr1 = [parser objectWithString:json_string error:nil];

    [json_string release];
    [parser release];

}

Now leak shows at following line.

arr1 = [parser objectWithString:json_string error:nil];

Any suggestion ?

  • 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-06-08T18:32:58+00:00Added an answer on June 8, 2026 at 6:32 pm

    You have allocated array and also retained it by accessing property.
    Change below line of code;

    self.arr1 = [[NSMutableArray alloc] init];
    

    with either of any below line..

    arr1 = [[NSMutableArray alloc] init];
    

    OR

    self.arr1 = [NSMutableArray array];
    

    OR

    NSMutableArray *tArr1 = [[NSMutableArray alloc] init];
    self.arr1 = tArr1;
    [tArr1 release];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's my current situation: I have a NSMutableArray named dictKeyArray which I assign a
I have this NSMutableArray which is a collection of objects that are being moved
I have a method which i need to call within another method. in a
I have a NSMutableArray consisting out of NSString s. When I need to sort
Good day. I have an NSMutableArray that contains references to objects. I need to
I currently have a three dimensional NSMutableArray which I need to deep copy. However,
I have an NSMutableArray which has five objects in it. I want to insert
I have an NSMutableArray which I assign with: NSMutableArray *newElements = [[NSMutableArray alloc] initWithObjects:self.currentScene.elements,
Essentially I have an NSMutableArray which contains several NSDictionaries . I wish to sort
All. I have a NSMutableArray , which name is dummyPerson. And it's element is

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.