• 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: Image loading bug out of nowhere...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Image loading bug out of nowhere...


  • Subject: Re: Image loading bug out of nowhere...
  • From: Steve Christensen <email@hidden>
  • Date: Thu, 3 Nov 2005 06:40:20 -0800


On Nov 3, 2005, at 4:15 AM, Michael Becker wrote:

I have a very heavy bug in my application and don't even know where to start looking for it. It has to do with loading JPEG images. I read out the iPhoto library and load the thumbnail images. For testing purposes, I created about 300 copies of one 1,2 MB JPEG image and imported them into iPhoto.

Now when my program loads all those images, there's always a certain point where no images will be loaded anymore and nothing else works (e.g. clicking an "Open" Button in my application results in an error message "unable to load nib data: /System/Library/Frameworks/AppKit.framework/Resources/English.lproj/ NSNavPanelContentView.nib").

"newImage" in the code below will be an object of my own image storage class.
Here's basically how I load the images (I want to know the original image's size, however):


NSData *imageData = [[NSData alloc] initWithContentsOfFile:thumbnailPath];
NSBitmapImageRep *bitmapImageRep = nil;


            char buffer[3];
            [imageData getBytes:&buffer length:3];

if (([[[path pathExtension] lowercaseString] hasPrefix:@"jp"]) &&
(buffer[0] == -1) &&
(buffer[1] == -40) &&
(buffer[2] == -1))
{
bitmapImageRep = [[NSBitmapImageRep imageRepWithContentsOfFile:thumbnailPath] retain];


// Load the original fullsize image to find out its dimensions
NSData *fullsizeData = [[NSData alloc] initWithContentsOfFile:path];
NSBitmapImageRep *sizeRep = [[NSBitmapImageRep alloc] initWithData:fullsizeData];


// Set original image size in our new object
[newImage setImageSize:NSMakeSize([sizeRep pixelsWide], [sizeRep pixelsHigh])];
[sizeRep release];
[fullsizeData release];


            }

This works fine until I put in too many images of too big filesizes. Suddenly (in my above example at image no. 217) no images will be loaded and the buffer-array will hold values like (-94, -121, 106) or (-112, 114, -12). Sometimes even the application's main menu gets screwed up, displaying nothing but strange characters (its basically an "A" inside a square box).

This looks to me like some big memory desaster, but I have no idea where to start looking...

Do you check to see that the various allocations above actually succeed? At least in the code above, you're using objects that you hope have been created; if they weren't, you could be stomping on memory. Do you release imageData someplace? If not, you're leaking a thumbnail-sized block of memory each time...


steve

_______________________________________________
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


References: 
 >Image loading bug out of nowhere... (From: Michael Becker <email@hidden>)

  • Prev by Date: RE : An OutlineView with Finder Editing Behavior
  • Next by Date: Reviews of "Advanced Mac OS X Programming"
  • Previous by thread: Image loading bug out of nowhere...
  • Next by thread: Re: Image loading bug out of nowhere...
  • Index(es):
    • Date
    • Thread