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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:23:54+00:00 2026-05-24T06:23:54+00:00

Having an issue with memory management i believe. i receive a EXC_BAD_ACCESS error when

  • 0

Having an issue with memory management i believe. i receive a “EXC_BAD_ACCESS” error when it tries to assign the second time (runs the code and makes the first assignment but the second time makes it die).

I have a function which will take an array of custom objects (contains a date and name variables). i need to sort this array into month specific arrays (all the aprils will go to aprilList, may into mayList, etc).

.h file

@class SceneData;

@interface DetailedSceneViewController : UIViewController <UITableViewDataSource,   UITableViewDelegate> 
{
    UITableView *mainTableView;
    SceneData *sceneData;
    NSArray *monthsArray;
}


@end

.m file

#import "SceneData.h"


- (void) sortMonths {
Agri_ImaGIS_iPhoneAppDelegate *dataCenter = (Agri_ImaGIS_iPhoneAppDelegate *) [[UIApplication sharedApplication] delegate];

NSMutableArray *janList, *febList, *marList, *aprList, *mayList, *junList, *julList, *augList, *sepList, *octList, *novList, *decList = [[NSMutableArray alloc] init];

int count = [dataCenter.sortedDataList count];

NSLog(@"count: %d", count);

for (int i = 0; i < count; i++)
{
    sceneData = [dataCenter.sortedDataList objectAtIndex:i];
    if ([sceneData.name rangeOfString:@"Jan" ].location != NSNotFound)
    {
        NSLog(@"jan name: %@", sceneData.name);
        [janList addObject: sceneData];
    }
    else if ([sceneData.name rangeOfString:@"Feb" ].location != NSNotFound)
    {
        NSLog(@"feb name: %@", sceneData.name);
        [febList addObject:sceneData];
    }
    else if ([sceneData.name rangeOfString:@"Mar" ].location != NSNotFound)
    {
        NSLog(@"Mar name: %@", sceneData.name);
        [marList addObject:sceneData];
    }
    else if ([sceneData.name rangeOfString:@"Apr" ].location != NSNotFound)
    {
        NSLog(@"Apr name: %@", sceneData.name);
        [aprList addObject:sceneData];
    }
    else if ([sceneData.name rangeOfString:@"May" ].location != NSNotFound)
    {
        NSLog(@"May name: %@", sceneData.name);
        [mayList addObject:sceneData];
    }
    else if ([sceneData.name rangeOfString:@"Jun" ].location != NSNotFound)
    {
        NSLog(@"Jun name: %@", sceneData.name);
        [junList addObject:sceneData];
    }
    else if ([sceneData.name rangeOfString:@"Jul" ].location != NSNotFound)
    {
        NSLog(@"Jul name: %@", sceneData.name);
        [julList addObject:sceneData];
    }
    else if ([sceneData.name rangeOfString:@"Aug" ].location != NSNotFound)
    {
        NSLog(@"Aug name: %@", sceneData.name);
        [augList addObject:sceneData];
    }
    else if ([sceneData.name rangeOfString:@"Sep" ].location != NSNotFound)
    {
        NSLog(@"Sep name: %@", sceneData.name);
        [sepList addObject:sceneData];
    }
    else if ([sceneData.name rangeOfString:@"Oct" ].location != NSNotFound)
    {
        NSLog(@"Oct name: %@", sceneData.name);
        [octList addObject:sceneData];
    }
    else if ([sceneData.name rangeOfString:@"Nov" ].location != NSNotFound)
    {
        NSLog(@"Nov name: %@", sceneData.name);
        [novList addObject:sceneData];
    }
    else if ([sceneData.name rangeOfString:@"Dec" ].location != NSNotFound)
    {
        NSLog(@"Dec name: %@", sceneData.name);
        [decList addObject:sceneData];
    }
}
}

am i handling the sceneData object incorrectly?

  • 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-24T06:23:55+00:00Added an answer on May 24, 2026 at 6:23 am

    You are not initializing correctly your arrays:

    NSMutableArray *janList, *febList, *marList, *aprList, *mayList, *junList, *julList, *augList, *sepList, *octList, *novList, *decList = [[NSMutableArray alloc] init];
    

    This syntax will only initialize the last pointer… You should use:

    NSMutableArray *janList = [[NSMutableArray alloc] init];
    NSMutableArray *febList = [[NSMutableArray alloc] init];
    ...
    NSMutableArray *decList = [[NSMutableArray alloc] init];
    

    On another note, all those object are leaking, since (if I am not missing something in your code) they are local variables (not autoreleased) and you don’t call release on them…

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

Sidebar

Related Questions

I believe I am having a memory issue using numpy arrays. The following code
I'm having an issue with memory management when dealing with callbacks and async code
I'm having an issue with the memory management in my application. I have an
As with any memory management issue, this is a long story, so strap-in. We
I am having issue with memory after running many times my app. java.lang.OutOfMemoryError: bitmap
I am having an issue hitting the memory limit of my application. My question
I'm having an issue which looks like a memory leak in one of my
i'm having a memory issue while testing a find/replace function. Say the search subject
I am having a memory issue with an algorithm I am using to Flatten
I'm having this issue with some objective C code to load the images on

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.