Re: dealloc and scarce resources

2011-06-30 Thread James Merkel
On Jun 30, 2011, at 6:39 PM, Kyle Sluder wrote: On Thu, Jun 30, 2011 at 6:34 PM, James Merkel wrote: Then wherever I was sending the -release, I need to also send a separate -close. it could be before or after the release, it doesn't really matter. No, it really needs to be before the

Re: dealloc and scarce resources

2011-06-30 Thread Kyle Sluder
On Thu, Jun 30, 2011 at 6:34 PM, James Merkel wrote: > Then wherever I was sending the -release, I need to also send a separate >  -close. it could be before or after the release, it doesn't really matter. No, it really needs to be before the -release. When you call -release, you relinquish your

Re: dealloc and scarce resources

2011-06-30 Thread James Merkel
Not to beat this subject to death, but I just realized that what Kyle Sluder and Wlm Lewis were saying is very easy to implement. All I need is a method that just closes the file -- one line of code. Then wherever I was sending the -release, I need to also send a separate -close. it could be

Re: dealloc and scarce resources

2011-06-30 Thread Ken Thomases
On Jun 30, 2011, at 3:33 PM, James Merkel wrote: > So, my guess is that when Instruments shows an FD of -1 it refers to an FD > that isn't mine. What the File Activity instrument is showing in its event list is a certain subset of system calls which operate on file descriptors. It is showing

Re: dealloc and scarce resources

2011-06-30 Thread Greg Guerin
Jeffrey Walton wrote: Wikipedia is hardly the definitive reference. SEO comes to mind. Luckily, I didn't say Wikipedia was a definitive reference. I said "useful reference". And anyone at all familiar with it knows full well that its accuracy (and usefulness) can vary widely. I, for one

Re: dealloc and scarce resources

2011-06-30 Thread Jeffrey Walton
On Thu, Jun 30, 2011 at 7:06 PM, Greg Guerin wrote: > James Merkel wrote: > >> 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

Re: dealloc and scarce resources

2011-06-30 Thread Greg Guerin
James Merkel wrote: 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. Wikipedia is also a useful r

Re: dealloc and scarce resources

2011-06-30 Thread Jens Alfke
On Jun 30, 2011, at 1:33 PM, James Merkel wrote: > 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. Actually file descriptors are used for any sort of I/O chann

Re: dealloc and scarce resources

2011-06-30 Thread Jerry Krinock
On 2011 Jun 30, at 13:33, James Merkel wrote: > I'm not sure where I would do that [-invalidate, releaseResources, > removeObservers, whatever] That's a common dilemma. There is no general solution. Each situation will have its own least-worst solution. > Apple could have helped things alon

Re: dealloc and scarce resources

2011-06-30 Thread James Merkel
On Jun 30, 2011, at 12:21 PM, Kyle Sluder wrote: On Thu, Jun 30, 2011 at 12:12 PM, James Merkel 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 wha

Re: dealloc and scarce resources

2011-06-30 Thread Kyle Sluder
On Thu, Jun 30, 2011 at 12:12 PM, James Merkel 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 -clos

Re: dealloc and scarce resources

2011-06-30 Thread James Merkel
On Jun 30, 2011, at 12:04 PM, Kyle Sluder wrote: On Thu, Jun 30, 2011 at 9:20 AM, James Merkel wrote: After a fair amount of application warm-up the FD shows 25 to 26. So, I assume I'm ok. And what happens when (not if) you introduce a leak, and these objects live longer than you expect th

Re: dealloc and scarce resources

2011-06-30 Thread Kyle Sluder
On Thu, Jun 30, 2011 at 9:20 AM, James Merkel wrote: > After a fair amount of application warm-up the FD > shows 25 to 26. So, I assume I'm ok. And what happens when (not if) you introduce a leak, and these objects live longer than you expect them to? Or worse, someone else starts holding on to t

Re: dealloc and scarce resources

2011-06-30 Thread James Merkel
On Jun 30, 2011, at 9:20 AM, James Merkel wrote: On Jun 30, 2011, at 2:01 AM, Ken Thomases wrote: On Jun 30, 2011, at 3:02 AM, Jean-Daniel Dupas wrote: Le 30 juin 2011 à 08:19, James Merkel a écrit : Ok, I'm looking at my application in Instruments File Activity. The column labeled FD I

Re: dealloc and scarce resources

2011-06-30 Thread James Merkel
On Jun 30, 2011, at 2:01 AM, Ken Thomases wrote: On Jun 30, 2011, at 3:02 AM, Jean-Daniel Dupas wrote: Le 30 juin 2011 à 08:19, James Merkel a écrit : Ok, I'm looking at my application in Instruments File Activity. The column labeled FD I assume means file descriptors. Is that the total

Re: dealloc and scarce resources

2011-06-30 Thread Ken Thomases
On Jun 30, 2011, at 3:02 AM, Jean-Daniel Dupas wrote: > Le 30 juin 2011 à 08:19, James Merkel a écrit : > >> Ok, I'm looking at my application in Instruments File Activity. The column >> labeled FD I assume means file descriptors. Is that the total number of FDs >> in use at any given time? >

Re: dealloc and scarce resources

2011-06-30 Thread Jean-Daniel Dupas
Le 30 juin 2011 à 08:19, James Merkel a écrit : > > On Jun 29, 2011, at 11:07 PM, Kyle Sluder wrote: > >> On Wed, Jun 29, 2011 at 10:38 PM, James Merkel wrote: >>> Ok, thanks. For what I'm doing file descriptors are not a scarce resource. >> >> File descriptors are almost always a scarce reso

Re: dealloc and scarce resources

2011-06-29 Thread James Merkel
On Jun 29, 2011, at 11:07 PM, Kyle Sluder wrote: On Wed, Jun 29, 2011 at 10:38 PM, James Merkel wrote: Ok, thanks. For what I'm doing file descriptors are not a scarce resource. File descriptors are almost always a scarce resource. By default, each process only gets 256 of them. --Kyle S

Re: dealloc and scarce resources

2011-06-29 Thread Kyle Sluder
On Wed, Jun 29, 2011 at 10:38 PM, James Merkel wrote: > Ok, thanks. For what I'm doing file descriptors are not a scarce resource. File descriptors are almost always a scarce resource. By default, each process only gets 256 of them. --Kyle Sluder ___

Re: dealloc and scarce resources

2011-06-29 Thread James Merkel
On Jun 29, 2011, at 9:47 PM, Quincey Morris wrote: On Jun 29, 2011, at 17:43, James Merkel wrote: "You should typically not manage scarce resources such as file descriptors, network connections, and buffers or caches in a dealloc method. In particular, you should not design classes so th

Re: dealloc and scarce resources

2011-06-29 Thread Quincey Morris
On Jun 29, 2011, at 17:43, James Merkel wrote: > "You should typically not manage scarce resources such as file descriptors, > network connections, and buffers or caches in a dealloc method. In > particular, you should not design classes so that dealloc will be invoked > when you think it will

Re: dealloc and scarce resources

2011-06-29 Thread James Merkel
On Jun 29, 2011, at 7:17 PM, Wim Lewis wrote: On 29 Jun 2011, at 5:43 PM, James Merkel wrote: In the [Memory Management Programming Guide] it says: "You should typically not manage scarce resources such as file descriptors, network connections, and buffers or caches in a dealloc method.

Re: dealloc and scarce resources

2011-06-29 Thread Wim Lewis
On 29 Jun 2011, at 5:43 PM, James Merkel wrote: > In the [Memory Management Programming Guide] it says: > > "You should typically not manage scarce resources such as file descriptors, > network connections, and buffers or caches in a dealloc method. In > particular, you should not design classe