s-news
[Top] [All Lists]

Re: Memory Usage During Script Execution

To: "S-News" <s-news@wubios.wustl.edu>
Subject: Re: Memory Usage During Script Execution
From: "David Smith" <dsmith@insightful.com>
Date: Thu, 2 May 2002 15:36:02 -0700
Cc: "Kim Elmore" <elmore@nssl.noaa.gov>
Thread-index: AcHyJ7qVv3s+dxKoRz6TlyAAytAi/QAAG+BA
Thread-topic: [S] Memory Usage During Script Execution
The script window in S-PLUS for Windows works by collecting the selected
text into a string, and passing it to the function "source".  It
actually calls the function script.run to do this, if you'd like to see
the code.

As a result, some (but not all) intermediate calculations are retained
in memory, so that if an error occurs during script execution, the
working database can be restored to the state before the script was run
(this is a property of the "source" function).

If you want to make each expression evaluate and commit immediately
(which often uses less memory) you can either:

1. cut and paste into the Commands window

2. Call Splus from the command line on your script file, e.g.
  
    Splus < myscript.ssc > outfile.txt
 or
    Sqpe < myscript.ssc > outfile.txt

[Sqpe uses slightly less memory, but won't work if your script relies on
any of the Windows GUI features; notably the function guiCreate.]

3. Wrap the code into a function call (objects created in evaluation
frames outside of the working databases don't need to be rolled back if
an error occurs)

I wanted to make it an option in S-PLUS 6.1 so that the script window
could optionally commit each statement as it's evaluated, like the
command window does, but for architectural reasons that proved tricky to
do.  I'll revisit the issue for 6.2.

# David Smith

-- 
David M Smith <dsmith@insightful.com>
S-PLUS Product Marketing Manager, Insightful Corp, Seattle WA
Tel: +1 (206) 802 2360
Fax: +1 (206) 283 6310

Insightful Corporation provides analytical solutions with S-PLUS
Analytic Server, StatServer, Insightful Miner and consulting services.
See www.insightful.com for details. 

> -----Original Message-----
> From: Kim Elmore [mailto:elmore@nssl.noaa.gov]
> Sent: Thursday, May 02, 2002 3:07 PM
> To: S-News
> Subject: [S] Memory Usage During Script Execution
> 
> 
> I'm running S-Plus 6r2, under Windows 2000, on a dual Athlon 
> 1800, 2 GB RAM 
> box.
> 
> I've written some rather long scripts that do rather mundane 
> things, such 
> as take the difference between two sets of matrices with, say 
> 60 matrices 
> per set.  Hence, 60 pairs of matrices are involved, and each 
> difference 
> generates yet another matrix.  The matrices are rather large, 
> about 13000 x 
> 400.
> 
> Running the script, I find that S-Plus runs out of virtual 
> memory.  Yet, if 
> I paste the script contents into the command window, all runs 
> fine.  Obviously, S-Plus is keeping a lot of objects (all of 
> them?) in 
> memory until the script execution is complete.
> 
> What's really going on here? Aside from pasting the script 
> contents into 
> the command window, is there a way to make a script behave 
> like the command 
> window?
> 
> Thanks for any insights!
> 
> Kim Elmore
>                            Kim Elmore, Ph.D.
> "All of weather is divided into three parts: Yes, No, and Maybe. The
> greatest of these is Maybe" The original Latin appears to be garbled.
> 
> --------------------------------------------------------------------
> This message was distributed by s-news@lists.biostat.wustl.edu.  To
> unsubscribe send e-mail to s-news-request@lists.biostat.wustl.edu with
> the BODY of the message:  unsubscribe s-news
> 
> 

<Prev in Thread] Current Thread [Next in Thread>