• 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: Mon, 11 Jul 2005 00:11:14 -0500


On Jul 10, 2005, at 11:51 PM, Matt Ball wrote:

And it gets called plenty. I've got some mouse tracking set up in my tableview to deal with some button rollovers, and it redraws the cell every time the mouse moves. So every time I add a layer or move the mouse over the view, the log that I posted gets logged. (So by the time it crashes, I've got hundreds of that sequence of logs).


Well then, if there's really hundred's of objects added to the autorelease pool, and the pool doesn't get a chance to release itself, it will eventually crash. I just managed to do that in a project today, and got exactly a sigbus 11, so I wouldn't be surprised if that is indeed your problem. Question is then to find a chance to autorelease your pool, and I am not sure where the best place to do that would be in your setup, given that it's the main autorelease pool.


You might want to consider cacheing some of the images if possible. The methods dealing with table views are supposed to be extra-light because they get called often.
In fact I would suggest creating a whole bunch of these images all at once, and then do that within your own pool, which you can then release. Actually, you might not even need a pool in that case.


A solution which is ugly and wrong, but you might want to go with it if you find no other way, is to have
return shadowCanvas;
at the end of shadowedImageWithImage
and to add
[image release];
at the end of the tableView method, and to NOT use the retain- autorelease pattern in the image setter method. I.e. avoid autoreleases at all. This should fix your problem.
The reason this is wrong is that shadowedImageWithImage is expected to return an autoreleased object, i.e. if anyone ever uses/reads your code, that's what they would expect. So if you go this way, make sure to document the fact.


- Matt Ball

On 7/11/05, Charilaos Skiadas <email@hidden> wrote:


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>
    • 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: Matt Ball <email@hidden>)
 >Re: 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: 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>)

  • Prev by Date: Re: Simple C File IO Question (with code listing)
  • Next by Date: Newbie question on NSDecimals
  • Previous by thread: Re: Why does this leak memory?
  • Next by thread: Re: Why does this leak memory?
  • Index(es):
    • Date
    • Thread