caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] memory problems
@ 2003-08-19 20:11 Tahir H Butt
  2003-08-21 12:54 ` Xavier Leroy
  0 siblings, 1 reply; 2+ messages in thread
From: Tahir H Butt @ 2003-08-19 20:11 UTC (permalink / raw)
  To: caml-list

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Caml-list] memory problems
  2003-08-19 20:11 [Caml-list] memory problems Tahir H Butt
@ 2003-08-21 12:54 ` Xavier Leroy
  0 siblings, 0 replies; 2+ messages in thread
From: Xavier Leroy @ 2003-08-21 12:54 UTC (permalink / raw)
  To: Tahir H Butt; +Cc: caml-list

> 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'd be interested in a complete program that exhibits the behavior you
describe.  (Please send it just to me, so as not to clutter this list.)

> I've tried throwing in some Gc.compact() lines, without luck.

You can also try Gc.full_major().

- Xavier Leroy

-------------------
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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-08-21 12:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-08-19 20:11 [Caml-list] memory problems Tahir H Butt
2003-08-21 12:54 ` Xavier Leroy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).