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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T01:05:32+00:00 2026-05-14T01:05:32+00:00

Using Instruments, I keep on getting pointed to a memory leak with a UIImage.

  • 0

Using Instruments, I keep on getting pointed to a memory leak with a UIImage.
I think I’m assigning and releasing the memory correctly. The leaked object in instruments is described as NSConcreteData

Is the following the correct way to assign and release a UIImage?

UIImage* flagimg = [UIImage imageWithData: [NSData dataWithContentsOfURL:url2]];    
[flagimg release];
flagimg =nil;
  • 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-14T01:05:32+00:00Added an answer on May 14, 2026 at 1:05 am

    [UIImage imageWithData:] returns an autoreleased object, which should not be released by you again. So this code snipped contains not a memory leak but the opposite, a double free (in the worst case).

    Note that Instruments sometimes generates false positives and/or reports memory leaks in the Foundation itself (yep, they make mistakes too :-).

    The fastest way to alloc/release an object is to avoid convenience initializers (like imageWithData:) and instead to something like

    NSData* data = [[NSData alloc] initWithContentsOfURL:url]];
    UIImage* img = [[UIImage alloc] initWithData:data];
    [data release];
    // use your image
    [img release];

    This will allocate and release your object right away and not wait until the autorelease pool is cleaned.

    But please note too, that a memory leak is generally not memory that is not yet freed, but that is lost and cannot be freed anymore, so an object which will be deallocated by the autorelease pool is not considered a memory leak.

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

Sidebar

Ask A Question

Stats

  • Questions 512k
  • Answers 512k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Consider using MSMQ (System.Messaging) for this task. Perhaps a flow… May 16, 2026 at 5:36 pm
  • Editorial Team
    Editorial Team added an answer I'm trying to create a filter, for some reason I… May 16, 2026 at 5:36 pm
  • Editorial Team
    Editorial Team added an answer I think what you want can be achieved by prototyping… May 16, 2026 at 5:36 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

Using Instruments on the device it detects a 3.50 KB memory leak using Apple's
I am working on a 2D iPhone game using OpenGL ES and I keep
I am trying to track down a memory leak in my cocos2D game. I
After many years of working on a general-purpose C++ library using the Microsoft MSVC
Our .NET application controls measurement instruments. The application is installed and many different windows
I build a parsing algorithm using NSXMLParser. Im having doubt as to what is
Something is puzzling me, after going through my app with instruments, it is a
I'm using Logging ( import logging ) to log messages. Within 1 single module,
I have an app that currently holds all state in memory. It fetches a
The Spring configuration I am using contains the definition of a persistenceUnitPostProcessor within my

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.