I can't seem to understand where R saves the data for
> x <- rnorm(1e4)
> y <- ecdf(x)
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 602079 32.2 1168576 62.5 750400 40.1
Vcells 1183188 9.1 299644732 2286.2 750532746 5726.2
> plot(y) # still works...
There is a fantastic explanation of function closures, the enclosing, executing and calling environments in @hadley's Advanced R.
For your specific example, as noted in the comments, the size of the object, together with its enclosing environment is much larger:
You can see the objects that this entails, and their relative sizes using this:
sapply(codetools::findGlobals(y), function(x) object.size(get(x, environment(y))))
You can sum the last vector to see that this is indeed what
pryr::object_size is reporting (164 kB on my machine).