Hi all,

I'm working with a program utilizing Core Text, but occurred to some strange
problems. When trying to reformat a document
larger than 1MB, the program crashes with the following error msg:
malloc: *** mmap(size=4,294,598,656) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug

Code is attached below. To me, it doesn't seem to have any problems. The app
crashes at the line creating the CTFrameRef, and
what's even stranger is, it crashes at around 1/3 of the file, so not
necessarily to be an out-of-memory problem. - It says CTFrameRef is
allocating 4GB of memory, which runs beyond the 32-bit boundary.

PS: The app runs without any problems on Snow Leopard, so could possibly be
a bug with Leopard?

   //
   // text is some Attribute String previously created
   //
    CTFramesetterRef framesetter =
CTFramesetterCreateWithAttributedString((CFAttributedStringRef) text);
    frameRange = CFRangeMake(0, 0);
    for (range = CFRangeMake(0, 0); range.location < text.length;
range.location += frameRange.length)
    {

        CGMutablePathRef path = CGPathCreateMutable();
        CGPathAddRect(path, NULL, frameRect);

        CTFrameRef frame = CTFramesetterCreateFrame(framesetter, range,
path, NULL);

        frameRange = CTFrameGetVisibleStringRange(frame);

        CFArrayRef lines = CTFrameGetLines(frame);

        CFIndex i, total = CFArrayGetCount(lines);
        CGFloat y = frameRect.origin.y;

        frameRect.origin.y = y;
        frameRect.size.height = contentSize.height;

        CFRelease(path);
        CFRelease(frame);
    }
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to