Re: Thousands of leaked CGContext ?
Re: Thousands of leaked CGContext ?
- Subject: Re: Thousands of leaked CGContext ?
- From: David Duncan <email@hidden>
- Date: Mon, 20 Apr 2015 09:37:57 -0700
> On Apr 20, 2015, at 12:05 AM, Eric Matecki <email@hidden> wrote:
>
> Hi,
>
>>> CGDataProviderRef provider = CGDataProviderCreateDirect( &mps, sizeof(mps), &callbacks );
>>>
>>> NSWindow* window = (NSWindow*)Window();
>>
>> What does this line do?
>
> It's just a global function which returns the (only) window.
> For crossplatform compatibility reasons (our app runs on MacOSX, Linux, Windows and Android) it returns a void*,
> that's why the cast is needed.
Sure, but of all the code you’ve presented, nothing seems to indicate a leak, except for the single call to Window(). My hope would be that it isn’t doing something with side effects that ultimately causes this.
>
> This one :
> >> 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 );
> >>
>
> It creates a CGImage which will use the CGDataProvider for a source of the pixels.
>
> The size is the same as the 'dirty' rect to refresh, 8 bits/component, 32 bits/pixel, w*4 bytes/row,
> the windows colorspace, the pixel 'description' (integer, no useful data in alpha channel),
> my data provider, NULL(decode array), no interpolation (it's anyway a 1to1 mapping of the pixels), rendering intent.
>
> The data provider just copies the pixels or returns a pointer to the correct byte :
>
> struct MyProviderStruct
> {
> ::nImage8::cRGBABlock* mBlock;
> int mX, mY;
> };
>
> static const void*
> MyProviderGetBytePointer( void* iInfo )
> {
> MyProviderStruct* mps = (MyProviderStruct*) iInfo;
> return mps->mBlock->Pixels( mps->mX, mps->mY ); // this returns a pointer to that pixel
> }
>
> static void MyProviderReleaseBytePointer( void* iInfo, const void* iPointer ) {}
>
> static size_t
> MyProviderGetBytesAtPosition( void* iInfo, void* oBuffer, off_t iPosition, size_t iCount )
> {
> MyProviderStruct* mps = (MyProviderStruct*) iInfo;
> ::nMemoryUtils::Copy( oBuffer, (uint8*)(mps->mBlock->Pixels()) + iPosition, uint32(iCount) );
> return iCount;
> }
>
> static void MyProviderReleaseInfo( void* iInfo ) {}
>
>
>
> Except for the leaked memory, it works as expected.
>
> Thanks
>
> --
> 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