I’m working with a C++ audio library in an iPhone app. Is there any Objective C / Cocoa memory management infrastructure I can use for my C++ objects, or do I need to just read up and learn C++ memory management?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You might find my latest blog post useful, at least the first half, as I discuss and compare both Objective-C memory management and idiomatic C++ memory management.
Executive summary is that most C++ devs use smart pointers.
With Objective-C++ there are additional things to worry about – in particular the fact that (at least by default), C++ value types held as members of Objective-C classes do not have constructors or destructors called automatically for you. You can call them explicitly, of course – but it’s ugly. Personally I tend to just hold them by intrusive pointers (smart, reference counted, pointers where the ref count is held within the object itself – much like Obj-C pointers – which is why they are a good fit).