From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: * X-Spam-Status: No, score=1.1 required=5.0 tests=AWL,SPF_SOFTFAIL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id 10B9EBB84 for ; Mon, 12 Jan 2009 18:57:13 +0100 (CET) X-IronPort-AV: E=Sophos;i="4.37,253,1231110000"; d="scan'208";a="22359933" Received: from discorde.inria.fr ([192.93.2.38]) by mail1-smtp-roc.national.inria.fr with ESMTP; 12 Jan 2009 18:57:12 +0100 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id n0CHvCw8020787 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Mon, 12 Jan 2009 18:57:12 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApoEALMTa0lSkiEx/2dsb2JhbADTeoVv X-IronPort-AV: E=Sophos;i="4.37,253,1231110000"; d="scan'208";a="22359928" Received: from 5070.info ([82.146.33.49]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 12 Jan 2009 18:57:08 +0100 X-Bogosity: Unsure, tests=bogofilter Received: from [192.168.1.21] (92-124-28-6.pppoe.irtel.ru [92.124.28.6] (may be forged)) (authenticated bits=0) by 5070.info (8.14.3/8.14.0) with ESMTP id n0CHujAD090759 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Mon, 12 Jan 2009 17:57:07 GMT (envelope-from john@ispsystem.com) Subject: Re: [Caml-list] Re: memory usage From: John Lepikhin To: caml-list@inria.fr In-Reply-To: <20090112114127.GA1568@annexia.org> References: <1231746106.4376.27.camel@john-laptop> <20090112083913.GA28059@annexia.org> <1231751641.4376.39.camel@john-laptop> <1231759695.4376.55.camel@john-laptop> <20090112114127.GA1568@annexia.org> Content-Type: text/plain Date: Tue, 13 Jan 2009 01:56:39 +0800 Message-Id: <1231782999.4376.246.camel@john-laptop> Mime-Version: 1.0 X-Mailer: Evolution 2.24.2 Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH authentication, not delayed by milter-greylist-3.0 (5070.info [82.146.33.49]); Mon, 12 Jan 2009 17:57:08 +0000 (UTC) X-Miltered: at discorde with ID 496B8478.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; wronly:01 buffer:01 buffer:01 decr:01 decremented:01 ocaml:01 7.0:98 threads:01 threads:01 unix:01 unix:01 caml-list:01 short:01 int:01 data:02 > I'm afraid to say that you'll have to post a short reproducer here > before I can look at this further ... I'm not sure this is the same issue. Look at this test code: ================================ let threads_counter = ref 0 let counter_mutex = Mutex.create () let send_data data size = let fd = Unix.openfile "/dev/null" [ Unix.O_WRONLY ] 0o644 in ignore (Unix.write fd data 0 size); Unix.close fd let read_data _ = let fd = Unix.openfile "/dev/random" [] 0o644 in let buffer = String.create 1024 in let br = Unix.read fd buffer 0 (Random.int 1000) in Unix.close fd; ignore (Unix.select [] [] [] 0.1); send_data buffer br let do_work _ = read_data (); Mutex.lock counter_mutex; decr threads_counter; Mutex.unlock counter_mutex let _ = while true do Mutex.lock counter_mutex; if !threads_counter < 20 then begin incr threads_counter; ignore (Thread.create do_work ()); end; Mutex.unlock counter_mutex; done; Unix.sleep 100 ================================ It checks if thread count is less than 20. If so, new thread is created and threads_counter incremented. After thread is done, threads_counter is decremented. After 5 minutes of work, RSS usage was grown from 3300KB to 5670KB on FreeBSD 7.0 and from 976KB to 1200KB on Linux. In both cases Ocaml 3.10.2 was used.