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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T00:06:51+00:00 2026-06-05T00:06:51+00:00

I have a big problem in my application and I’m wondering how to resolve

  • 0

I have a big problem in my application and I’m wondering how to resolve it. I’ve searched a lot in SO but I cannot find a valid solution. Here the scenario I’m working on.

I have a NON-ARC application and I’m using a bunch of ARC classes within it. These classes belong to GMGridView. These classes have been added to the project with -fobjc-arc directive.

This is the code I’m using (for the sake of simplicity I added only key parts).

Memory management section

- (void)dealloc
{
    [gmGridView setActionDelegate:nil];
    [gmGridView setDataSource:nil];
    [gmGridView release];    

    [super dealloc];
}

ViewDidLoad section

- (void)viewDidLoad
{
    [super viewDidLoad];

    NSInteger topBottomSpacing = 20;
    NSInteger leftRifghtSpacing = 75;
    NSInteger itemSpacing = 5;

    UIView* mainView = [self view];

    GMGridView* gridView = [[[GMGridView alloc] initWithFrame:mainView.bounds] autorelease];    
    gridView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
    gridView.backgroundColor = [UIColor clearColor];   
    gridView.style = GMGridViewStyleSwap;
    gridView.itemSpacing = itemSpacing;
    gridView.minEdgeInsets = UIEdgeInsetsMake(topBottomSpacing, leftRifghtSpacing, topBottomSpacing, leftRifghtSpacing);
    gridView.centerGrid = NO;
    gridView.actionDelegate = self;
    gridView.dataSource = self;    
    [mainView addSubview:gridView];

    [self setGmGridView:gridView]; // retain policy
}

DataSource section

- (GMGridViewCell *)GMGridView:(GMGridView *)gridView cellForItemAtIndex:(NSInteger)index
{
    CGSize size = [self GMGridView:gridView sizeForItemsInInterfaceOrientation:[[UIApplication sharedApplication] statusBarOrientation]];

    GMGridViewCell *cell = [gridView dequeueReusableCell];    
    if (!cell) {

        cell = [[[GMGridViewCell alloc] initWithFrame:CGRectMake(0, 0, size.width, size.height)] autorelease];

        InternalView *view = [[[InternalView alloc] initWithFrame:CGRectMake(0, 0, size.width, size.height)] autorelease];
        cell.contentView = view;
    }

    return cell;
}

When I’m using Zombie Objects, the application works well. No errors. But when I disable Zombie Objects the application crashes EXC_BAD_ACCESS in main method. This is quite strange for me since if Zombies are enabled, I would see a detail of that error that happens in main.

The things I’m not pretty sure are the autorelease calls in the code, but I think that If I don’t put the objects in an autorelease pool they will leak.

GMGridView* gridView = [[[GMGridView alloc] initWithFrame:mainView.bounds] autorelease];

cell = [[[GMGridViewCell alloc] initWithFrame:CGRectMake(0, 0, size.width, size.height)] autorelease];

Investigating a bit I found that if I comment [gmGridView release] in dealloc method, the app stops to crash. So what does this mean? If I don’t call release, will the gmGridView leak?

Do you have any suggestions? Thank you in advance.

EDIT

I added some code in - (GMGridViewCell *)GMGridView:(GMGridView *)gridView cellForItemAtIndex:(NSInteger)index method. I forgot to add it the first time.

The dealloc method of InternalView (of type UIView) seems the root of the problem. Here the code.

- (void)dealloc
{    
    [addButton release]; // it's added to self addSubview, it has also a retain policy
    [imageView release]; // it's added to detView addSubview, it has also a retain policy
    [detView release]; // it's added to self addSubview, it has also a retain policy

    [super dealloc];
}

Commenting [detView release], the crash goes away.

  • 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-05T00:06:53+00:00Added an answer on June 5, 2026 at 12:06 am

    Flex_Addicted,

    Judging from your code, we are looking at MRR code (i.e. non-ARC). If it was ARC, you could not have the [super dealloc], the -release nor -autorelease.

    Is that what you intend? If so, then you have an early deallocation. I recommend that you convert this class to ARC. ARC, along with the static analyzer, will find early deallocation problems and handle them.

    Andrew

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

Sidebar

Related Questions

I'm writing not so complicated application but I have a big problem;) In my
I installed the Zend Framework, but I have a big problem here. When I
i have a big problem here..i am using Microsoft charting controls in my asp.net
I have a very big problem and can't seem to find anybody else on
I have got a big problem. After searching through the internet, I didn't find
I have a big problem with sessions. I drive to create an application around
i have a little problem here. I am working on a little application wich
I have a big problem with my application and the memory. The application (java
I'm currenty writing small application for image processing. However I have a big problem
I have facing a big problem with my webView application for android. It was

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.