1

Apparently object.size does not work here:

> e = new.env()
> e$a = 1:10000
> e$b = 1:10000
> object.size(e)
56 bytes
> e$c = 1:10000
> object.size(e)
56 bytes
qed
  • 21,094
  • 18
  • 110
  • 180
  • possible duplicate of [Tricks to manage the available memory in an R session?](http://stackoverflow.com/questions/1358003/tricks-to-manage-the-available-memory-in-an-r-session) – hrbrmstr Oct 25 '14 at 23:05

2 Answers2

1

Use object_size function from pryr package:

> library(pryr)
> e = new.env()
> e$a = 1:10000
> e$b = 1:10000
> object.size(e)
28 bytes
> object_size(e)
80.3 kB
> e$c = 1:10000
> object.size(e)
28 bytes
> object_size(e)
120 kB

See also Hadley's doc about memory in R: http://adv-r.had.co.nz/memory.html

Marek
  • 47,613
  • 13
  • 96
  • 119
1

A simple base R solution:

sum(sapply(e, object.size))
Hong Ooi
  • 54,701
  • 13
  • 127
  • 173