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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T11:13:30+00:00 2026-05-28T11:13:30+00:00

I’m nearing the end of a school project with programming in Xcode, but right

  • 0

I’m nearing the end of a school project with programming in Xcode, but right now I’m having a small yet extremely annoying issue: a memory leak. The leak has been traced down to the following line of code:

@autoreleasepool {
    [NSThread detachNewThreadSelector:@selector(updateThread) toTarget:self withObject:nil];
}

When I comment this out, the leak is gone. Apparently something goes wrong in the autoreleasepool: I’m still a bit new on these (especially when using ARC), but threads like this one made it clear to me that using @autoreleasepool should be sufficient.

For some reason, this is not the case for my code. I guess I’m missing something here: if someone could give some ideas on what the issue could be, then that would be highly appreciated. Just tell me if I have to post more code, that won’t be a problem: it’s just for the readability of the question that I try to limit it to the main issue.

Thanks in advance!

EDIT:

Thank you for the first responses! The issue still persists however… I will post a bit more code to clear things up a bit. The thread is started in viewDidLoad:

/*
 Everything mentioned here will be done after loading.
 */
- (void)viewDidLoad
{
    // Do standard setup
    [super viewDidLoad];

    // Do any additional setup before loading the view from its nib.
    self.title = @"Blog Manager";

    // Activate edit mode
    [tbvBlogList setEditing:YES animated:YES];
    tbvBlogList.allowsSelectionDuringEditing = YES;

    [NSThread detachNewThreadSelector:@selector(updateThread) toTarget:self withObject:nil];

    UIImage *btnImage = [UIImage imageNamed:@"iPhone_General_Button_Add_Blog.png"];
    UIButton *viewBtnAddBlog = [UIButton buttonWithType:UIButtonTypeCustom];
    [viewBtnAddBlog setImage:btnImage forState:UIControlStateNormal];
    viewBtnAddBlog.frame = CGRectMake(0, 0, 80, 36);
    [viewBtnAddBlog addTarget:self action:@selector(addBlogByButton:) forControlEvents:UIControlEventTouchUpInside];

    UIBarButtonItem *btnAddBlog = [[UIBarButtonItem alloc] initWithCustomView:viewBtnAddBlog];
    btnAddBlog.tintColor = [UIColor clearColor];
    self.navigationItem.rightBarButtonItem = btnAddBlog;
}

Then, the other functions that are used for the threading:

/*
 Thread to update the progress bar with.
 */
- (void)updateThread
{
    @autoreleasepool {
        while(YES){
            [self performSelectorOnMainThread:@selector(updateProgressBar) withObject:nil waitUntilDone:false];
            [NSThread sleepForTimeInterval:0.1f];
        }
    }
}

/*
 Updates the progress bar.
 */
- (void)updateProgressBar
{
    pvProgress.progress = dProgress;
}

If it is anything worth mentioning: I’m using Xcode 4.2.1. Thanks again for the support!

  • 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-28T11:13:30+00:00Added an answer on May 28, 2026 at 11:13 am

    Right now I just want to hit myself with a rock.

    I just realized the “while”-loop never stops. Of course this means the thread will keep running, therefore the memory won’t ever be released until the app finishes.

    By simply adding a boolean that is set to “NO” when the thread should quit, the issue was solved. Everyone: thanks you very much for looking at this problem for me. Sometimes the biggest problems have the smallest solutions…

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
I want to count how many characters a certain string has in PHP, but
I used javascript for loading a picture on my website depending on which small
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build

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.