[chuck-users] variables and memory

mike clemow gelfmuse at gmail.com
Fri Mar 20 16:51:07 EDT 2009


Hi Dimitris,

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[10];
                // 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.

Cheers,
Mike


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, ChucK
> lacks garbage collector. If my understanding is correct this means that it
> does not automatically free the memory that any variable needs after getting
> out of its scope. So this probably mean that if I run a loop that declares a
> variables like
>
> for( int i = 0; i < 100; i++; )
> {
>     int var1; float var2[10];
>     // 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 problems.
> Is this correct? Is there anything like c++'s delete to free memory?
>
> Dimitris
>
>
> ________________________________
> Χρησιμοποιείτε Yahoo!
> Βαρεθήκατε τα ενοχλητικά μηνύ ματα (spam); Το Yahoo! Mail διαθέτει την
> καλύτερη δυνατή προστασία κατά των ενοχλητικών μηνυμάτων
> http://login.yahoo.com/config/mail?.intl=gr
> _______________________________________________
> chuck-users mailing list
> chuck-users at lists.cs.princeton.edu
> https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
>
>



-- 
http://michaelclemow.com
http://semiotech.org


More information about the chuck-users mailing list