On 13 September 2012, Sonia Hamilton said:
> I'm getting errors due to "too many open files":
>
> Couldn't get hostname: open /proc/sys/kernel/hostname: too many open files
>
>
> What tools/techniques could I use to track this down? I've
> got deferred closes on the two locations in my program where I open files,
> so I'm thinking it's in one of the third party libraries I'm using.
Code review?
Years of experience with other garbage-collected languages (mainly
Python and Java) has taught me to always, always, always explicitly
release non-memory resources. IOW, if you open a file, you close it.
If you are 100% sure that your own code religiously closes every file
that it opens without relying on GC, then you should probably audit
those third-party libraries.
Alternately, write tiny test programs that just focus on one
third-party library at a time until you have found the culprit... or
convinced yourself that those libraries are all fine. ;-)
Greg