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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T04:53:53+00:00 2026-06-09T04:53:53+00:00

ARC is enabled and bufferReady is being triggered by a C++ library(non-ARC enabled), and

  • 0

ARC is enabled and bufferReady is being triggered by a C++ library(non-ARC enabled), and I’m sure I’m missing an ARC cast somewhere. Please advise. Thanks in advance.

With the code below:

@implementation HelloWorldLayer

id refToSelf;  //reference to self
int shakeCounter = 0;

void bufferReady() {
    if (shakeCounter % 100 == 0) {
        [refToSelf shakes];
    }

    shakeCounter++;
}

- (void) shakes {
    CCRotateBy * rotate = [CCRotateBy actionWithDuration:0.1 angle:2];
    CCActionInterval * rotateReverse = [rotate reverse];
    CCSequence * seq1 = [CCSequence actions:rotate, rotateReverse, nil];

    CCMoveBy * shake = [CCMoveBy actionWithDuration:0.1 position:ccp(5, 0)];
    CCActionInterval * shakeReverse = [shake reverse];
    CCSequence * seq2 = [CCSequence actions:shake, shakeReverse, nil];

    CCSpawn * spawner = [CCSpawn actions:seq1, seq2, nil];
    CCSequence * lastSequence = [CCSequence actions:spawner, spawner, spawner, spawner, nil];

    [self runAction:lastSequence];
}

- (id) init {
    if((self = [super init])) {
        ...
    }
    refToSelf = self;
    return self;
}

During runtime I’m receiving memory leaked warnings every time shakes is executed.

objc[10060]: Object 0x466830 of class CCRotateBy autoreleased with no pool in place - just leaking - break on objc_autoreleaseNoPool() to debug
objc[10060]: Object 0x44cb70 of class CCRotateBy autoreleased with no pool in place - just leaking - break on objc_autoreleaseNoPool() to debug
objc[10060]: Object 0x46b260 of class CCSequence autoreleased with no pool in place - just leaking - break on objc_autoreleaseNoPool() to debug
objc[10060]: Object 0x45a790 of class CCMoveBy autoreleased with no pool in place - just leaking - break on objc_autoreleaseNoPool() to debug
objc[10060]: Object 0x469150 of class CCMoveBy autoreleased with no pool in place - just leaking - break on objc_autoreleaseNoPool() to debug
objc[10060]: Object 0x469190 of class CCSequence autoreleased with no pool in place - just leaking - break on objc_autoreleaseNoPool() to debug
objc[10060]: Object 0x46b350 of class CCSpawn autoreleased with no pool in place - just leaking - break on objc_autoreleaseNoPool() to debug
objc[10060]: Object 0x46b380 of class CCSequence autoreleased with no pool in place - just leaking - break on objc_autoreleaseNoPool() to debug
objc[10060]: Object 0x46b3b0 of class CCSequence autoreleased with no pool in place - just leaking - break on objc_autoreleaseNoPool() to debug
objc[10060]: Object 0x46bc00 of class CCSequence autoreleased with no pool in place - just leaking - break on objc_autoreleaseNoPool() to debug
  • 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-09T04:53:54+00:00Added an answer on June 9, 2026 at 4:53 am

    You’re not missing an “ARC cast”.

    I guess your C++ creates a separate thread and calls bufferReady on that thread. Since it’s a C++ library, I presume it doesn’t know anything about Objective-C or Cocoa memory management, so it doesn’t create an autorelease pool. Therefore you should create an autorelease pool in bufferReady:

    void bufferReady() {
        if (shakeCounter % 100 == 0) {
            @autoreleasepool {
                [refToSelf shakes];
            }
        }
    
        shakeCounter++;
    }
    

    But also I see that in shakes, you’re creating Cocos2D objects and sending runAction: to yourself, presumably to run the action objects you created. Are you sure it’s safe to do this on a random thread? Maybe you should send yourself shakes on the main thread. Here’s an easy way to do that:

    void bufferReady() {
        if (shakeCounter % 100 == 0) {
            dispatch_async(dispatch_get_main_queue(), ^{
                [refToSelf shakes];
            });
        }
    
        shakeCounter++;
    }
    

    Since the main thread manages its own autorelease pool, you don’t have to set one up in this case.

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

Sidebar

Related Questions

I have the following code, which is causing a leak, despite ARC being enabled
I am using a non-ARC framework in my ARC-enabled app. Now I get a
While adding Electro Server library to my existing project (with ARC enabled), it gives
My project is ARC enabled (the build settings have Objective-C Reference Counting set to
I'm getting a strange exception in Xcode 4.2.1 (ARC-enabled project) that I can't track
I am using Xcode 4.3.2 to develop iPhone apps with ARC enabled. while navigating
I'm using the following code within XCode, building for iOS with ARC enabled. Why
I've enabled ARC, In my didFinishLaunchingWithOptions method, I wrote the following code: AppDelegate.h: @interface
Under ARC, is it possible to encode/decode a CGMutablePathRef (or its non-mutable form) using
In a ARC enabled project, is there a way to add the -fno-objc-arc tag

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.