From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id WAA07931; Tue, 19 Aug 2003 22:13:48 +0200 (MET DST) Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id WAA29685 for ; Tue, 19 Aug 2003 22:13:45 +0200 (MET DST) Received: from cog.brown.edu (titan.cog.brown.edu [128.148.208.226]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h7JKDhf10340 for ; Tue, 19 Aug 2003 22:13:44 +0200 (MET DST) Received: from venere.cog.brown.edu ([128.148.208.214] verified) by cog.brown.edu (CommuniGate Pro SMTP 4.0.6) with ESMTP id 511512 for caml-list@inria.fr; Tue, 19 Aug 2003 16:13:43 -0400 Received: from venere.cog.brown.edu (localhost.localdomain [127.0.0.1]) by venere.cog.brown.edu (8.12.9/8.12.9) with ESMTP id h7JKBaGq020550 for ; Tue, 19 Aug 2003 16:11:36 -0400 Received: (from tahir@localhost) by venere.cog.brown.edu (8.12.9/8.12.9/Debian-5) id h7JKBXwR020548 for caml-list@inria.fr; Tue, 19 Aug 2003 16:11:33 -0400 X-Authentication-Warning: venere.cog.brown.edu: tahir set sender to tahir@acm.jhu.edu using -f Subject: [Caml-list] memory problems From: Tahir H Butt To: caml-list@inria.fr Content-Type: text/plain Content-Transfer-Encoding: 7bit Message-Id: <1061323892.20426.33.camel@venere.cog.brown.edu> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.3 Date: 19 Aug 2003 16:11:33 -0400 X-Loop: caml-list@inria.fr X-Spam: no; 0.00; butt:99 vals:01 ocamlopt:01 ocamlc:01 3.06,:01 3.07:01 flags:01 bug:01 chunks:01 598:99 cog:99 ocaml:01 ocaml-:01 int:01 fragments:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Hi all, There seems to be something going screwy in a piece of my code. The code is used to average a matrix of values over several modifications. for r=0 to k-1 do let matrix_r = matrix.(r) in let f_r = feature_vals.(r) in for j=0 to n-1 do let f_rj = f_r.(j) in let matrix_rj = matrix_r.(j) in let current_sum = f_rj.current_sum in let generation = f_rj.generation in let new_sum = current_sum +. (matrix_rj *. (float_of_int (generation_counter - generation))) in (* VARIED SECTION *) f_rj.generation <- generation_counter done done; (* VARIED SECTION *) is (A) f_rj.current_sum <- current_sum; or (B) f_rj.current_sum <- 1.0; or (C) f_rj.current_sum <- new_sum; Using both ocamlopt and ocamlc (3.06, and 3.07beta1, with and without optimization flags), (A) and (B) keep a constant memory load through the course of the program. (C) which is the actual value I need to set causes the memory usage to grow each time the above function is called. I've tried throwing in some Gc.compact() lines, without luck. This is mildly frustrating. Is this a bug, or a mistake on my part? I can send whoever wishes to see the rest of the code the source, but it's probably not critical here. I tried replicating this as an isolated case, and it didn't seem to cause problems. Any ideas? Has someone reported a similar bug? I tried searching the BTS without luck. Sorry if this might be of trivial concern, but I'm far from an expert of the ocaml language. Here is some Gc.stat info, before and after the code above, as well as with Gc.compact() (all with ocaml-3.07beta1) % Before function minor_words: 108910518 promoted_words: 36319417 major_words: 67201780 minor_collections: 4947 major_collections: 10 heap_words: 69238784 heap_chunks: 598 top_heap_words: 69238784 live_words: 66342960 live_blocks: 11447005 free_words: 2895824 free_blocks: 89 largest_free: 61440 fragments: 0 compactions: 1 % After function minor_words: 141302822 promoted_words: 67223235 major_words: 98105598 minor_collections: 7505 major_collections: 11 heap_words: 97255424 heap_chunks: 1054 top_heap_words: 97255424 live_words: 97246778 live_blocks: 21747585 free_words: 8646 free_blocks: 43 largest_free: 8562 fragments: 0 compactions: 1 % After function and compact minor_words: 141303588 promoted_words: 67223235 major_words: 98106033 minor_collections: 7505 major_collections: 13 heap_words: 97255424 heap_chunks: 1054 top_heap_words: 97255424 live_words: 95698876 live_blocks: 21232921 free_words: 1556548 free_blocks: 67 largest_free: 61440 fragments: 0 compactions: 2 Thanks --tahir Tahir H Butt Brown University Cognitive and Linguistic Sciences PhD Student http://www.cog.brown.edu/~tahir ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners