Sylvain Le Gall <sylv...@le-gall.net> writes:

> On 19-11-2010, Goswin von Brederlow <goswin-...@web.de> wrote:
>> Sylvain Le Gall <sylv...@le-gall.net> writes:
>>> On 19-11-2010, Goswin von Brederlow <goswin-...@web.de> wrote:
>>>> Sylvain Le Gall <sylv...@le-gall.net> writes:
>>>>> On 18-11-2010, Goswin von Brederlow <goswin-...@web.de> wrote:
>>>
>>> Not that much, if you proceed in another way. I think what you are
>>> looking for is a fd leak detector?
>>>
>>> Here is a small modules that I have written for this purpose:
>>>
>>> File UnixExt.ml:
>>> (** Count open/close call *)
>
> [...]
>
>>> [...override other functions that open/close fd...]
>>>
>>> Then in the modules using this features, you just have to open UnixExt
>>> after Unix...
>>>
>>> You can even probably design a library that will transparently hide Unix
>>> with a custom Unix module providing this feature.
>>
>> Much less usefull.
>>
>> Using a custom block with finalizer means that the FD will be closed
>> relative close to where/when it was leaked. Makes it easier to find
>> where it was leaked and adding GC.compact calls at strategic locations
>> can narrow it down even more. Leaking FDs also becomes much less
>> serious. The GC will clean them up and close them. So you can use an app
>> that leaks FDs just fine.
>>
>
> It all depends on what you want: fix your program that leaks or live
> with it. The former piece of code helps to fail if there are leaked FD.
> On Unix FD leaks is not that problematic, but on Windows it turns to be
> another problem.
>
> The best example about this: you cannot delete a file that has an FD
> still open on it. This makes harder to remove temporary file (and this
> piece of code was precisely made to track FD on temporary files, that
> let 1000s of unremoved temp file). 
>
> Regards,
> Sylvain Le Gall

Which again speaks for my solution. The leaked FD will be closed much
faster (before the program terminates) and one can remove the tempfiles
while the program is still running.

MfG
        Goswin

_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

Reply via email to