X-Git-Url: http://git.nguyen.vg/gitweb/?a=blobdiff_plain;f=memory.ml;fp=memory.ml;h=0000000000000000000000000000000000000000;hb=4b52da1a20a4fe031930bb96d2ca46bec06dc529;hp=d0054206552327cb6c6c84a259386f2cc92eb2b5;hpb=a223af3254fb51c279cfbccdc18c59484fdca74e;p=SXSI%2Fxpathcomp.git diff --git a/memory.ml b/memory.ml deleted file mode 100644 index d005420..0000000 --- a/memory.ml +++ /dev/null @@ -1,40 +0,0 @@ -(******************************************************************************) -(* SXSI : XPath evaluator *) -(* Kim Nguyen (Kim.Nguyen@nicta.com.au) *) -(* Copyright NICTA 2008 *) -(* Distributed under the terms of the LGPL (see LICENCE) *) -(******************************************************************************) - -let globals = Hashtbl.create 107 -let cpt = ref 0 - -let register v str = - let _cpt = !cpt in - let f = (* This function must not take v as argument, otherwise - v won't be garbage collected *) - fun _ -> Hashtbl.remove globals _cpt - in - Hashtbl.add globals _cpt str; - incr cpt; - Gc.finalise f v -;; - -let schedule_stats = - let first = ref true in - function () -> if !first - then - let show_leaked_values () = - Printf.eprintf "Memory debugging requested :\n%!"; - Printf.eprintf "Triggering major collection :%!"; - Gc.full_major(); - Printf.eprintf " ok\n%!"; - Printf.eprintf "Triggering memory compaction :%!"; - Gc.compact(); - Printf.eprintf " ok\n%!"; - let i = Hashtbl.length globals in - Printf.eprintf "%i object%s leaked\n%!" i (if i < 2 then "" else "s"); - Hashtbl.iter (fun key msg -> - Printf.printf "Value %i, registered at %s has not been collected\n" key msg) globals - in at_exit show_leaked_values; first := false - else () -