[chuck-users] variables and memory
dbozelos at yahoo.gr
Sat Mar 21 09:20:07 EDT 2009
Hi Mike, thanks for the reply
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.
>> From Kas:
>>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
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...)
--- Στις Παρ., 20/03/09, ο/η mike clemow <gelfmuse at gmail.com> έγραψε:
Από: mike clemow <gelfmuse at gmail.com>
Θέμα: Re: [chuck-users] variables and memory
Προς: dbozelos at yahoo.gr, "ChucK Users Mailing List" <chuck-users at lists.cs.princeton.edu>
Ημερομηνία: Παρασκευή, 20 Μάρτιος 2009, 22:51
It's true that ChucK isn't great with garbage collection. I
implemented your code so that it ran every sample:
while ( true )
for( 0 => int i; i < 100; i++ )
int var1; float var2;
// do things
1::samp => now;
Yes: this ate about a 1Gb of memory in a few minutes. HOWEVER, I've
rarely found that I needed to do something this abusive to ChucK. To
be fair, this code was designed to do nothing but eat memory...
hopefully, you'll be asking ChucK to do something important (like make
sound). Also, since you'll most likely be letting time pass to
implement some sort of control rate for what you're doing (e.g.
someduration => now;) this usually isn't happening every sample. And
just because ChucK won't blink an eye at a control rate of
every-sample doesn't mean that it's always a good idea.
In theory, the above seems like a huge limitation. In practice, I
find that there are other bugs and things that I generally have to
fight long before I get annoyed about garbage collection. ;-)
What exactly are planning on doing? Perhaps there's a way to do it
without declaring so many variables.
2009/3/20 Bozelos Dimitris <dbozelos at yahoo.gr>:
> Hi all,
> as i've read in the documentation or maybe in some email in this list,
> lacks garbage collector. If my understanding is correct this means that it
> does not automatically free the memory that any variable needs after
> out of its scope. So this probably mean that if I run a loop that declares
> variables like
> for( int i = 0; i < 100; i++; )
> int var1; float var2;
> // do things
> and have this code called many times inside an infinite loop and do other
> stuff in other shreds, after a while it's inevitable to run into
> Is this correct? Is there anything like c++'s delete to free memory?
> Χρησιμοποιείτε Yahoo!
> Βαρεθήκατε τα ενοχλητικά μηνύ ματα (spam);
Το Yahoo! Mail διαθέτει την
> καλύτερη δυνατή προστασία κατά των
> chuck-users mailing list
> chuck-users at lists.cs.princeton.edu
Βαρεθήκατε τα ενοχλητικά μηνύματα (spam); Το Yahoo! Mail
διαθέτει την καλύτερη δυνατή προστασία κατά των ενοχλητικών
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the chuck-users