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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:41:24+00:00 2026-05-26T02:41:24+00:00

I have taken to the following code which will call CFRelease after a delay.

  • 0

I have taken to the following code which will call CFRelease after a delay. I have included it in a method for context.

CGPathRef NewPathWithRoundRect(CGRect rect, CGFloat cornerRadius)
{
     // other work to create ref which is a CGPath
     dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.5 * NSEC_PER_SEC), dispatch_get_current_queue(), ^{
        CFRelease(ref);
    });
}

In the latest version of Xcode I get a warning about not releasing memory properly. The caller takes the value, uses it and then calls CFRelease. I now CFRetain it and also CFRelease it so in order to get the reference count down to zero I am setting this dispatch to run and clean up the reference.

I am not comfortable with this approach. Is there is a better pattern for returning CF objects that were created in the method and need to be returned? Should I create the path outside the method and pass it in as a parameter so it is created and released by the caller?

I have also changed my code to call CGPathRelease which is a little safer. Any suggestions are appreciated.

  • 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-26T02:41:25+00:00Added an answer on May 26, 2026 at 2:41 am

    The CoreFoundation policy is that if a function has the word “Create” in it, then the function returns an owning (or retained) object, which the caller is responsible for releasing. So your NewPathWithRoundRect method should be named CreatePathWithRoundRect, and then just drop the delayed CFRelease. The caller will be responsible for releasing it when they’re done with it.

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

Sidebar

Related Questions

I am using **<style>..{data inside}..</style>** which is there in following code.i have taken all
I have the following piece of code taken from the PHP manual on the
This may well have come up before but the following code is taken from
Okay so i have a semi weridish problem with re.sub. Take the following code:
I have the following code to take an image and generate the thumbnail. how
I have the following code to take screenshots of a window: HDC WinDC; HDC
I have the following code to take a screenshot of a window, and get
I have the following code print Starting stage 1<br> # Something that takes about
I have a for-loop which performs the following function: Take a M by 8
I have the following jquery code: $(document).ready(function() { $(#build_table, a.coursename, .Start Date, .Book Title,

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.