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 11:32:37 -0700
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 assume means file descriptors. Is that
the total number of FDs in use at any given time?
No, Just like process ID, file descriptor number can be reused by
the system.
That analogy is a bit flawed. Process IDs are global across the
system. File descriptors are per-process.
And there is absolutely no guarantee the system use simple
incremental value for fd AFAIK.
Actually, when a new file descriptor is created for your process,
it does use the lowest unused descriptor number (except for dup2()).
Still, the File Activity instrument's event list isn't showing a
count of file descriptors, it's showing the specific individual
file descriptor involved in the specific event. But there's a
pretty good chance that the highest file descriptor you see across
a significant range of events roughly indicates the count of open
descriptors.
Regards,
Ken
That's kind of what I concluded -- that the FD is roughly the
current number of file descriptors.
I noticed that sometimes the FD shows -1, but that's only in a
transient condition. I attribute that to Instruments not being able
to keep up. It never settles down to -1. After a fair amount of
application warm-up the FD shows 25 to 26. So, I assume I'm ok. The
FD has a pattern similar to memory in use. It grows for a while when
you start and use an application, then settles out to some value. If
it grows continually I guess you have a problem. In order not to get
a fire-hose amount of data, you can type in a file-name (or some
other identifier) into the spotlight-like magnifier box in the lower
right corner of the Instruments window. Then you are looking at only
files of interest. Again this sort of works, but Instruments still
may not show everything.
Jim Merkel
After looking some more at Instruments File Activity, I see that the
FD can end up in a static state with an FD of -1. I'm not sure what
that means. However I think Ken Thomases' statement is correct:
"Still, the File Activity instrument's event list isn't showing a
count of file descriptors, it's showing the specific individual file
descriptor involved in the specific event. But there's a pretty good
chance that the highest file descriptor you see across a significant
range of events roughly indicates the count of open descriptors."
You can sort on the FD column and find the largest FD, so that's
pretty easy to find.
I notice that the Instruments documentation (User Guide) doesn't
explain these things, at least as far as I could tell. Maybe you're
just supposed to know this (from birth I guess).
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