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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T04:46:31+00:00 2026-05-24T04:46:31+00:00

While analysing our project Xcode came with a posibe leak notification at a custom

  • 0

While analysing our project Xcode came with a posibe leak notification at a custom UIBarButtonItem.
I fixed the leak, but while loading the view for the second time, [super dealloc] gives a EXC_BAD_ACCESS error.

Removing the autorelease from the UIBarButtonItem (so returning the warning):

self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithCustomView:toolbar] autorelease];

gives no problems while reloading the screen.

Custom UIBarButtonItem and dealloc code:

- (void)viewDidLoad
{
    [super viewDidLoad];

    // create a toolbar to have the buttons at the right side of the navigationBar
    UIToolbar* toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 150, 44.01)];
    toolbar.tintColor = [UIColor clearColor];
    [toolbar setTranslucent:YES];

    // create the array to hold the buttons, which then gets added to the toolbar
    NSMutableArray* buttons = [[NSMutableArray alloc] initWithCapacity:4];


    // Create a comments button
    propertiesButton = [[UIBarButtonItem alloc]
                        initWithBarButtonSystemItem:UIBarButtonSystemItemSearch target:self action:@selector(properties)];
    [buttons addObject:propertiesButton];
    [propertiesButton release];

    // Create a comments button
    commentaryButton = [[UIBarButtonItem alloc]
                        initWithBarButtonSystemItem:UIBarButtonSystemItemCompose target:self action:@selector(comments)];
    [buttons addObject:commentaryButton];
    [commentaryButton release];

    // create a versions button
    versionsButton = [[UIBarButtonItem alloc]
                      initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks target:self action:@selector(versions)];
    [buttons addObject:versionsButton];
    [versionsButton release];

    // create a save button
    downloadButton = [[UIBarButtonItem alloc]
                      initWithBarButtonSystemItem:UIBarButtonSystemItemOrganize target:nil action:@selector(download)];
    [buttons addObject:downloadButton];
    [downloadButton release];

    // stick the buttons in the toolbar
    [toolbar setItems:buttons animated:NO];

    [buttons release];

    // and put the toolbar in the nav bar
    self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithCustomView:toolbar] autorelease];
    [toolbar release];
}

- (void)dealloc
{
    [popOverController release];
    [propertiesButton release];
    [downloadButton release];
    [versionsButton release];
    [commentaryButton release];
    [webView release];
    [super dealloc];
}

With NSZombieEnabled i get

'2011-08-01 10:30:36.571 ProjectName[100:707] *** -[UIBarButtonItem release]: message sent to deallocated instance 0x1fb330'

We are not sure how to fix the problem.

Thank you in advance.

  • 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-24T04:46:31+00:00Added an answer on May 24, 2026 at 4:46 am

    You are releasing propertiesButton, downloadButton, versionsButton, commentaryButton two times. First time in viewDidLoad and again in dealloc.

    You don’t have to release them in dealloc as you have already released it in viewDidLoad.

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

Sidebar

Related Questions

I came across this code while working through code-analysis warnings on our code base.
my problem is the GIL of course. While I'm analysing data it would be
I've written a custom task for analyzing code coverage results. While building the entire
While analyzing some approaches to making our web app easier to deploy on our
I'm using 3.5 SP1 on my machine, while our customers currently use 3.5 without
With a customer web site we currently experiences performance problems. While analyzing the problem
While the C# spec does include a pre-processor and basic directives (#define, #if, etc),
While going through university and from following the development of SO, I've heard a
While I've seen rare cases where private inheritance was needed, I've never encountered a
While setting up CruiseControl, I added a buildpublisher block to the publisher tasks: <buildpublisher>

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.