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

The Archive Base Latest Questions

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

I still have some unclear understand about release and autorelease. What are the difference

  • 0

I still have some unclear understand about release and autorelease. What are the difference between both of them? I have this code. For facebook connection. I crash it sometimes when I go to Facebook login, I doubting maybe it is because I don’t release the object nicely.? Thanks for any helps

if (_session.isConnected) {
        [_session logout];
    } else {
        FBLoginDialog* dialog = [[[FBLoginDialog alloc] initWithSession:_session] autorelease];
        [dialog show];
    }
  • 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-13T11:20:22+00:00Added an answer on May 13, 2026 at 11:20 am

    The Memory Management Programming Guide for Cocoa will soon be your best friend. In brief, object instances in Cocoa are memory managed using reference counting (unless, of course you’re using garbage collection on OS X). An object indicates that it wants to ‘retain’ an ownership interest in an other instance–keep it from being deallocated–by sending it a -retain message. An object indicates that it wants to release that interest by sending the other instance a -release message. If the number of objects that have ‘retained’ and ownership interest in an object drops to 0 (i.e. when the last of the owning instances sends a -release message), the instance with a 0 retain count is deallocated.

    It’s sometimes convenient to say “I want this instance to be released some time in the future“. That’s the purpose of -autorelease. Sending an -autorelease message adds the receiver to the current NSAutoreleasePool. When that pool is drained, it sends a -release message to all the instances in the pool. An NSAutoreleasePool is automatically created at the start of each iteration of each thread’s run loop and drained at the end of that iteration. Thus, you can do something like this in a method:

    - (id)myMethod {
      return [[[MyObject alloc] init] autorelease];
    }
    

    The caller of this method will get back an instance that they can -retain if they wish to keep it. If they don’t retain it, it will stick around at least until the enclosing autorelease pool is drained:

    - (void)someOtherMethod {
    ...
    
    id instance = [obj myMethod];
    ... // do more with instance, knowing that it won't be dealloc'd until after someOtherMethod returns
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've read some docs about the .NET Garbage Collector but i still have some
I have some old code (an old but still maintained VB6 application) that from
Ok I am still learning this... I have Googled and done some research but
After reading some tutorials I am still unclear on some points about memory management
I have looked at most threads here about Doubly linked lists but still unclear
I still have some problems with jQuery. If I have html like this: <form
I have been making some progress on this but still have some issues to
i now this is a silly question, but i still have some poor understanding
There might be similar questions but I still have some parts that I couldn't
im currently learning python (in the very begining), so I still have some doubts

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.