Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
Looking for stubs for sendmsg/recvmsg
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2010-11-19 (22:11)
From: Sylvain Le Gall <sylvain@l...>
Subject: Re: Looking for stubs for sendmsg/recvmsg
On 19-11-2010, Goswin von Brederlow <> wrote:
> Sylvain Le Gall <> writes:
>> On 19-11-2010, Goswin von Brederlow <> wrote:
>>> Sylvain Le Gall <> writes:
>>>> On 18-11-2010, Goswin von Brederlow <> 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
>> (** 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). 

Sylvain Le Gall