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
  • 22,298
  • 21
  • 125
  • 196
  • 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
  • 49,472
  • 15
  • 99
  • 121
1

A simple base R solution:

sum(sapply(e, object.size))
Hong Ooi
  • 56,353
  • 13
  • 134
  • 187