By the way, ChucK's memory model is similar to Java's in that primitive types are allocated on the stack, while anything object-y is on the heap. In other words, ints, floats, durs, times, complex's, polars, and empty references won't have any memory cost after their enclosing scope ends. For example, I can run this loop forever without seeing any particular increase in memory usage: while(true) { 0 => int i; // type can be int, float, dur, time, complex, polar, or empty reference 1::samp => now; } So, with regards to setting things to null to free their memory, ints, floats, etc. can't be set to null, but their memory does not normally need freeing. spencer On Mar 21, 2009, at 2:49 PM, mike clemow wrote:
Kassen,
I've often seen this type of thing...
0 => int i;
for(0 => i; i < 10; i++ ) { // stuff }
for(0 => i; i < 10; i++ ) { // more stuff }
just keep reusing the same iterator integer, which I assumed you were talking about earlier.
Also, this is going to be a lot more important for object references and large arrays, etc. but it's neat trick that I didn't know about before
_mike
2009/3/21 Kassen
: Mike;
Όλα Καλά!!
I'll assume that translates to "w00t"? :¬D
Three cheers for Eduard!
This won't work on floats and ints though ( for strings it's fine). Arrays of length 1, on the other hand, can be dealt with in this way if we really urgently must clean up everything.
Sadly that will make for loops look like this;
for (int n[1]; n[0] <= 5; n[0]++) { <<
>>; if( n[0] == 5) {null @=> n; break;} } That's not going to win any beauty awards. Ahum.
Kas.
_______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
-- http://michaelclemow.com http://semiotech.org _______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users