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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T23:24:16+00:00 2026-05-18T23:24:16+00:00

I have a situation in my code, where I cannot clean up my classes

  • 0

I have a situation in my code, where I cannot clean up my classes objects without first calling [super dealloc]. It is something like this:

// Baseclass.m
@implmentation Baseclass

...

-(void) dealloc
{
    [self _removeAllData];
    [aVariableThatBelongsToMe release];
    [anotherVariableThatBelongsToMe release];
    [super dealloc];
}

...

@end

This works great. My problem is, when I went to subclass this huge and nasty class (over 2000 lines of gross code), I ran into a problem: when I released my objects before calling [super dealloc] I had zombies running through the code that were activated when I called the [self _removeAllData] method.

// Subclass.m
@implementation Subclass

...

-(void) dealloc
{
    [super dealloc];

    [someObjectUsedInTheRemoveAllDataMethod release];
}     

...

@end

This works great, and It didn’t require me to refactor any code. My question Is this: Is it safe for me to do this, or should I refactor my code? Or maybe autorelease the objects?

I am programming for iPhone if that matters any.

  • 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-18T23:24:16+00:00Added an answer on May 18, 2026 at 11:24 pm

    Okay, I was talking rubbish. [super dealloc] does need to be called last.

    Of course, this doesn’t answer your question.

    Without looking at your code it’s hard to see, but the trouble seems to come from the _removeAllData method

    Firstly, you shouldn’t be prefixing methods with an underscore as that prefix is reserved by Apple (Reference) for private methods.

    Secondly, it is obviously used for tidying up the object and might be releasing objects that you are then manually releasing later on. It could even be releasing objects defined in one of the super classes that are then being over released in [super dealloc].

    So, after a bit of thought (more than it should have taken, really) the problem isn’t in where your super’s dealloc is called; but in what is being cleaned up and when.

    Sorry about my earlier mistake, and thanks to the commenters who persuaded me of my error rather than letting me persist in my error.

    Original answer

    Yes. As long as you don’t try to use any of the superclass’s variables.

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

Sidebar

Related Questions

In my code I have often situations like this: public void MyMethod(string data) {
I have recently come across a situation where code is dynamically loading some libraries,
Here's the situation: We have some generic graphics code that we use for one
I am using Stripes for a project and have a situation I cannot understand.
I have been in this situation quite a few times where visual studio does
We have a situation where users are allowed to upload content, and then separately
We have a situation in our product where for a long time some data
I have a situation where I might have multiple instances of a program running
I have the situation where i use GIS software which stores the information about
I have a situation where I want to create a signature of a data

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.