Skip navigation.
 
mlRe: saving big image crashes
FROM : John C. Randolph
DATE : Wed Nov 24 13:13:41 2004

It sounds like you're running into the limitations of NSBitmapImageRep.
  You should file a bug on this, since we shouldn't crash just because
an image is very large.

For an image this big, you'll need to do your own memory management for
the image data.  What I would do in this situation, is use an
NSCustomImageRep, which will ask its delegate to draw portions of the
image.  Your custom image rep's delegate should handle the mapping of
your raw data to its visual representation.

-jcr

On Nov 23, 2004, at 9:30 PM, ±è°æ¿Á wrote:


> Hi,
>
> I'm implementing a cocoa application in Obj-C for editing images.
> Users can resize image in pixels using the application.
>
> When I resize 450 x 300(pixels) image to 9000 x 9000 and save it with
> new size,
> the new image is saved but the application crashes during reopening
> the resized image with a message as follows:
> ----------------------------------------------------------
> *** malloc:vm_allocate(size=24307324) fail (error code=3)
> *** malloc[874]: error:Can't allocate region
> Executable "application" has exited due to signal 10 (SIGBUS).
> ----------------------------------------------------------
> The point the application crashes is the line as follows:
> aImage = [[NSImage alloc] initWithData:[newImage TIFFRepresentation]];
>
>
> And when I resize the same image to 10000 x 10000 and save it with new
> size,
> the application crashes during the new image is saved.
>
> The program is abnoramlly exited at the line of code without any error
> code as follows:
> TiffRef = [[NSBitmapImageRep alloc] initWithData:[temp_image
> TIFFRepresentation]];
>
> the temp_image is resized image.
>
> How can I solve momory problem with big images?
> Any help is greatly appreciated.
>
>




John C. Randolph <<email_removed>> (408) 974-8819
Sr. Cocoa Software Engineer,
Apple Worldwide Developer Relations
http://developer.apple.com/cocoa/index.html

Related mailsAuthorDate
mlsaving big image crashes ±è°æ¿Á Nov 24, 06:30
mlRe: saving big image crashes Louis C. Sacha Nov 24, 09:41
mlRe: saving big image crashes Marcel Weiher Nov 24, 12:01
mlRe: saving big image crashes John C. Randolph Nov 24, 13:13