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.
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ 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