next up previous
Next: Reading gzipped, bzipped, zipped, Up: Getting started Previous: Initialization

Memory management in S

Splus has huge problems with memory leaks (or at least the version I used back in 2001 or so did). If you run a loop with big objects, you may find memory useage creeps up inexorably. One solution is to use R.

A kludge is to write a UNIX shell script that calls S many times (or you could do this in Perl), quitting after each call and thereby clearing memory. E.g., the shell script might be along the following lines: 
Splus <file1.q >file1.out # file1.q should start your looping variable 
Splus <file2.q >file2.out # file2.q just increments the variable (don't reset it to its starting value) and does your stuff 
Splus <file3.q >file3.out # etc. ....

Put that all in a file loop.csh, do >chmod guo+x loop.csh, and then call >loop.csh.



Chris Paciorek 2012-01-21