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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T21:20:00+00:00 2026-05-24T21:20:00+00:00

I’m having unseen object leak (CFRuntimeCreateInstance) when profiling my app with instrument leak tool.

  • 0

I’m having unseen object leak (CFRuntimeCreateInstance) when profiling my app with instrument leak tool. I have rough imagination where the leak occurs but unable to spot it 🙂 The call tree points me to my class method for loading an image from a spritesheet. Here is a fragment of the call tree (until leaking object CFRuntimeCreateInstance):

+[ImageCache loadImageOfType:andIndex:]
 +[NSString stringWithFormat:]
  _CFStringCreateWithFormatAndArgumentsAux
   CFStringCreateCopy
    __CFStringCreateImmutableFunnel3
     _CFRuntimeCreateInstance

I’m using this helper class method for loading and caching the image. The method uses static NSMutableDictionary where it pushes loaded image for further use. My images are grouped into spritesheets, so the method reads corresponding image file and reads corresponding image area. Here is my method:

+(UIImage*)loadImageOfType:(int)type andIndex:(int)index{
  UIImage *image;

  if (!dict) dict = [[NSMutableDictionary dictionary] retain];

  //First, trying to get already loaded image
  int ind = IMAGECOUNT * type + index; //calculating the index that is used for storing image in dict
  image = [dict objectForKey:[NSString stringWithFormat:@"%d", ind]]; //trying to get image
  if (!image){ //if image is not loaded then read the spriteimage file 
    NSString *spritesheetName = [NSString stringWithFormat:@"itemsprite%d.png", type];
    NSString* imagePath = [[NSBundle mainBundle] pathForResource:spritesheetName ofType:nil];
    image = [UIImage imageWithContentsOfFile:imagePath];
    if (image) //if spritesheet exists
    {
        int loopInd; 
        CGFloat x = 0, y = 0;
        //load all images from it
        for (int i=0; i<IMAGECOUNT; i++) {
            UIImage *img;
            loopInd = IMAGECOUNT * type + i;
            CGImageRef imageRef = CGImageCreateWithImageInRect( [image CGImage], CGRectMake(x, y, ITEMIMAGESIZE, ITEMIMAGESIZE)); 
            img = [UIImage imageWithCGImage:imageRef];
            [dict setObject:img forKey:[NSString stringWithFormat:@"%d", loopInd]];
            CGImageRelease(imageRef);
            x += ITEMIMAGESIZE;
        }
    }
    //set image var to be image needed
    image = [dict objectForKey:[NSString stringWithFormat:@"%d", ind]];
  }    

  return image;   
}

Any suggestions, where to start?

UPDATE: I’m also having a lot of messages in debug area, all are quite similar:

__NSAutoreleaseNoPool(): Object 0x4c55e80 of class NSCFNumber autoreleased with no pool in place - just leaking

__NSAutoreleaseNoPool(): Object 0x4c69060 of class __NSCFDictionary autoreleased with no pool in place - just leaking

__NSAutoreleaseNoPool(): Object 0x4c6a620 of class NSCFString autoreleased with no pool in place - just leaking

__NSAutoreleaseNoPool(): Object 0x4e75fe0 of class NSPathStore2 autoreleased with no pool in place - just leaking

__NSAutoreleaseNoPool(): Object 0x4e312d0 of class UIImage autoreleased with no pool in place - just leaking
  • 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-24T21:20:01+00:00Added an answer on May 24, 2026 at 9:20 pm

    I found the problem. At the beginning of the game, I’m preloading the images. I have a method “loadGameResourses” that loops and does multiple calls to single image loading method “loadImageOfType…”. Now, I’m performing the call of “”loadGameResourses” in separate thread:

    [self performSelectorInBackground:@selector(loadGameResourses) withObject:nil]; 
    

    The leaks just disappeared when I replaced that with:

    [self loadGameResourses];
    

    I heard that you need to deal with UIKit stuff in the main thread, so it looks like I have picked the wrong method. Everything works as expected when using this appropriate method:

    [self performSelectorOnMainThread: @selector(loadGameResourses) withObject:nil waitUntilDone: NO]; 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a French site that I want to parse, but am running into
We're building an app, our first using Rails 3, and we're having to build
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

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.