Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in R Programming by (5.3k points)

I'd like to work out how much RAM is being used by each of my objects inside my current workspace. Is there an easy way to do this?

1 Answer

0 votes

To determine the memory usage of objects in your R environment, you can use the object.size function as follows:

mylist <- list(a=10,b=20,c=30)

> object.size(mylist)

608 bytes

To know the size of all the objects present in your R environment:

sort( sapply(ls(),function(x) {object.size(get(x))} )) 

To print the total memory used in an R session:

print(object.size(x=lapply(ls(), get)), units="Mb") 

394.6 Mb

To get the memory usage by object type:


NULL      symbol    pairlist     closure environment     promise    language 

 1       29141     1296469       25360        6406       22508      352342 

special     builtin        char     logical     integer      double     complex 

 45         689       77154       42282      234847       67617          48 

character      ...         any        list  expression    bytecode externalptr 

428052          86           0      118213           3       89732        5453 

weakref         raw          S4 

 1431        1447        4368 

Welcome to Intellipaat Community. Get your technical queries answered by top developers!

28.4k questions

29.7k answers


94k users

Browse Categories