From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id BCE6CBC57 for ; Fri, 19 Nov 2010 23:11:12 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AokFAEuE5kxQW+UMgWdsb2JhbACUX44CFQEBFiIivV2FSwSKWw X-IronPort-AV: E=Sophos;i="4.59,226,1288566000"; d="scan'208";a="80360974" Received: from lo.gmane.org ([80.91.229.12]) by mail2-smtp-roc.national.inria.fr with ESMTP; 19 Nov 2010 23:11:12 +0100 Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1PJZAh-0000Lv-MH for caml-list@inria.fr; Fri, 19 Nov 2010 23:11:07 +0100 Received: from avelizy-155-1-94-54.w90-35.abo.wanadoo.fr ([90.35.89.54]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 19 Nov 2010 23:11:07 +0100 Received: from sylvain by avelizy-155-1-94-54.w90-35.abo.wanadoo.fr with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 19 Nov 2010 23:11:07 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: caml-list@inria.fr From: Sylvain Le Gall Subject: Re: Looking for stubs for sendmsg/recvmsg Date: Fri, 19 Nov 2010 22:10:55 +0000 (UTC) Message-ID: References: <87d3q21qe4.fsf@frosties.localnet> <87ipztl2ld.fsf@frosties.localnet> <8739qx88e9.fsf@frosties.localnet> X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: avelizy-155-1-94-54.w90-35.abo.wanadoo.fr User-Agent: slrn/pre1.0.0-18 (Linux) X-Spam: no; 0.00; le-gall:01 stubs:01 le-gall:01 finalizer:01 leaking:01 wrote:01 wrote:01 unix:01 unix:01 functions:01 precisely:01 writes:01 writes:01 modules:02 modules:02 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 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