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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T09:30:34+00:00 2026-05-30T09:30:34+00:00

I took apple’s sample code tweeting and modified it so that it doesn’t use

  • 0

I took apple’s sample code “tweeting” and modified it so that it doesn’t use ARC (download my project here to test the problem yourself). Actually only one “autorelease” statement was needed:

// Set up the built-in twitter composition view controller.
tweetViewController = [[[TWTweetComposeViewController alloc] init]autorelease];

// Set the initial tweet text. See the framework for additional properties that can be set.
[tweetViewController setInitialText:@"Hello. This is a tweet."];

// Create the completion handler block.
[tweetViewController setCompletionHandler:^(TWTweetComposeViewControllerResult result) {
    NSString *output;

    switch (result) {
        case TWTweetComposeViewControllerResultCancelled:
            // The cancel button was tapped.
            output = @"Tweet cancelled.";
            break;
        case TWTweetComposeViewControllerResultDone:
            // The tweet was sent.
            output = @"Tweet done.";
            break;
        default:
            break;
    }

    //[self performSelectorOnMainThread:@selector(displayText:) withObject:output waitUntilDone:NO];

    // Dismiss the tweet composition view controller.
    [self dismissModalViewControllerAnimated:NO];


}];

// Present the tweet composition view controller modally.
[self presentModalViewController:tweetViewController animated:YES];

If you send the tweet or click cancel in “tweetViewController” you would expect that the tweetViewController is deallocated. Instead the object remains in memory including the attached image (if you have attached one in the tweet) . So, if the user tries to make another tweet the app’s memory grows bigger because tweetViewController leaked.

As you notice, tweetViewController isn’t mentioned inside the block so it isn’t automatically retained..

I used instruments and proved 1 that “[[TWTweetComposeViewController alloc] init]” causes a memory leak.

Another thing I tried in order to prove it, was to ” NSLog(“%@”,tweetViewController); ” a few runcycles after the controller has been dismissed. Normally the program should have crashed because tweetViewController would not be pointing to a TWTweetComposeViewController instance. Instead it printed correctly the previous instance, proving the memory leak.

The only way I have found in order to avoid this is by violating the memory management rules and is the following:

[tweetViewController setCompletionHandler:^(TWTweetComposeViewControllerResult result) {

    // Dismiss the tweet composition view controller using animated YES!!
    [self dismissModalViewControllerAnimated:YES];
    [tweetViewController release];

}];

If you dismiss it without animation, a memory leak occurs… Have you noticed the problem? Am I doing something wrong? Try it yourself and comment please…
instruments showing the "leak"

  • 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-30T09:30:36+00:00Added an answer on May 30, 2026 at 9:30 am

    Turns out it’s a known bug and it’s currently under investigation by apple! I hope it gets fixed in iOS 5.1

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

Sidebar

Related Questions

I took some code here: Check if role consists of particular user in DB?
I recently took all my code a manually imported it into an eclipse project
I took over a Visual C++ project in Visual Studio 2005 from a colleague.
It took me a while, and some help from Apple (one instruction I missed),
In couple of recent projects that I took part in I was almost addicted
Im building an app that will use a Core Data model. I pretty new
I'd like to merge all the changes that took place between rev 10 &
Hey, I have to parse XML in my iOS app. I took Apple's SeismicXML
I'm currently working on this project that implies some DSP skills. I must extract
Anyone manage to write code that uses the mysqlclient library? I can get compiling

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.