![](https://secure.gravatar.com/avatar/454141e8c35e3be2ed7e8d0e32b6fbcf.jpg?s=120&d=mm&r=g)
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