• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Why does this leak memory?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why does this leak memory?


  • Subject: Re: Why does this leak memory?
  • From: Charilaos Skiadas <email@hidden>
  • Date: Sun, 10 Jul 2005 20:55:57 -0500


On Jul 10, 2005, at 8:41 PM, Matt Ball wrote:

- (void)setImage:(NSImage *)anImage
{
if(anImage != image && anImage != nil)
{
// [image release]; <-- I get a crash if I uncomment this line
image = [anImage retain];
}
}



You should not comment lines simply because you get a crash if you uncomment them! If you get a crash, then there are problems with your code elsewhere. If you leave the setter method as it is right now, each time it is called it will leak the object that image points to.


By the way, where are you initializing image?

And as Rosyna just pointed out, there are way too many different things called image. Things will become more clear if you use different names where appropriate.

Also, go through your code with the debugger and tell us exactly where it crashes, when it does.

Haris


_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: Why does this leak memory?
      • From: Matt Ball <email@hidden>
References: 
 >Why does this leak memory? (From: Matt Ball <email@hidden>)
 >Re: Why does this leak memory? (From: Charilaos Skiadas <email@hidden>)
 >Re: Why does this leak memory? (From: Matt Ball <email@hidden>)
 >Re: Why does this leak memory? (From: Zach Wily <email@hidden>)
 >Re: Why does this leak memory? (From: Matt Ball <email@hidden>)

  • Prev by Date: Re: Why does this leak memory?
  • Next by Date: SOAP Handler question
  • Previous by thread: Re: Why does this leak memory?
  • Next by thread: Re: Why does this leak memory?
  • Index(es):
    • Date
    • Thread