[R] Summary of Total Object.Size in R Script
Prof Brian Ripley
ripley at stats.ox.ac.uk
Tue Jan 13 17:55:22 CET 2009
On Tue, 13 Jan 2009, jim holtman wrote:
> That is certainly true because I have seen differences due to the
> sharing of values. I also look at what 'gc()' shows at the memory
> being used. Does this provide a reasonable estimate of the total
> space being used?
Yes, but not just by your workspace, also all the loaded packages.
>
> On Tue, Jan 13, 2009 at 11:14 AM, Prof Brian Ripley
> <ripley at stats.ox.ac.uk> wrote:
>> On Tue, 13 Jan 2009, jim holtman wrote:
>>
>>> Here is a function I use to see how big the objects in my workspace are:
>>
>> Be careful with the caveats spelled out in ?object.size. Especially for
>> character data such summations can be way off.
>>
>>>
>>>> my.ls <-
>>>
>>> + function (pos = 1, sorted = F)
>>> + {
>>> + .result <- sapply(ls(pos = pos, all.names = TRUE), function(..x)
>>> object.size(eval(as.symbol(..x))))
>>> + if (sorted) {
>>> + .result <- rev(sort(.result))
>>> + }
>>> + .ls <- as.data.frame(rbind(as.matrix(.result), `**Total` =
>>> sum(.result)))
>>> + names(.ls) <- "Size"
>>> + .ls$Size <- formatC(.ls$Size, big.mark = ",", digits = 0,
>>> + format = "f")
>>> + .ls$Mode <- c(unlist(lapply(rownames(.ls)[-nrow(.ls)],
>>> function(x) mode(eval(as.symbol(x))))),
>>> + "-------")
>>> + .ls
>>> + }
>>>>
>>>> my.ls()
>>>
>>> Size Mode
>>> .my.env 28 environment
>>> .Random.seed 2,528 numeric
>>> .required 72 character
>>> my.ls 6,712 function
>>> **Total 9,340 -------
>>>
>>>
>>> On Tue, Jan 13, 2009 at 9:53 AM, Gundala Viswanath <gundalav at gmail.com>
>>> wrote:
>>>>
>>>> Dear all,
>>>>
>>>> Is there a way we can find the total object.size of
>>>> all the objects in our R script?
>>>>
>>>> The reason we want to do this because we want to know
>>>> how much memory does our R script require overall.
>>>>
>>>> Rprofmem(), doesn't seem to do it.
>>>>
>>>> and Unix 'top' command is dynamic and
>>>> it doesn't give the exact byte size.
>>>>
>>>> - Gundala Viswanath
>>>> Jakarta - Indonesia
>>>>
>>>> ______________________________________________
>>>> R-help at r-project.org mailing list
>>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>>> PLEASE do read the posting guide
>>>> http://www.R-project.org/posting-guide.html
>>>> and provide commented, minimal, self-contained, reproducible code.
>>>>
>>>
>>>
>>>
>>> --
>>> Jim Holtman
>>> Cincinnati, OH
>>> +1 513 646 9390
>>>
>>> What is the problem that you are trying to solve?
>>>
>>> ______________________________________________
>>> R-help at r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide
>>> http://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>>>
>>
>> --
>> Brian D. Ripley, ripley at stats.ox.ac.uk
>> Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
>> University of Oxford, Tel: +44 1865 272861 (self)
>> 1 South Parks Road, +44 1865 272866 (PA)
>> Oxford OX1 3TG, UK Fax: +44 1865 272595
>>
>
>
>
> --
> Jim Holtman
> Cincinnati, OH
> +1 513 646 9390
>
> What is the problem that you are trying to solve?
>
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help
mailing list