s-news
[Top] [All Lists]

[S] Q: how avoid memory build up during loops and function calls

To: "'S-news@wubios.wustl.edu'" <S-news@wubios.wustl.edu>
Subject: [S] Q: how avoid memory build up during loops and function calls
From: Vadim Ogranovich <vograno@arbitrade.com>
Date: Wed, 26 Jan 2000 14:58:11 -0600
Sender: owner-s-news@wubios.wustl.edu
Hi, I thought that options "compact" and "free" should provide a relief from
memory build-up during long iterations. This does not seem to work. Here are
two (meaningless) examples where I am trying to accumulate a value during a
loop or lapply:

> assign("r", rnorm(100), where=1, immed=T)
> for (i in seq(10^5)) { assign("r", rnorm(1000), where=1, immed=T) }

After completion the process size is 112M! Here is the same stuff done
through lapply - it is neither faster nor more memory efficient:

> assign("r", rnorm(100), where=1, immed=T)
> lapply(as.list(seq(10^5)), function(x) { assign("r", rnorm(1000), where=1,
immed=T); NULL })

The process size is 130M!

The value of the compact option on my machine is 10^5, free=1.

Could you tell why S-Plus was unable to reclaim the memory?

Thanks,
Vadim



============================================================
compact= 
    Internal memory built up during a loop ( for, while, or repeat) will be
compacted when the possibly recoverable amount
    exceeds this number of bytes. Giving a value of 0 (or FALSE) to compact
turns off compacting. This choice, or a large value
    for compact trades off more memory growth for less time spent in
compacting. While the best value depends somewhat on the
    problem you are working, it depends more on the configuration and load
of the computer system. Your local S-PLUS
    administrator may have chosen a reasonable value for your system; if so,
you usually should not change it yourself.
-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu.  To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message:  unsubscribe s-news

<Prev in Thread] Current Thread [Next in Thread>
  • [S] Q: how avoid memory build up during loops and function calls, Vadim Ogranovich <=