Re: Some Questions...
Re: Some Questions...
- Subject: Re: Some Questions...
- From: Jerry LeVan <email@hidden>
- Date: Sun, 20 Jun 2004 13:39:00 -0400
Hi,
I thought about something like that but the situation is
well, "situational".
I have some small directories ( 30 entries ) but the expanded
images take up to 30MB ( peaks at about 1 GIG VM) and dirctories
with about 100 images of 10MB (again peaking at 1 GIG VM).
I am still in exploratory/feature addition mode. I think I will
go back at do something like you suggest after I figure out what
I am doing :)
All that I am "displaying" in the loop is the number of files
left to process in my progress dialog.
Don't think that is too much overhead...
Nobody has offered any advice on full screen image display :)
Thanks,
Jerry
On Jun 20, 2004, at 1:20 PM, j o a r wrote:
On 2004-06-20, at 18.55, Jerry LeVan wrote:
for(i=0 ; i< fcnt ; i++) {
// NSImage * tmp= [[NSImage
alloc]initWithContentsOfFile:(NSString*)[fileNameList
objectAtIndex:i]];
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSImage * tmp = [self altMakeThumb:[fileNameList
objectAtIndex:i]];
[[thumbArray cellAtRow:i column:0] setImage: tmp];
[[thumbArray cellAtRow:i column:0] setTarget:self];
[[thumbArray cellAtRow:i column:0] setAction:@selector(showMe:)];
[tmp release];
[filesLeft setIntValue: fileCtr--];
[filesLeft displayIfNeeded];
[pool release];
}
I would have done something like this:
================================================
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
int i;
for (i = 0; i < someThing; i++)
{
// Do stuff
if ((i % 500) == 499)
{
[pool release];
pool = [[NSAutoreleasePool alloc] init];
}
}
[pool release];
================================================
To avoid having to empty the pool in each iteration through the loop.
In the code above (if I didn't make any mistakes - it's hacked
together in Mail) the pool is emptied every 500th iteration through
the loop. Change that number to fit your application!
Do something similar for your call to "display" - you should probably
not force a display at every iteration through the loop. If you're
doing something that's going to take so long time that you think that
you need to force display updates, you should probably spin off this
operation to a separate thread, and funnel up the results to the main
thread every so often to show progress - while still allowing the main
thread to be responsive at all times.
j o a r
_______________________________________________
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.