• 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: EXC_BAD_ACCESS when -fobjc-gc is on (Was: Memory corruption ...)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: EXC_BAD_ACCESS when -fobjc-gc is on (Was: Memory corruption ...)


  • Subject: Re: EXC_BAD_ACCESS when -fobjc-gc is on (Was: Memory corruption ...)
  • From: Gabriel Zachmann <email@hidden>
  • Date: Thu, 8 Oct 2009 00:22:45 +0200

Well, I did some more experimenting. Now I've got 2 issues ...

First of all, I guess I should apologize, because my minimal example was not quite "minimal".

There was one other layer, which I have removed now. Now the code sort of works in the GC world, *except* the memory footprint keeps growing.

No matter where I put CFMakeCollectable(), or whether I use it at all.
Even with CGImageRelease() or CFRelease(), the leak persists.

This is one of the many variations I have tried:

CGImageRef cgImage = CGImageSourceCreateImageAtIndex( sourceRef, 0, NULL );
// [snip]
imgLayer.contents = (id) cgImage;
// [snip]
CFMakeCollectable( cgImage );
if ( [NSGarbageCollector defaultCollector] == NULL )
CGImageRelease( cgImage );
return imgLayer;


I can't think of any variation I have not tried.

In all cases, the app doesn't seem to crash any more, but it leaks.

The fact that it doesn't crash any more might be, of course, due to a different pattern of the underlying memory management.


At least, when I add the second layer, I get a crash immediately. The second layer is basically this:

TextLayerDelegate * textlayer_delegate = [[[TextLayerDelegate alloc] init] retain];
textLayer_ = [[CALayer layer] retain];
textLayer_.bounds = NSRectToCGRect( [self bounds] ); // mainLayer_.bounds;
textLayer_.delegate = textlayer_delegate; // TODO: direkt machen
[mainLayer_ addSublayer: textLayer_ ];
[textLayer_ setNeedsDisplay];


where TextLayerDelegate just exists for the drawLayer:inContext: method:

@interface TextLayerDelegate : NSObject { }
- (void) drawLayer: (CALayer *) theLayer inContext: (CGContextRef) theContext;
@end


@implementation TextLayerDelegate
- (void) drawLayer: (CALayer *) theLayer inContext: (CGContextRef) theContext
{
CGContextSetRGBStrokeColor( theContext, 0.0, 1.0, 1.0, 1.0 );
CGMutablePathRef thePath = CGPathCreateMutable();
// ...
CGContextStrokePath(theContext);
CFRelease(thePath);
}




I'm afraid I am still lost.


Best regards, Gabriel.

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:

This email sent to email@hidden

  • Prev by Date: Re: Autorelease pool
  • Next by Date: Re: EXC_BAD_ACCESS when -fobjc-gc is on (Was: Memory corruption ...)
  • Previous by thread: Re: EXC_BAD_ACCESS when -fobjc-gc is on (Was: Memory corruption ...)
  • Next by thread: Alert prompts for BetterAuthorizationService
  • Index(es):
    • Date
    • Thread