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 mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id 975C5BB84 for ; Tue, 13 Jan 2009 17:01:29 +0100 (CET) X-IronPort-AV: E=Sophos;i="4.37,260,1231110000"; d="scan'208";a="21429732" Received: from discorde.inria.fr ([192.93.2.38]) by mail3-smtp-sop.national.inria.fr with ESMTP; 13 Jan 2009 17:01:29 +0100 Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id n0DG1Pqu007918 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Tue, 13 Jan 2009 17:01:29 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApoEABNJbElSkiEx/2dsb2JhbADRKIVv X-IronPort-AV: E=Sophos;i="4.37,260,1231110000"; d="scan'208";a="19541621" Received: from 5070.info ([82.146.33.49]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 13 Jan 2009 17:01:25 +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 n0DG0nYO070350 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 13 Jan 2009 16:01:12 GMT (envelope-from john@ispsystem.com) Subject: Re: [Caml-list] Re: memory usage From: John Lepikhin To: caml-list@inria.fr In-Reply-To: <20090112220126.GA26026@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> <1231782999.4376.246.camel@john-laptop> <20090112201219.GB21039@annexia.org> <1231796046.4376.261.camel@john-laptop> <20090112220126.GA26026@annexia.org> Content-Type: text/plain Date: Wed, 14 Jan 2009 00:00:42 +0800 Message-Id: <1231862442.4376.315.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]); Tue, 13 Jan 2009 16:01:14 +0000 (UTC) X-Miltered: at discorde with ID 496CBAD5.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; libexec:01 libexec:01 lib:01 lib:01 libc:01 libc:01 gdb:01 lwp:01 lwp:01 gdb:01 stdout:01 stdout:01 chunks:01 compactions:01 anon:98 > Yeah, I flushed the output and I used /dev/zero - I still see no > messages. That's strange. Anyway, it looks like a memory leak, isn't it? 20 threads * 1KB max = 20 KB of memory for data storage should be used (plus 20KB*500% for heap overhead = 100KB). I changed delay to 1 ms: ignore (Unix.select [] [] [] 0.001); After 2 minutes of work on FreeBSD, 19MB(!) was used: # ps auxw | grep a.out | grep -v grep root 35136 30.1 0.2 60348 19304 p5 L+ 1:36PM 2:08.07 ./a.out # pmap : Address Kbytes RSS Shared Priv Mode Mapped File 0000000000400000 204 360 - 360 r-x /tmp/a.out 0000000000532000 80 76 - 80 rw- /tmp/a.out 0000000000546000 28 16 - 28 rw- [ anon ] 0000000040532000 148 108 148 - r-x /libexec/ld-elf.so.1 0000000040557000 132 108 - 132 rw- [ anon ] 0000000040657000 28 28 - 28 rw- /libexec/ld-elf.so.1 000000004065E000 24 20 - 24 rw- [ anon ] 0000000040664000 92 76 92 - r-x /lib/libm.so.5 000000004067B000 4 4 - 4 r-x /lib/libm.so.5 000000004067C000 1024 0 1024 - r-x /lib/libm.so.5 000000004077C000 8 8 - 8 rw- /lib/libm.so.5 000000004077E000 64 64 64 - r-x /lib/libthr.so.3 000000004078E000 4 4 - 4 r-x /lib/libthr.so.3 000000004078F000 1024 12 1024 - r-x /lib/libthr.so.3 000000004088F000 12 12 - 12 rw- /lib/libthr.so.3 0000000040892000 8 8 - 8 rw- [ anon ] 0000000040894000 932 452 932 - r-x /lib/libc.so.7 000000004097D000 4 4 - 4 r-x /lib/libc.so.7 000000004097E000 1020 0 1020 - r-x /lib/libc.so.7 0000000040A7D000 116 116 - 116 rw- /lib/libc.so.7 0000000040A9A000 92 36 - 92 rw- [ anon ] 0000000040B00000 44032 13976 - 44032 rw- [ anon ] 00007FFFF85A4000 128 12 - 128 rw- [ anon ] 00007FFFF87A5000 128 12 - 128 rw- [ anon ] 00007FFFF89A6000 128 12 - 128 rw- [ anon ] 00007FFFF8BA7000 128 12 - 128 rw- [ anon ] 00007FFFF8DA8000 128 12 - 128 rw- [ anon ] 00007FFFF8FA9000 128 12 - 128 rw- [ anon ] ... (gdb) info thr 18 Thread 0x40b01120 (LWP 101068) 0x00000000408e4d4c in _umtx_op () from /lib/libc.so.7 17 Thread 0x40b01290 (LWP 100489) 0x0000000040971cfc in select () from /lib/libc.so.7 16 Thread 0x40b01b30 (LWP 100079) 0x00000000408e4d4c in _umtx_op () from /lib/libc.so.7 15 Thread 0x40b04d80 (LWP 100858) 0x0000000040971cfc in select () from /lib/libc.so.7 14 Thread 0x40b02260 (LWP 101096) 0x00000000408e4d4c in _umtx_op () from /lib/libc.so.7 13 Thread 0x40b04200 (LWP 101128) 0x0000000040971cfc in select () from /lib/libc.so.7 12 Thread 0x40b03960 (LWP 101175) 0x00000000408e4d4c in _umtx_op () from /lib/libc.so.7 11 Thread 0x40b02820 (LWP 101189) 0x00000000408e4d4c in _umtx_op () from /lib/libc.so.7 10 Thread 0x40b03680 (LWP 101217) 0x00000000408e4d4c in _umtx_op () from /lib/libc.so.7 9 Thread 0x40b03f20 (LWP 100057) 0x00000000408e4d4c in _umtx_op () from /lib/libc.so.7 8 Thread 0x40b020f0 (LWP 100066) 0x0000000040971cfc in select () from /lib/libc.so.7 7 Thread 0x40b05ec0 (LWP 100535) 0x0000000040971cfc in select () from /lib/libc.so.7 6 Thread 0x40b04370 (LWP 100564) 0x00000000408e4d4c in _umtx_op () from /lib/libc.so.7 5 Thread 0x40b04c10 (LWP 100698) 0x0000000040971cfc in select () from /lib/libc.so.7 4 Thread 0x40b02b00 (LWP 101224) 0x0000000040971cfc in select () from /lib/libc.so.7 3 Thread 0x40b03ad0 (LWP 101227) 0x0000000040971cfc in select () from /lib/libc.so.7 2 Thread 0x40b037f0 (LWP 101258) 0x00000000408e4d4c in _umtx_op () from /lib/libc.so.7 * 1 Thread 0x40b05620 (LWP 100101) 0x00000000409643dc in open () from /lib/libc.so.7 (gdb) I also added special thread to check GC: let print_stats _ = while true do Gc.compact (); Gc.print_stat stdout; flush stdout; Unix.sleep 10; done Thread.create print_stats (); GC statistics after 1 minute: minor_words: 21929847 <-- ? promoted_words: 2474840 major_words: 2939105 minor_collections: 1655 major_collections: 635 heap_words: 61440 heap_chunks: 1 top_heap_words: 61440 live_words: 1024 live_blocks: 115 free_words: 60416 free_blocks: 1 largest_free: 60416 fragments: 0 compactions: 7