Re: Autorelease pools?
Re: Autorelease pools?
- Subject: Re: Autorelease pools?
- From: Greg Hulands <email@hidden>
- Date: Fri, 19 Mar 2004 15:55:36 +1000
That was one of the reasons why I never filed an enhancement request
because of the inherent overhead. The work around was when I got the
NSBitmapImageRef I just calculated the size of the autorelease pool
based on the image size. If it went over 50MB then it would release the
current pool and create a new one.
On 19/03/2004, at 2:08 PM, Clark Cox wrote:
On Mar 18, 2004, at 22:48, Greg Hulands wrote:
Since we are on this topic I would just like to ask a question that
popped into my mind when I was creating a image indexing application.
Basically it opened any file you gave it and created a thumbnail on a
index (like what you get when you drop your photos off to get
printed). It used a tight loop with an autorelease pool, but so I
wasn't destroying the autorelease pool and recreating it every cycle
of the loop, I decided to do it every 5 cycles through. Because I was
working with images, I didn't really want to do it every n cycles
through the loop but rather if the autorelease pool was n MB in size
to destroy and recreate it. The reason for this is that sometimes I
index quite a few 200MB images and when it only releases every 5
times, that can be 1GB of memory or a lot of paging to disk for those
with less that 1GB.
It never really worried me so I never filed an enhancement request,
but it was just something I thought would be useful to the
autorelease pool- to query its size.
In order to query the size of the memory held by the objects in your
autorelease pool, you'd have to be able to query the size of any
object that could possibly be autoreleased (i.e. any object that
descended from NSObject), and the size of every object that it
referenced, etc.
For example, what if one of the objects that you had autoreleased was
an NSArray instance, well, the autorelease pool would have to ask the
array for it's size, which would in tern have to ask each of the
objects contained within for their size, and each of those objects
would have to ask any objects to which they held the only reference to
for their size and...
This could very quickly become much more expensive than the paging
that you were trying to avoid in the first place.
--
Clark S. Cox III
email@hidden
http://homepage.mac.com/clarkcox3/
http://homepage.mac.com/clarkcox3/blog/B1196589870/index.html
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.