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

Mixing Cpp and ObjC - Memory Leak in ARC


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

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


  • Follow-Ups:
    • Re: Mixing Cpp and ObjC - Memory Leak in ARC
      • From: Jens Alfke <email@hidden>
  • Prev by Date: Re: Launchimages no longer showing the expected sizes of the images in Xcode 8.1?
  • Next by Date: Re: Mixing Cpp and ObjC - Memory Leak in ARC
  • Previous by thread: Re: Xcode 8.1 deleting images in launchimages for iOS apps
  • Next by thread: Re: Mixing Cpp and ObjC - Memory Leak in ARC
  • Index(es):
    • Date
    • Thread