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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:51:06+00:00 2026-05-28T04:51:06+00:00

In my app i have a loop that move on array of UIImage and

  • 0

In my app i have a loop that move on array of UIImage and make stuff with this images.
the loop work in the background Thread so in the start of the function i put :

NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

and in the end

[pool release];

In the loop i create UIImage so i need to release it because it give me a memory warning if i am not make a release.

When the app finish the loop and get to the

[pool release];

it give me BAD_ACCESS error and crash the app.

Edit


This is the methods in the loop

        UIImage *tmp = [image rotate:UIImageOrientationRight];
        //do some stuff with this image
        [tmp release];

This is the rotate method:

    UIImage*           copy = nil;
    CGRect             bnds = CGRectZero;
    UIImage*           copy = nil;
    CGContextRef       ctxt = nil;
    CGImageRef         imag = self.CGImage;
    CGRect             rect = CGRectZero;
    CGAffineTransform  tran = CGAffineTransformIdentity;

    rect.size.width  = CGImageGetWidth(imag);
    rect.size.height = CGImageGetHeight(imag);

    bnds = rect;

    UIGraphicsBeginImageContext(bnds.size);
    ctxt = UIGraphicsGetCurrentContext();

switch (orient)
{
    case UIImageOrientationLeft:
    case UIImageOrientationLeftMirrored:
    case UIImageOrientationRight:
    case UIImageOrientationRightMirrored:
        CGContextScaleCTM(ctxt, -1.0, 1.0);
        CGContextTranslateCTM(ctxt, -rect.size.height, 0.0);
        break;

    default:
        CGContextScaleCTM(ctxt, 1.0, -1.0);
        CGContextTranslateCTM(ctxt, 0.0, -rect.size.height);
        break;
}

CGContextConcatCTM(ctxt, tran);
CGContextDrawImage(UIGraphicsGetCurrentContext(), rect, imag);

copy = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

if (imag) {
    CFRelease(imag);
}

return copy;
  • 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-28T04:51:07+00:00Added an answer on May 28, 2026 at 4:51 am

    You’re over-releasing your image after rotating it.

        UIImage *tmp = [image rotate:UIImageOrientationRight];
        //do some stuff with this image
        [tmp release]; // Here
    

    UIGraphicsGetImageFromCurrentImageContext() returns an autoreleased object, so you don’t need to call release on it after you return it.

    The crash happens when releasing the NSAutoreleasePool because the last -release is not sent until it gets drained and sends the correct release call to your object that was previously and wrongly released by you.

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

Sidebar

Related Questions

I have written a C# app that runs constantly in a loop and several
I am aware that System.Threading.Timer exists, but I already have a Thread. This thread
I am working within a Ruby on Rails app. I have a loop that
Let's say I have an app that let's a Facebook user make a collage.
I want my app to loop in python but have a way to quit.
This is a continuation of the question here: JBoss - does app have to
While developing my app I have come to realize that the majority of my
I have an app that is making use of photos stored on either the
I have an app that cleans dirty filenames. Dirty filenames have #%&~+{} in their
I have an ai loop that I would like to write for my iphone

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.