Skip to content
Prev 158024 / 398500 Next

environment and scoping

Rene,

What you have below does not make much sense. You have not provided a 
definition for fun.dat() nor have you given an example with which to run 
any of your functions.

The issue you raise about passing 'dat variable as a parameter as it can 
get pretty large' is not an issue.

Observe:

------------------
used (Mb) gc trigger (Mb) max used (Mb)
Ncells  136213  3.7     350000  9.4   350000  9.4
Vcells 1091921  8.4    1540913 11.8  1091931  8.4
[1] -0.0004251693
used (Mb) gc trigger (Mb) max used (Mb)
Ncells  136405  3.7     350000  9.4   350000  9.4
Vcells 1091962  8.4    1697958 13.0  1092837  8.4
[1] 8000024
[1] -0.0008503386
used (Mb) gc trigger (Mb) max used (Mb)
Ncells  136413  3.7     350000  9.4   350000  9.4
Vcells 1091962  8.4    2441693 18.7  2091968 16.0
-------------------

x occupies most of the Vcells in R's memory.

And the 'max used' does not increase when mean(x) is called - in other 
words, no copy of x is performed.

Only when another object is created ( '2*x' ) does 'max used' increase - 
almost doubling.

So, as long as you are not modifying 'dat' (in which case a local copy is 
made) , I think there is nothing to worry about.

HTH,

Chuck
On Sat, 4 Oct 2008, Ren? Holst wrote:

            
Charles C. Berry                            (858) 534-2098
                                             Dept of Family/Preventive Medicine
E mailto:cberry at tajo.ucsd.edu	            UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901