• 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: Thousands of leaked CGContext ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Thousands of leaked CGContext ?


  • Subject: Re: Thousands of leaked CGContext ?
  • From: David Duncan <email@hidden>
  • Date: Fri, 17 Apr 2015 10:09:53 -0700

> On Apr 17, 2015, at 2:38 AM, Eric Matecki <email@hidden> wrote:
>
> Hi,
>
> (I know this is not 100% Cocoa, but it isn't 100% CoreGraphics either...)
>
> I'm drawing to an NSWindow with CoreGraphics, and each time there is a leaked CGContext, CGContextDelegate, CGColorTransform, NSBitmapGraphicsContext, and NSFocusStack (one of each).
>
>
> Here is how I do it :
>
>    CGDataProviderDirectCallbacks callbacks = {
>        0,
>        &MyProviderGetBytePointer,
>        &MyProviderReleaseBytePointer,
>        &MyProviderGetBytesAtPosition,
>        &MyProviderReleaseInfo
>    };
>
>    MyProviderStruct  mps = { mBlock, mDirtyRect.X(), mDirtyRect.Y() };
>
>    CGDataProviderRef  provider = CGDataProviderCreateDirect( &mps, sizeof(mps), &callbacks );
>
>    NSWindow*  window = (NSWindow*)Window();

What does this line do?

>    CGImageRef  image = CGImageCreate( size_t(mDirtyRect.W()), size_t(mDirtyRect.H()), 8, 32, size_t(mBlock->Width()*4),
>                                       [[window colorSpace] CGColorSpace], kCGBitmapByteOrder32Big | kCGImageAlphaNoneSkipFirst,
>                                       provider, NULL, false, kCGRenderingIntentRelativeColorimetric );
>
>    CGContextRef  myContext = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
>
>    CGContextDrawImage( myContext, CGRectMake( mDirtyRect.X(), geom.H() - mDirtyRect.Y() - mDirtyRect.H(),
>                                               mDirtyRect.W(), mDirtyRect.H() ), image );
>
>    CGContextFlush( myContext );
>    CGImageRelease( image );
>    CGDataProviderRelease( provider );
>
>
> I don't release the CGContextRef because I don't 'create' it.
> If I release it, the app doesn't crash but doesn't draw anything anymore after the first one.
>
> My data provider just copy bytes from a legacy data structure.
>
> What am I doing wrong ?
> Or maybe there is a better way of doing this ?
>
> Thanks for any help !
>
> --
> Keep intel OUTSIDE my Mac !
> Hiii !!! I can see Intel chips creeping around my G5 !
>
> Eric M.
> _______________________________________________
>
> 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

--
David Duncan


_______________________________________________

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


  • Follow-Ups:
    • Re: Thousands of leaked CGContext ?
      • From: Eric Matecki <email@hidden>
References: 
 >Thousands of leaked CGContext ? (From: Eric Matecki <email@hidden>)

  • Prev by Date: Re: Scattered NSProgress use
  • Next by Date: RE: NSStatusItem, Popover and NSTextField make responder
  • Previous by thread: Thousands of leaked CGContext ?
  • Next by thread: Re: Thousands of leaked CGContext ?
  • Index(es):
    • Date
    • Thread