On 7 Aug 2007, at 10:06, Ari Brown wrote:

>
> On Aug 6, 2007, at 8:35 PM, Alex Gutteridge wrote:
>> Other people have explained why this really isn't such a great  
>> idea, but in the spirit of experimentation...
>>
>
> I can understand why it's not suggested that I forcefully clear the  
> RAM, but will it have a negative effect on my programs? And is  
> there a suggested way to clear the RAM using Ruby?

I think the point is that you should leave memory management to tools  
that are designed to do it: usually the kernel of whatever operating  
system you are using (which I'm guessing will have had many, many,  
expert man hours spent on it). Forcefully clearing the RAM in this  
way just shifts other processes into swap (the memory space held on  
disk rather than in RAM). Trying to access these processes is then  
very slow as they have to be read back into RAM from the disk.

For instance, if I have a copy of Firefox running, run your script  
and then try to go back to Firefox it is extremely slow for 10  
seconds or so. Once Firefox is back in RAM it then runs fine from  
then on.

Having said that, I hate telling people what to do with their time,  
and often designing something 'crazy' is a good way to learn new  
stuff. So if running your script works for you and you learn about  
memory management at the same time then go for it.

As for the suggested way to clear RAM, I think the semi-joking  
suggestions people have given you are probably about right: allocate  
a big string or Array (Ara suggested using mmap).

Alex Gutteridge

Bioinformatics Center
Kyoto University