<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>>> From Kas:<br>>><br>>>Still; in many cases I end up defining the variables outside of the
loop (but inside of >>the class or function) and where we'd normally
instantiate them I reset them to 0. >>I'm not religious about this as
often it's not worth the trouble but for tight, continual >>loops in long
term projects I do it and sometimes even go as far as recycling the
>>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><gelfmuse@gmail.com></i></b> έγραψε:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;">Από: mike clemow <gelfmuse@gmail.com><br>Θέμα: Re: [chuck-users] variables and memory<br>Προς: dbozelos@yahoo.gr, "ChucK Users Mailing List" <chuck-users@lists.cs.princeton.edu><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 => int i; i < 100; i++ )<br> {<br> int var1; float var2[10];<br> // do things<br> 1::samp => 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 => 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 <dbozelos@yahoo.gr>:<br>> Hi all,<br>><br>> as i've read in the documentation or maybe in some email in this list,<br>ChucK<br>> lacks garbage collector. If my understanding is correct this means that it<br>> does not automatically free the memory that any variable needs after<br>getting<br>> out of its scope. So this probably mean that if I run a loop that declares<br>a<br>> variables like<br>><br>> for( int i = 0; i < 100; i++; )<br>> {<br>> int var1; float var2[10];<br>> // do things<br>>
}<br>><br>> and have this code called many times inside an infinite loop and do other<br>> stuff in other shreds, after a while it's inevitable to run into<br>problems.<br>> Is this correct? Is there anything like c++'s delete to free memory?<br>><br>> Dimitris<br>><br>><br>> ________________________________<br>> Χρησιμοποιείτε Yahoo!<br>> Βαρεθήκατε τα ενοχλητικά μηνύ ματα (spam);<br>Το Yahoo! Mail διαθέτει την<br>> καλύτερη δυνατή προστασία κατά των<br>ενοχλητικών μηνυμάτων<br>> http://login.yahoo.com/config/mail?.intl=gr<br>> _______________________________________________<br>> chuck-users mailing list<br>> chuck-users@lists.cs.princeton.edu<br>> https://lists.cs.princeton.edu/mailman/listinfo/chuck-users<br>><br>><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>