Re: NSImage, corrupt images and address faults
Re: NSImage, corrupt images and address faults
- Subject: Re: NSImage, corrupt images and address faults
- From: Dan Grassi <email@hidden>
- Date: Fri, 12 Dec 2003 15:25:58 -0500
I'm looking for a work around, I have submitted a bug to Apple.
Exception: EXC_BAD_ACCESS (0x0001)
Codes: KERN_INVALID_ADDRESS (0x0001) at 0x1a4c5833
Thread 0 Crashed:
#0 0x92e65920 in _NXFreeImageCache (_NXFreeImageCache + 148)
#1 0x92e658e4 in _NXFreeImageCache (_NXFreeImageCache + 88)
#2 0x92e2fbb0 in -[NSCachedImageRep dealloc] (-[NSCachedImageRep
dealloc] + 388)
#3 0x92e1311c in -[NSImage _freeRepresentation:] (-[NSImage
_freeRepresentation:] + 324)
#4 0x92e27844 in -[NSImage dealloc] (-[NSImage dealloc] + 108)
#5 0x909f1c24 in NSPopAutoreleasePool (NSPopAutoreleasePool + 356)
Perhaps the problem is with NSAutoreleasePool.
The base problem I am trying to solve is that I am displaying a series
of images. This is in a modalSession so that the GUI will update and
buttons will work. But since NSImage autoreleases the memory and the
run loop is never entered the memory is never released and finally all
available disk space is consumed by virtual memory. Thus I added an
NSAutoreleasePool. around the NSImage code in the loop.
BTW, this only happens with certain corrupt images, always the same
images.
My code looks like:
for(int i=0; i<imgeCount; i++)
{
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
NSString* fileName = getNewFilename();
[imageView setImage: nil];
mImage = [mImage initWithContentsOfFile:fileName];
if (mImage)
{
if ([mImage isValid])
{
[imageView setImage: mImage];
[mImage display];
}
else
NSLog(@"Image invalid for file: %@\n", fileName);
[mImage release];
sleep(seconds); // Actually work is done here.
[pool release];
}
Dan
_______________________________________________
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.