[chuck-users] variables and memory

mike clemow gelfmuse at gmail.com
Sat Mar 21 13:31:11 EDT 2009


Eduard, Kassen,

> That's interesting but are you sure that memory will actually be freed in that case? I'm not so sure about that.

Kassen, he's right!  It is freed.  At least, with his addition, the
code we posted stayed steady in the memory dept.  Very low usage and
never changed.  Without that line, it eats up memory until it's all
gone.

while ( true )
{
        for( 0 => int i; i < 100; i++ )
        {
                int var1; float var2[10];
                // do things
                1::samp => now;
                NULL @=> var2;  // this frees memory.
        }
}

Well, that's very interesting...  I have a lot of code that I want to
go back over and see if it uses less memory if I judiciously set
object references to NULL when I'm done with stuff.  There's your
destroy method, Dimitris!  Όλα Καλά!!

-Mike



2009/3/21 Kassen <signal.automatique at gmail.com>
>
> Dimitris;
>
> >
> > 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...)
> >
>
> I think most of our problems can be solved with this kind of technique, at least practically speaking.
>
> Still; I do think there are techniques that would be very worthwhile that aren't being explored in ChucK right now because doing so would lead to memory issues. For example recursion; we can use recursion (it's even used in the examples) but we tend not to. For me part of the reason there is that I fear the amount of garbage. For practical things I can re-write most things linearly so it's no big deal but a recursive approach might be extremely interesting on a compositional level.
>
> I suspect having GC will open the door to new techniques that would be impractical to explore right now.
>
> Eduard;
>
> That's interesting but are you sure that memory will actually be freed in that case? I'm not so sure about that.
>
> Yours,
> Kas.
>
> _______________________________________________
> 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