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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T15:47:12+00:00 2026-05-29T15:47:12+00:00

if UIImage is an autorelease object, why when I analyze does it complain that

  • 0

if UIImage is an autorelease object, why when I analyze does it complain that on the 2nd line below there is a potential leak stored to image:

    NSData *data = [[NSData alloc] initWithContentsOfURL: ImageURL];
    UIImage *image = [[UIImage alloc] initWithData: data];

    [data release];
    // Do we want to round the corners?
    image = [self roundCorners: image];

    // Is it PNG or JPG/JPEG?
    // Running the image representation function writes the data from the image to a file
    if([ImageURLString rangeOfString: @".png" options: NSCaseInsensitiveSearch].location != NSNotFound)
    {
        [UIImagePNGRepresentation(image) writeToFile: uniquePath atomically: YES];
    }
    else if(
            [ImageURLString rangeOfString: @".jpg" options: NSCaseInsensitiveSearch].location != NSNotFound || 
            [ImageURLString rangeOfString: @".jpeg" options: NSCaseInsensitiveSearch].location != NSNotFound
            )
    {
        [UIImageJPEGRepresentation(image, 100) writeToFile: uniquePath atomically: YES];
    }
  • 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-29T15:47:14+00:00Added an answer on May 29, 2026 at 3:47 pm

    Why do you say your UIImage is autoreleased? I see only

    UIImage *image = [[UIImage alloc] initWithData: data];
    

    Use instead

    UIImage *image = [[[UIImage alloc] initWithData: data] autorelease];
    

    As an alternative you may use:

    UIImage *tmp = [[UIImage alloc] initWithData: data];
    
    UIImage *image = [self roundCorners: tmp];
    
    [tmp release];
    

    (assuming roundCorners returns an autoreleased object).

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

Sidebar

Related Questions

The result of Build and Analyze Showing me this line. Potential leak of an
imgBiteSpot.clipsToBounds=YES; NSData *imageData = [[[NSData alloc]init]autorelease]; imageData = [NSData dataWithContentsOfURL:[NSURL URLWithString:ObjBitSpot.StrImagePath]]; if(imageData==0) { imgBiteSpot.image=[UIImage
To create an UiImage with a image file, I use the code as below:
I have a UIImage containing an image with a whole bunch of smaller pictures
According to the UIImage documentation : In low-memory situations, image data may be purged
I wanted to easily blend a UIImage on top of another background image, so
When running the analyze in xcode 4.2 i have the warning Value stored to
Incorrect decrement of the reference count of an object that is not owned at
I have a UIImage that I'm instantiating using imageWithData: (the data is loaded from
I have a function that takes some bitmap data and returns a UIImage *

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.