<!-- 
RSS generated by JIRA (4.4#649-r158309) at Sun May 19 21:06:49 CDT 2013

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary add field=key&field=summary to the URL of your request.
For example:
http://dev.clojure.org/jira/si/jira.issueviews:issue-xml/CLJ-883/CLJ-883.xml?field=key&field=summary
-->
<rss version="0.92" >
<channel>
    <title>Clojure JIRA</title>
    <link>http://dev.clojure.org/jira</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>4.4</version>
        <build-number>649</build-number>
        <build-date>25-07-2011</build-date>
    </build-info>

<item>
            <title>[CLJ-883] Clojure head holding bug 				</title>
                <link>http://dev.clojure.org/jira/browse/CLJ-883</link>
                <project id="10010" key="CLJ">Clojure</project>
                        <description>&lt;p&gt;I&apos;ve a head holding problem that I believe is a bug in clojure 1.3.  I&lt;br/&gt;
wrote the following function to split a a lazy seq of strings across&lt;br/&gt;
files of x size:&lt;/p&gt;

&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt;(defn split-file
 ([path strs size]
    (trampoline split-file path (seq strs) size 0))
 ([path strs size part]
    (with-open [f (clojure.java.io/writer (str path &quot;.&quot; part))]
      (loop [written 0, ss strs]
        (when ss
          (if (&amp;gt;= written size)
            #(split-file path ss size (inc part))
            (let [s (first ss)]
              (.write f s)
              (recur (+ written (.length s)) (next ss)))))))))
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;If I call the 3 arg version of the function:&lt;br/&gt;
(split-file &quot;foo&quot; (repeat 100000000 &quot;blah blah blah&quot;) 100000000)&lt;/p&gt;

&lt;p&gt;I see memory usage increases as I&apos;m writing each file with the usual&lt;br/&gt;
gc slow down, then memory usage goes back down again as I get to a new&lt;br/&gt;
split file.&lt;/p&gt;

&lt;p&gt;Memory usage is fine if I call the 4 arg version (which only writes&lt;br/&gt;
one part of the split file):&lt;br/&gt;
(split-file &quot;foo&quot; (repeat 100000000 &quot;blah blah blah&quot;) 100000000 0)&lt;/p&gt;

&lt;p&gt;I can also avoid the head holding problem by removing trampoline and&lt;br/&gt;
recursively calling split-file directly, but then those recursive&lt;br/&gt;
calls use up stack and don&apos;t close files until all calls complete&lt;/p&gt;</description>
                <environment>java 6 jdk on linux, jre 6 on windows 7</environment>
            <key id="15030">CLJ-883</key>
            <summary>Clojure head holding bug 				</summary>
                <type id="1" iconUrl="http://dev.clojure.org/jira/images/icons/bug.gif">Defect</type>
                                <priority id="3" iconUrl="http://dev.clojure.org/jira/images/icons/priority_major.gif">Major</priority>
                    <status id="6" iconUrl="http://dev.clojure.org/jira/images/icons/status_closed.gif">Closed</status>
                    <resolution id="2">Declined</resolution>
                                <assignee username="-1">Unassigned</assignee>
                                <reporter username="gerrard.mcnulty@gmail.com">Gerrard McNulty</reporter>
                        <labels>
                    </labels>
                <created>Sun, 27 Nov 2011 05:53:11 -0600</created>
                <updated>Fri, 1 Mar 2013 12:46:59 -0600</updated>
                    <resolved>Tue, 27 Nov 2012 14:29:16 -0600</resolved>
                            <version>Release 1.3</version>
                                                        <due></due>
                    <votes>0</votes>
                        <watches>1</watches>
                        <comments>
                    <comment id="27575" author="a_strange_guy" created="Mon, 16 Jan 2012 04:15:37 -0600"  >&lt;p&gt;There is actually no problem with head retention in your code.&lt;br/&gt;
It&apos;s zust the garbage collector that doesn&apos;t collect the seq right away. If there were problems, then you would get a OutOfMemoryError pretty fast.&lt;/p&gt;

&lt;p&gt;compare&lt;br/&gt;
(split-file &quot;foo&quot; (repeat 100000000 &quot;blah blah blah&quot;) 100000000 0)&lt;br/&gt;
with&lt;br/&gt;
(doall (repeat 100000000 &quot;blah blah blah&quot;))&lt;br/&gt;
to see the difference&lt;/p&gt;</comment>
                    <comment id="30064" author="halgari" created="Tue, 27 Nov 2012 14:29:03 -0600"  >&lt;p&gt;Closing due to lack of reproducible tests. On my system I actually saw memory usage not move at all when I ran the demo code, and at one point the GC kicked in and the memory usage went down a bit. &lt;/p&gt;</comment>
                </comments>
                    <attachments>
                </attachments>
            <subtasks>
        </subtasks>
                <customfields>
                                <customfield id="customfield_10002" key="com.atlassian.jira.plugin.system.customfieldtypes:select">
                <customfieldname>Approval</customfieldname>
                <customfieldvalues>
                        <customfieldvalue key="10008">Not Approved</customfieldvalue>

                </customfieldvalues>
            </customfield>
                                                                                    <customfield id="customfield_10010" key="com.pyxis.greenhopper.jira:gh-global-rank">
                <customfieldname>Global Rank</customfieldname>
                <customfieldvalues>
                    
                </customfieldvalues>
            </customfield>
                                                                                                            </customfields>
    </item>
</channel>
</rss>