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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T16:43:29+00:00 2026-05-30T16:43:29+00:00

I get leaks if I dont put it in dealloc. I get a crash

  • 0

I get leaks if I dont put it in dealloc. I get a crash EXC_BAD_ACCESS If I do. I cannot see anything wrong with this code. The bad access is pointed at [events release]. Have I made a mistake in the code below or is Instruments just having a laugh at my expense?

events is an NSArray

@interface EventsViewController : UITableViewController 
{    
@private
    NSArray *events;
}

 - (void)viewDidLoad
    {
        events = [[self getEvents] retain];
    }

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

    - (NSArray*)getEvents
    {
        NSMutableArray *response = [[[NSMutableArray alloc] init] autorelease];

       //Some sql
       while(sqlite3_step(statement) == SQLITE_ROW)
       {
           Event *event = [[[Event alloc] init] autorelease];
           event.subject = [NSString stringWithUTF8String:(char *)sqlite3_column_text(statement, 0)];

          [response addObject:event];
       }
       return response;
    }

Update
A lot of you are saying the code is fine which is a plus. I dont manipulate events elsewhere – I have removed any code that does to try and single out the crash. Perhaps its in the parent view?

This is the click event that pushes the EventsViewController:
– (void)eventsClick:(id)sender

{
    EventsViewController *eventsViewController = [[EventsViewController alloc] initWithNibName:@"EventsViewController" bundle:nil];
    eventsViewController.anywhereConnection = anywhereConnection;
    eventsViewController.contact = contact;

    [[self navigationController] pushViewController:eventsViewController animated:YES];
    [eventsViewController release];
}

The crash is actually happening when I return to the parent view. (I think it is considered a parent in this scenario). But perhaps the [eventsViewController release] just triggers dealloc in the EventViewController.

  • 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-30T16:43:31+00:00Added an answer on May 30, 2026 at 4:43 pm

    try putting

    events = nil; 
    

    in dealloc.

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

Sidebar

Related Questions

I get an EXC_BAD_ACCESS error at a place that doesn't have anything to do
What are all the possible ways in which we can get memory leaks in
I get an Access is Denied error message when I use the strong name
I get this message. The thing is, I want to be able to tell
I am trying to clean up my code from memory leaks and I am
here is my code , i am trying to get from one view to
i am using this widget to get my users to create accounts: <iframe src=http://www.facebook.com/plugins/registration.php?
I'm currently playing with linked lists, and I've put together the following code for
i usually dont check the retain count untill the program leaks. But today (i
I'm working on a system that needs to get a country code based 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.