To: caml-list@inria.fr
Subject: [GC] Evaluate memory use
From: David.Mentre@irisa.fr (David =?iso-8859-1?q?Mentré?=)
Date: 18 Nov 1999 15:37:26 +0100
[ short french:
Comment connaître la consommation mémoire maximum d'un programme OCaml
? ]
Hello all Caml users/hackers,
Is there any way to know the maximum memory used by an OCaml program?
Right now, I'm using Gc.heap_words, but it doesn't seem to be very
accurate. I think because the minor heap words are not counted. Anyway
to fix this? Should I use something like:
let max_words_total = stats.Gc.minor_words - stats.Gc.promoted_words + stats.Gc.heap_words in
Used code below:
let print_computation_stats elapsed_time =
let stats = Gc.stat () in
let max_words_total = stats.Gc.heap_words in
printf "@\n@[<v 2>##### Statistics #####@\n" ;
printf "Maximum memory used: %d kBytes@\n" (max_words_total * Sys.word_size
/ 8 / 1024) ;
printf "Processor time used: %f seconds@\n" (Sys.time ()) ;
printf "Wall clock time used: %f seconds@\n" elapsed_time ;
printf "@\n" ;
printf "@]@\n@?"
BTW, is there any simple way to evaluate Wall Clock Time used by an
OCaml program? Right now, I'm using 'Unix.gettimeofday ()'. Is there a
simpler way to do it?
let start_time = Unix.gettimeofday () in
let produced_properties = verify properties prog possible_projections in
let stop_time = Unix.gettimeofday () in
print_computation_stats (stop_time -. start_time) ;
Best regards,
david
-- David.Mentre@irisa.fr -- http://www.irisa.fr/prive/dmentre/ Opinions expressed here are only mine.
This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:28 MET