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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T15:33:13+00:00 2026-06-17T15:33:13+00:00

ARC seems very nice but there are one or two edge cases that the

  • 0

ARC seems very nice but there are one or two edge cases that the typical naming conventions/rules don’t make clear to me. Look at the following category implementation around NSThread:

@interface NSThread (BlockAdditions)
- (void)performBlock:(dispatch_block_t)block;
@end

@implementation NSThread (BlockAdditions)
- (void)internal_performBlock:(dispatch_block_t)block
{
    block();
}

- (void)performBlock:(dispatch_block_t)block
{
    [self performSelector:@selector(internal_performBlock:)
                 onThread:self
               withObject:[block copy]
            waitUntilDone:NO];
}

My question is: does block leak after calling -copy? How would the compiler know when to release the block? Instruments does not detect a leak but that does not convince me, given what I know about ARC, that this case is handled correctly. Thanks for any info!

  • 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-06-17T15:33:15+00:00Added an answer on June 17, 2026 at 3:33 pm

    That would leak in retain/release, but should not leak in ARC.

    The compiler sees the -copy and that implies that a -release is needed. If you look at the generated assembly, that should be exactly what you see.

    (well, exactly what you see once you wade through the assembly, which isn’t exactly straightforward.)

    Note that you can simplify the assembly by just compiling the [block copy];.

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

Sidebar

Related Questions

I am using ARC but reading the MRR part of Objective-C, and it seems
It seems that there is a standard convention that in Objective-C, if a method
I know that this question had been asked many times, but every answer seems
There is a gap in my understanding of blocks and ARC that I would
Since converting my project to ARC, it seems the analyzer is a bit in
The only method in a StreamGeometryContext that seems related to ellipses is the ArcTo
I'm using ARC and targeting iOS 5. I've declared an NSMutableArray ivar in one
It seems that my app is abandoning memory since the persistent memory of recorded
Under ARC , I have an object, Child that has a weak property, parent
So I just found out that ARC is only supported for devices running iOS

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.