[R] Memory Problem

jim holtman jholtman at gmail.com
Sat Feb 6 13:08:20 CET 2010


Here is a function I use to get the size of the objects in my
workspace.  Let us know the output of this command

my.object.size <- 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
}


You will get something like this:

> my.object.size()
                 Size        Mode
.my.env            28 environment
.Random.seed    2,528     numeric
.required          72   character
my.object.size  6,712    function
x               6,712   character
**Total        16,052     -------
>




On Sat, Feb 6, 2010 at 4:51 AM, Meenakshi
<meenakshichidambaram at gmail.com> wrote:
>
> Hi,
> I am using R 10.2.1 version.
>
> Before run any statement/functions the gc report is:
>         used (Mb) gc trigger (Mb) max used (Mb)
> Ncells 124352  3.4     350000  9.4   350000  9.4
> Vcells  81237  0.7     786432  6.0   310883  2.4
>
> After I run the repeat statement, I got the following error message:
>
> Error: cannot allocate vector of size 100 Kb
> In addition: There were 50 or more warnings (use warnings() to see the first
> 50)
>
> Finally I have 22 objects. All are 3 columns and within 50 rows only. I
> don't know its size.
>
> I gave final gc report below:(That meas after got error messange)
>            used   (Mb) gc trigger   (Mb)  max used   (Mb)
> Ncells    322451    8.7     597831   16.0    597831   16.0
> Vcells 194014676 1480.3  285240685 2176.3 198652226 1515.6
>
> Please give solution to me.
>
>
>
> --
> View this message in context: http://n4.nabble.com/Memory-Problem-tp1459740p1471138.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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?



More information about the R-help mailing list