From: Enrico Tassi Date: Thu, 12 May 2005 09:20:48 +0000 (+0000) Subject: fixed memory leak (workaround) X-Git-Tag: single_binding~81 X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=commitdiff_plain;h=8d1c6f47f6a17cae4cc738987184b37e640b48ed;p=helm.git fixed memory leak (workaround) --- diff --git a/helm/ocaml/cic/cicPushParser.ml b/helm/ocaml/cic/cicPushParser.ml index c6f56dad9..a76105deb 100644 --- a/helm/ocaml/cic/cicPushParser.ml +++ b/helm/ocaml/cic/cicPushParser.ml @@ -638,8 +638,19 @@ let parse uri filename = let xml_parser = P.create_parser callbacks in ctxt.xml_parser <- Some xml_parser; try - P.parse xml_parser (`Gzip_file filename); + (try + P.parse xml_parser (`Gzip_file filename); + with exn -> + ctxt.xml_parser <- None; + (* ZACK: the above "<- None" is vital for garbage collection. Without it + * we keep in memory a circular structure parser -> callbacks -> ctxt -> + * parser. I don't know if the ocaml garbage collector is supposed to + * collect such structures, but for sure the expat bindings will (orribly) + * leak when used in conjunction with such structures *) + raise exn); + ctxt.xml_parser <- None; (* ZACK: same comment as above *) (* debug_print (string_of_stack stack);*) + (* assert (List.length ctxt.stack = 1) *) List.hd ctxt.stack with | Failure "int_of_string" -> parse_error ctxt "integer number expected"