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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T15:28:22+00:00 2026-06-10T15:28:22+00:00

Have problems with memory have code that looks like this: Have EXC_BAS_ACCESS @interface MapList

  • 0

Have problems with memory have code that looks like this:

Have EXC_BAS_ACCESS

@interface MapList : NSObject
{
    NSArray* m_units;
}
-(MapList*) loadMapListWithLevel:(uchar) lvl chapter: (uchar) chapt;
-(void) dealloc;
@end

and implementation:

-(MapList*) loadMapListWithLevel:(uchar) lvl chapter: (uchar) chapt
{
    self =[super init];
    if (self)
    {
         {
            ...

            NSMutableArray* array = [[NSMutableArray alloc] initWithCapacity:size];

            for (uint j=0;j<size;j++)
            {
                obj =[[SpriteDB alloc] init];
                [array addObject:obj];
                [obj release];
            }
            if (i==0)
                m_units = [NSArray arrayWithArray:array];

            [array release];
        }
        ...
    }
    return self;
}

-(void) dealloc
{
    [m_units release];
    [super dealloc];
}

And in one method I call them like this

MapList* mpl = [[MapList alloc] loadMapListWithLevel:level chapter:chapter];
[mpl release];

Where is problem? When I comment [m_units release]; it works…

  • 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-10T15:28:24+00:00Added an answer on June 10, 2026 at 3:28 pm

    m_units = [NSArray arrayWithArray:array]; gives you an autoreleased value. When you do a second release, you are over releasing this object. Even accessing this value after the return of the runloop will give you memory problems. Retain this value, and release it on your dealloc. Also, you should use properties.

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

Sidebar

Related Questions

I have some code in my application that looks something like this: char *hash
I have something that looks like this: my $report = new ReportGenerator; #custom object
I have a problem with a memory leak. I have this code in a
We have a couple of sites which have some memory problems and fairly often
I have successfully debugged my own memory leak problems. However, I have noticed some
This is a C# problem. I have a big object in memory at a
I have a piece of templated code that is never run, but is compiled.
it looks like I'm facing a typical memory outage problem when using a PHP
This looks like a long question because of all the context. There are 2
I have a class that is managed by ninject as a singleton that looks

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.