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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T03:05:45+00:00 2026-06-09T03:05:45+00:00

I have a Cocoa app with ARC enabled. I am using OS 10.8 and

  • 0

I have a Cocoa app with ARC enabled. I am using OS 10.8 and Xcode 4.4. The app sporadically crashes upon calls to CGLayerRelease, dumping messages like the following to console:

error for object 0x10a2d2000: entry for pointer being freed from death-row vanished

If I comment out the calls to CGLayerRelease the crashing stops. Do I need to call CGLayerRelease in ARC enabled projects? The documentation isn’t very clear about this.

It is hard to post code for this because it is spread throughout a large file for a class that inherits from NSView. The class has a data member CGLayerRef layer;. Then inside the drawRect function:

    if (layer == nil) {
        layer = CGLayerCreateWithContext(context, self.frame.size, NULL);
        // draw some stuff into CGLayerGetContext(layer)
    }
    CGContextDrawLayerInRect(context, self.bounds, layer);

The class is also a delegate of its window and has the following function

- (void)windowDidEndLiveResize:(NSNotification *)notification {
    if (layer) {
        //CGLayerRelease(layer);
        layer = nil;
    }
    [self setNeedsDisplay:YES];
}

Also inside a property setter

- (void)setPitch:(NSArray *)aPitch {
    pitch = aPitch;
    if (layer) {
        //CGLayerRelease(layer);
        layer = nil;
    }
}

Now if I uncomment the calls to CGLayerRelease then I sporadically get the crash mentioned above. I stress “sporadically” because it does not always happen.

  • 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-09T03:05:47+00:00Added an answer on June 9, 2026 at 3:05 am

    Yes, you need to call CGLayerRelease() in ARC. The above assignments look correct, but I suspect you may have others. You’re directly accessing your ivars, which is the #1 cause of these kinds of crashes. Do not access your own ivars except in init and dealloc. Create an accessor for setLayer: that correctly releases the old one and creates a new one and always use that.

    It’s very possible that your CGLayer code is fine, and that it’s something else like a CGPath that you’re adding to the CGLayer. Move all your ivars to accessors. Otherwise you will be chasing these kinds of bugs forever.

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

Sidebar

Related Questions

I have never made an app using XCode and Cocoa but I think following
I have a Cocoa application (.app) and I would like to launch it from
I am using the KVO validations in my cocoa app. I have a method
Assume I have a Cocoa-based Mac or iOS app. I'd like to run a
I have a simple Cocoa app using a NSWindowController subclass. In the nib I
I have a Cocoa app that embeds a WebView. I'd like to intercept a
Environment: xcode 3.2.1, document-based core-data application. I have a document-based cocoa app which uses
I have a cocoa-touch app, using the core data framework. I've created a xcdatamodel
I have an Cocoa app that calls a web service. When I parse the
I have a Cocoa app for Mac OS X written in Xcode 4. The

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.