[Openmcl-devel] Fix memory leak in an objc example

Leo Liu sdl.web at gmail.com
Sun May 4 01:39:21 PDT 2014


On 2014-05-03 09:54 -0500, Paul Krueger wrote:
> More subtle problems would occur if you released objects that are
> returned by what are called "convenience constructors" by Apple
> (presumably because you don't have to worry about managing their
> memory). These constructors return objective-c objects which are
> already autoreleased. If you already know about these, then you'll be
> fine; just don't release such objects.
>
> If you're not familiar with convenience constructors then I'd suggest
> that you do some reading. The apple documentation is not always very
> clear about which constructors are of this form and which are not, but
> read the doc anyway since it will sometimes be helpful. If you google
> "apple convenience constructor" you will find all sorts of information
> about them which may help you. If you release an object created via a
> convenience constructor, you can cause all sorts of problems since the
> memory may be reused and then released by the autorelease prematurely.
> Trust me, such problems can be difficult to diagnose.

Thanks for the advice.

Leo




More information about the Openmcl-devel mailing list