• 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: Mixing Cpp and ObjC - Memory Leak in ARC
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Mixing Cpp and ObjC - Memory Leak in ARC


  • Subject: Re: Mixing Cpp and ObjC - Memory Leak in ARC
  • From: Hado Hein Applelists <email@hidden>
  • Date: Sun, 27 Nov 2016 23:03:41 +0100

No. I tried some autoreleasepools and it is still leaking.
Whatever I do the allocation of the NSColor in the callback leaks. When it’s commented out the application runs fine.


> On 27.11.2016, at 19:13, Jean-Daniel <email@hidden> wrote:
>
>
>> Le 27 nov. 2016 à 19:12, Jean-Daniel <email@hidden> a écrit :
>>
>> Just a though, but have you tried to enclose your obj-c code into an @autorelease block ?
>>
>> AFAIK, the BlackMagic SDK don’t create autorelease pool for you.
>>
>>> Le 27 nov. 2016 à 17:40, Hado Hein Applelists <email@hidden> a écrit :
>>>
>>>
>>> Hoi,
>>> I have to use a SDK that is written in cpp.
>>>
>>> Since I have to include the .hpp header of the SDK I also had to switch my AppDelegate.m to .mm
>>> I’m using ARC.
>>>
>>>
>>> Now I have another cpp source file that makes use of this SDK. It defines a cpp class which also works.
>>> In some callback of the class I need to call out to my AppDelegate.
>>>
>>>
>>>> HRESULT DeckLinkCaptureDelegate::VideoInputFrameArrived(IDeckLinkVideoInputFrame* videoFrame, IDeckLinkAudioInputPacket* audioFrame)
>>>
>>>
>>> But this eats memory. First I did it in a direct call on my
>>>> [iter setAvgColor:[NSColor colorWithRed:r green:g blue:b alpha:1]].
>>> This produced a ~1MB per second memory leak.
>>>
>>> Then I went to:
>>>>                      dispatch_async(dispatch_get_main_queue(), ^{
>>>>                            [iter performSelectorOnMainThread:@selector(setAvgColor:) withObject:[NSColor colorWithRed:r green:g blue:b alpha:1] waitUntilDone:YES];
>>>>                      });
>>>
>>> Which brought down the leak to <100kB/sec. But it’s still there.
>>>
>>> Then I tried not to allocate a Foundation Object in the cpp code and tried:
>>>
>>>>                      [iter setAvgColorWithR:r G:g B:b];
>>> and allocating the NSColor in the source of my iter-objc-class.
>>>
>>> This didn’t work either.
>>>
>>>
>>>
>>>
>>> Now I’m wondering what I’m doing wrong.
>>>
>>> The class cpp does not contain any obj-c code or objects. It just includes the AppDelegate.h for calling out.
>>>
>>> Unfortunately, when I turn on Malloc Debug Functions in Xcode the thing does not compile anymore. So I’m a bit lost on how to find the exakt position of the leak and on how to implement this correctly. I assume that this might have to do something with using a Foundation constructor In cpp code which doesn’t arc correctly.
>>>
>>>
>>> Thx, Hado
>>> _______________________________________________
>>> Do not post admin requests to the list. They will be ignored.
>>> Xcode-users mailing list      (email@hidden)
>>> Help/Unsubscribe/Update your Subscription:
>>>
>>> This email sent to email@hidden
>>
>
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Xcode-users mailing list      (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • Re: Mixing Cpp and ObjC - Memory Leak in ARC
      • From: Quincey Morris <email@hidden>
References: 
 >Mixing Cpp and ObjC - Memory Leak in ARC (From: Hado Hein Applelists <email@hidden>)
 >Re: Mixing Cpp and ObjC - Memory Leak in ARC (From: Jean-Daniel <email@hidden>)

  • Prev by Date: Re: Mixing Cpp and ObjC - Memory Leak in ARC
  • Next by Date: Re: Mixing Cpp and ObjC - Memory Leak in ARC
  • Previous by thread: Re: Mixing Cpp and ObjC - Memory Leak in ARC
  • Next by thread: Re: Mixing Cpp and ObjC - Memory Leak in ARC
  • Index(es):
    • Date
    • Thread