[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Worth it for an object to caching its own IMPs?



On 2/03/2004, at 12:00 PM, Scott Stevenson wrote:

> It might also be that the autoreleased objects I'm getting back from 
> KVC could be piling up, but I'm not sure what to do about that. It 
> would be nice if there was some way I could use KVC without 
> autorelease. I already have manual retain/releases in effect almost 
> everywhere it makes sense. I guess I could try more autorelease pools 
> too, but I'm not sold on how big of a difference that makes in terms 
> of overall performance.

Autoreleased objects will normally be cleaned up for every iteration in 
the run loop.

So if you are calling a method repeatedly without returning control to 
the run loop, and that method generates a lot of big autoreleased 
objects, you might want to look into creating an autorelease pool for 
that method.

Again, profile the code before and after to see if it makes a 
noticeable difference. Adding or removing an autorelease pool is 
trivial, so a couple of minutes of work will give you results here. 
However, for something like this it might also make sense to try the 
profiling on a low end machine with little physical memory. The 
performance characteristics could be very different!

If you can't see much difference, I'd say keep it simple and leave the 
extra autorelease pools out.

Cheers,
Tobias Peciva
Pharos Systems