[chuck-users] optimize memory usage when calling a large number of functions
Jean Menezes da Rocha
jean at menezesdarocha.info
Thu Oct 15 19:57:26 EDT 2015
Hello,
I am writing a program that stores a large number of objects in the memory
(thousands of), and then calls a "play" method from each one. As it goes
playing, RAM usage increases drastically and a weird lag/clicking happens.
Is there a possible method to clear memory (perhaps by discarding objects
already played) while the script is in execution? Is there any alternative
when calling a large number of functions over short periods of time?
For the sake of example, take this lame pseudocode:
class Foo {
int fooX;
float fooY;
int fooZ;
string fooBla;
string fooBlu;
fun void set(int x, float y, int z, string bla, string blu) {
x => fooX;
y => fooY;
z => fooZ;
bla => fooBla;
blu => fooBlu;
}
fun void play() {
SinOsc s => Gain g => dac;
if ( x > 2 ) { fooY * x => s.freq; }
else { if ( z < 4 ) { fooY * z => s.freq; } else { fooY => s.freq; } }
0.5 => g.gain;
if ( bla == "fast" ) { 10::ms => now; }
else { if ( bla == "slow" ) { 500::ms => now; } else { 200::ms => now; }
}
}
(now imagine a function that sets thousands of Foo objects, stores them
into an array and afterwards iterate through said array, calling .play()
function for each item. at this point things become *very* slow because of
too many objects filling up the memory).
Even using --silent, the script is eventually sluggish because memory still
is filled up.
I hope you can point me to the right direction!
--
Jean Menezes da Rocha
Compositor
Professor -- Faculdades Est
Mestre e Doutorando em Composição pela Universidade Federal da Bahia
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cs.princeton.edu/pipermail/chuck-users/attachments/20151015/12bfeba2/attachment.html>
More information about the chuck-users
mailing list