Hi, I was experimenting with Clojure and XML and stumbled upon a lengthy hang when exiting java which was tracked down to the use of clojure.contrib.lazy-xml. Here's a toy example which exhibits the issue:
Script started on Wed Jul 29 15:06:44 2009 [~/dev/clojure]$ cat read-xml-lazy.clj (ns strange (:use clojure.contrib.lazy-xml) (import (java.io ByteArrayInputStream))) (time (clojure.contrib.lazy-xml/parse-trim (ByteArrayInputStream. (.getBytes (slurp "msgs.xml"))))) #_(System/exit 0) [~/dev/clojure]$ time java -cp clojure-1.0.0.jar\;clojure-contrib.jar clojure.lang.Script read-xml-lazy.clj "Elapsed time: 691.81977 msecs" real 1m1.796s user 0m0.031s sys 0m0.061s [~/dev/clojure]$ # now without laziness [~/dev/clojure]$ cat read-xml-nonlazy.clj (ns strange (import (java.io ByteArrayInputStream))) (time (clojure.xml/parse (ByteArrayInputStream. (.getBytes (slurp "msgs.xml"))))) #_(System/exit 0) [~/dev/clojure]$ time java -cp clojure-1.0.0.jar\;clojure-contrib.jar clojure.lang.Script read-xml-nonlazy.clj "Elapsed time: 15493.727555 msecs" real 0m16.406s user 0m0.047s sys 0m0.031s [~/dev/clojure]$ java -version java version "1.6.0_14" Java(TM) SE Runtime Environment (build 1.6.0_14-b08) Java HotSpot(TM) Client VM (build 14.0-b16, mixed mode, sharing) [~/dev/clojure]$ exit exit Script done on Wed Jul 29 15:11:14 2009 While the time to perform the lazy xml read is much less than the non- lazy, it takes nearly a minute to exit java. If the (System/exit 0) form is enabled, then the exit from java is immediate. This is on a Windows XP platform, using cygwin as the shell, although the same issue occurs when run under cmd.exe. The version of clojure- contrib is that provided by the "Programming Clojure" download. The msgs.xml file is about 3.7MB and contains about 1300 XML elements under the root. It looks a bit like: <document> <Message> ...many elements in message </Message> <Message> ...many elements in message </Message> </document> So, it looks like my mother was right and laziness costs in the end. Is anyone able to shed light on what might be going on here? Many thanks, Mark Willson --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---