What the deal with NSZoneFree in

Submitted by:

's Success Story

What the deal with NSZoneFree in

I never had the notion that I should be calling NSZoneFree in my own NSObject subclasses (or what NS_WhateverClass_ subclasses) and can't find anything conclusive on the topic anywhere in the docs.

All I can find about using NSZoneFree is a brief mention in thCotee Memory Management Programming Guide, and an explanation of the function in the Foundation Functions Reference, but none of these docs make it clear to me whether I should worry about it in the context of a dealloc method.

NSZoneFree() balances out a call to NSZoneMalloc(), just like -release balances a call to -alloc or -copy and CFRelease() balances a call to CFRetain() or CF*Create*() or, for that matter, free() balances a call to malloc() or calloc().

Given the allocator(s) that the C library uses on Ma Cheap MBT c OS X, much of this is academic, but best practices say that you release your hold on memory the same way you got it, and in the case of that class, the instance variable private had previously been allocated with NSZoneMalloc().

No Name

Certs/Trainings:
No reviews

Success Story Reviews

Add Comment

 
Image CAPTCHA
Cancel