<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">Hi Mike, thanks for the reply<br><br>What I'm doing is an installation which will run for about an hour. I get some control signals from other laptops and according to some logic set parameters to my audio algorithms / synthesis (so yes, I'm doing sound :-) ). This logic includes a loop and a triple (nested) loop, quite necessary. They are not repeated at sample rate, they will be probably repeated every 30 seconds approximately BUT they will be repeated for a whole hour, that's why I was worried. I will try to test it when I have an hour and see if I run out of memory. But maybe it's a better idea to implement the logic in SuperCollider and send the outcome to ChucK.<br><br>&gt;&gt; From Kas:<br>&gt;&gt;<br>&gt;&gt;Still; in many cases I end up defining the variables outside of the
loop (but inside of &gt;&gt;the class or function) and where we'd normally
instantiate them I reset them to 0. &gt;&gt;I'm not religious about this as
often it's not worth the trouble but for tight, continual &gt;&gt;loops in long
term projects I do it and sometimes even go as far as recycling the
&gt;&gt;variables I use for "for" loops<br><br>Thanks Kas, yes I use all these techniques, I think I will even try to define the variables outside the class/function and pass it by reference if I see that I have a problem so that memory is allocated only once. I think actually that this might solve the problem. (I hope that it's not only objects/arrays that you pass by reference in ChucK, I'll have to check the manual...)<br><br>Dimitris<br><br>--- Στις <b>Παρ., 20/03/09, ο/η mike clemow <i>&lt;gelfmuse@gmail.com&gt;</i></b> έγραψε:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;">Από: mike clemow &lt;gelfmuse@gmail.com&gt;<br>Θέμα: Re: [chuck-users] variables and memory<br>Προς: dbozelos@yahoo.gr, "ChucK Users Mailing List" &lt;chuck-users@lists.cs.princeton.edu&gt;<br>Ημερομηνία: Παρασκευή, 20 Μάρτιος 2009, 22:51<br><br><pre>Hi Dimitris,<br><br>It's
 true that ChucK isn't great with garbage collection.  I<br>implemented your code so that it ran every sample:<br><br>while ( true )<br>{<br>        for( 0 =&gt; int i; i &lt; 100; i++ )<br>        {<br>                int var1; float var2[10];<br>                // do things<br>                1::samp =&gt; now;<br>        }<br>}<br><br>Yes: this ate about a 1Gb of memory in a few minutes.  HOWEVER, I've<br>rarely found that I needed to do something this abusive to ChucK.  To<br>be fair, this code was designed to do nothing but eat memory...<br>hopefully, you'll be asking ChucK to do something important (like make<br>sound).  Also, since you'll most likely be letting time pass to<br>implement some sort of control rate for what you're doing (e.g.<br>someduration =&gt; now;) this usually isn't happening every sample.  And<br>just because ChucK won't blink an eye at a control rate of<br>every-sample doesn't mean that it's always a good idea.<br><br>In
 theory, the above seems like a huge limitation.  In practice, I<br>find that there are other bugs and things that I generally have to<br>fight long before I get annoyed about garbage collection.  ;-)<br><br>What exactly are planning on doing?  Perhaps there's a way to do it<br>without declaring so many variables.<br><br>Cheers,<br>Mike<br><br><br>2009/3/20 Bozelos Dimitris &lt;dbozelos@yahoo.gr&gt;:<br>&gt; Hi all,<br>&gt;<br>&gt; as i've read in the documentation or maybe in some email in this list,<br>ChucK<br>&gt; lacks garbage collector. If my understanding is correct this means that it<br>&gt; does not automatically free the memory that any variable needs after<br>getting<br>&gt; out of its scope. So this probably mean that if I run a loop that declares<br>a<br>&gt; variables like<br>&gt;<br>&gt; for( int i = 0; i &lt; 100; i++; )<br>&gt; {<br>&gt; &nbsp;&nbsp;&nbsp; int var1; float var2[10];<br>&gt; &nbsp;&nbsp;&nbsp; // do things<br>&gt;
 }<br>&gt;<br>&gt; and have this code called many times inside an infinite loop and do other<br>&gt; stuff in other shreds, after a while it's inevitable to run into<br>problems.<br>&gt; Is this correct? Is there anything like c++'s delete to free memory?<br>&gt;<br>&gt; Dimitris<br>&gt;<br>&gt;<br>&gt; ________________________________<br>&gt; Χρησιμοποιείτε Yahoo!<br>&gt; Βαρεθήκατε τα ενοχλητικά μηνύ ματα (spam);<br>Το Yahoo! Mail διαθέτει την<br>&gt; καλύτερη δυνατή προστασία κατά των<br>ενοχλητικών μηνυμάτων<br>&gt; http://login.yahoo.com/config/mail?.intl=gr<br>&gt; _______________________________________________<br>&gt; chuck-users mailing list<br>&gt; chuck-users@lists.cs.princeton.edu<br>&gt; https://lists.cs.princeton.edu/mailman/listinfo/chuck-users<br>&gt;<br>&gt;<br><br><br><br>--
 <br>http://michaelclemow.com<br>http://semiotech.org<br></pre></blockquote></td></tr></table><br>



      <hr size=1><font size=-1 face=Arial> 
Χρησιμοποιείτε Yahoo!<br> 
Βαρεθήκατε τα ενοχλητικά μηνύ ματα (spam); Το Yahoo! Mail διαθέτει την καλύτερη δυνατή προστασία κατά των ενοχλητικών μηνυμάτων <br> 
<a href="http://login.yahoo.com/config/mail?.intl=gr">http://login.yahoo.com/config/mail?.intl=gr</a> </font>