Re: dealloc and scarce resources
Re: dealloc and scarce resources
- Subject: Re: dealloc and scarce resources
- From: James Merkel <email@hidden>
- Date: Thu, 30 Jun 2011 13:33:59 -0700
On Jun 30, 2011, at 12:21 PM, Kyle Sluder wrote:
On Thu, Jun 30, 2011 at 12:12 PM, James Merkel <email@hidden>
wrote:
Ok, I don't know what an -invalidate method is, but I'll look it up.
It's the thing Wim talked about. An explicit way to release the scarce
resource you're holding on to. Depending on what that resource is, an
appropriate name might be -close, or -invalidate, or -terminate.
--Kyle Sluder
I saw that in Wlm's post. However, I'm not sure where I would do that.
I'll have to think about it some more.
By the way my original post referred to the Memory Management
Programming Guide and the statement:
"You should typically not manage scarce resources such as file
descriptors, network connections, and buffers or caches in a dealloc
method."
I was pretty sure that "file descriptors" referred to something at a
lower level, but wasn't sure. Maybe I'm being pedantic, but Apple
could have helped things along by saying:
"You should typically not manage scarce resources such as Unix file
descriptors, ..."
Everyone doesn't approach this stuff with the same background.
We find from Kernighan and Ritchie (K&R) second edition, section 8.1
that a file descriptor is a small non-negative integer that refers to
a file and is maintained by the system. So, my guess is that when
Instruments shows an FD of -1 it refers to an FD that isn't mine. But
that's just a guess. Instruments doesn't document this as far as I know.
Jim Merkel
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden